From cc55202ec583d0f97eecbaa4f06e7b9e1c99e8d2 Mon Sep 17 00:00:00 2001 From: Dario Sassi Date: Tue, 18 Mar 2025 17:02:20 +0100 Subject: [PATCH] DataDoors 2.7c1 : - primo commit con versione corrente. --- .gitignore | 23 + Compile.bat | 60 + LuaLibs/ConcealedHinge.lua | 1683 ++++ LuaLibs/DOORMatch.lua | 214 + LuaLibs/EPT.lua | 1589 ++++ LuaLibs/EdgePullFlat.lua | 1704 ++++ LuaLibs/EdgePullMortiseCyl.lua | 1573 ++++ LuaLibs/EgtDoorsBase.lua | 979 +++ LuaLibs/EgtDoorsData.lua | 228 + LuaLibs/EgtDoorsMsg.lua | 597 ++ LuaLibs/FC_Rectangle.lua | 913 +++ LuaLibs/FaceDecoration.lua | 129 + LuaLibs/Fc_Lines.lua | 1009 +++ LuaLibs/FlushBolt.lua | 3325 ++++++++ LuaLibs/FlushPull.lua | 1349 ++++ LuaLibs/Groove.lua | 1904 +++++ LuaLibs/ImportNgeFile.lua | 201 + LuaLibs/LockMortiseCyl.lua | 3506 +++++++++ LuaLibs/LouverCutOut.lua | 744 ++ LuaLibs/MachiningBase.lua | 3367 ++++++++ LuaLibs/MailSlot.lua | 493 ++ LuaLibs/Main_Assemb_I.lua | 55 + LuaLibs/Main_Assembly.lua | 47 + LuaLibs/MortiseHinge.lua | 1955 +++++ LuaLibs/OverHead.lua | 812 ++ LuaLibs/OverHeadArm.lua | 1370 ++++ LuaLibs/OverHeadPocket.lua | 1115 +++ LuaLibs/Pivot.lua | 3024 ++++++++ LuaLibs/Rabbet.lua | 1376 ++++ LuaLibs/RollerLatch.lua | 1957 +++++ LuaLibs/Strike.lua | 3746 +++++++++ LuaLibs/Viewer.lua | 720 ++ LuaLibs/VisionCutOut.lua | 1531 ++++ LuaLibs/_AssemblyDisp.lua | 483 ++ LuaLibs/_Latch.lua | 908 +++ LuaLibs/_LatchCorner.lua | 768 ++ LuaLibs/_LatchStrike.lua | 753 ++ LuaLibs/_Mortise.lua | 1294 ++++ LuaLibs/_MortiseCorner.lua | 954 +++ LuaLibs/_OPivot.lua | 3528 +++++++++ LuaLibs/_OverHeadArm.lua | 1458 ++++ LuaLibs/_OverHeadPocket.lua | 484 ++ LuaLibs/_PivotL.lua | 1902 +++++ LuaLibs/_Strike.lua | 1549 ++++ Machining.lua | 560 ++ Machining_1.lua | 2901 +++++++ Machining_2.lua | 2966 +++++++ Machining_3v3.lua | 7544 ++++++++++++++++++ Machining_4.lua | 4631 +++++++++++ Machining_5.lua | 4441 +++++++++++ Machining_6.lua | 4207 ++++++++++ Main.lua | 12860 +++++++++++++++++++++++++++++++ Main_Assemb.lua | 60 + Version.lua | 4 + 54 files changed, 97553 insertions(+) create mode 100644 .gitignore create mode 100644 Compile.bat create mode 100644 LuaLibs/ConcealedHinge.lua create mode 100644 LuaLibs/DOORMatch.lua create mode 100644 LuaLibs/EPT.lua create mode 100644 LuaLibs/EdgePullFlat.lua create mode 100644 LuaLibs/EdgePullMortiseCyl.lua create mode 100644 LuaLibs/EgtDoorsBase.lua create mode 100644 LuaLibs/EgtDoorsData.lua create mode 100644 LuaLibs/EgtDoorsMsg.lua create mode 100644 LuaLibs/FC_Rectangle.lua create mode 100644 LuaLibs/FaceDecoration.lua create mode 100644 LuaLibs/Fc_Lines.lua create mode 100644 LuaLibs/FlushBolt.lua create mode 100644 LuaLibs/FlushPull.lua create mode 100644 LuaLibs/Groove.lua create mode 100644 LuaLibs/ImportNgeFile.lua create mode 100644 LuaLibs/LockMortiseCyl.lua create mode 100644 LuaLibs/LouverCutOut.lua create mode 100644 LuaLibs/MachiningBase.lua create mode 100644 LuaLibs/MailSlot.lua create mode 100644 LuaLibs/Main_Assemb_I.lua create mode 100644 LuaLibs/Main_Assembly.lua create mode 100644 LuaLibs/MortiseHinge.lua create mode 100644 LuaLibs/OverHead.lua create mode 100644 LuaLibs/OverHeadArm.lua create mode 100644 LuaLibs/OverHeadPocket.lua create mode 100644 LuaLibs/Pivot.lua create mode 100644 LuaLibs/Rabbet.lua create mode 100644 LuaLibs/RollerLatch.lua create mode 100644 LuaLibs/Strike.lua create mode 100644 LuaLibs/Viewer.lua create mode 100644 LuaLibs/VisionCutOut.lua create mode 100644 LuaLibs/_AssemblyDisp.lua create mode 100644 LuaLibs/_Latch.lua create mode 100644 LuaLibs/_LatchCorner.lua create mode 100644 LuaLibs/_LatchStrike.lua create mode 100644 LuaLibs/_Mortise.lua create mode 100644 LuaLibs/_MortiseCorner.lua create mode 100644 LuaLibs/_OPivot.lua create mode 100644 LuaLibs/_OverHeadArm.lua create mode 100644 LuaLibs/_OverHeadPocket.lua create mode 100644 LuaLibs/_PivotL.lua create mode 100644 LuaLibs/_Strike.lua create mode 100644 Machining.lua create mode 100644 Machining_1.lua create mode 100644 Machining_2.lua create mode 100644 Machining_3v3.lua create mode 100644 Machining_4.lua create mode 100644 Machining_5.lua create mode 100644 Machining_6.lua create mode 100644 Main.lua create mode 100644 Main_Assemb.lua create mode 100644 Version.lua diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..495bd51 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ + +# / +/revision.h +/*.aps +/*.ncb +/*.suo +/*.user +/*.sdf +/*.opensdf +/Debug32 +/Release32 +/Trial32 +/Debug64 +/Release64 +/ipch +/obj +/.vs +/bin/*.lua +/bin/*.ini +/bin/LuaLibs/*.lua +/bin/Images/*.png +.vscode/settings.json +bin/Images/.placeholder diff --git a/Compile.bat b/Compile.bat new file mode 100644 index 0000000..7ec817b --- /dev/null +++ b/Compile.bat @@ -0,0 +1,60 @@ + +REM Compilazione della libreria lua EgtDoors standard 2025.03.18 +REM Per togliere info di debug aggiungere flag -s prima del nome del file di input + +REM Cancellazione precedenti compilazioni +erase /S /Q C:\EgtData\Doors_Sources\Bin\*.* + +REM Compilazione luac54 +"c:\EgtProg\Dll32\luac54" -o Bin\Machining.lua Machining.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_1.lua Machining_1.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_2.lua Machining_2.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_3v3.lua Machining_3v3.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_4.lua Machining_4.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_5.lua Machining_5.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Machining_6.lua Machining_6.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Main.lua Main.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Main_Assemb.lua Main_Assemb.lua +"c:\EgtProg\Dll32\luac54" -o Bin\Version.lua Version.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_AssemblyDisp.lua LuaLibs\_AssemblyDisp.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_Latch.lua LuaLibs\_Latch.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_LatchCorner.lua LuaLibs\_LatchCorner.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_LatchStrike.lua LuaLibs\_LatchStrike.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_Mortise.lua LuaLibs\_Mortise.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_MortiseCorner.lua LuaLibs\_MortiseCorner.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_OPivot.lua LuaLibs\_OPivot.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_OverHeadArm.lua LuaLibs\_OverHeadArm.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_OverHeadPocket.lua LuaLibs\_OverHeadPocket.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_PivotL.lua LuaLibs\_PivotL.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\_Strike.lua LuaLibs\_Strike.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\ConcealedHinge.lua LuaLibs\ConcealedHinge.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\DOORMatch.lua LuaLibs\DOORMatch.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EdgePullFlat.lua LuaLibs\EdgePullFlat.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EdgePullMortiseCyl.lua LuaLibs\EdgePullMortiseCyl.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EgtDoorsBase.lua LuaLibs\EgtDoorsBase.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EgtDoorsData.lua LuaLibs\EgtDoorsData.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EgtDoorsMsg.lua LuaLibs\EgtDoorsMsg.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\EPT.lua LuaLibs\EPT.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\FaceDecoration.lua LuaLibs\FaceDecoration.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Fc_Lines.lua LuaLibs\Fc_Lines.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Fc_Rectangle.lua LuaLibs\Fc_Rectangle.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\FlushBolt.lua LuaLibs\FlushBolt.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\FlushPull.lua LuaLibs\FlushPull.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Groove.lua LuaLibs\Groove.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\ImportNgeFile.lua LuaLibs\ImportNgeFile.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\LockMortiseCyl.lua LuaLibs\LockMortiseCyl.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\LouverCutOut.lua LuaLibs\LouverCutOut.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\MachiningBase.lua LuaLibs\MachiningBase.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\MailSlot.lua LuaLibs\MailSlot.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Main_Assemb_I.lua LuaLibs\Main_Assemb_I.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Main_Assembly.lua LuaLibs\Main_Assembly.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\MortiseHinge.lua LuaLibs\MortiseHinge.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\OverHead.lua LuaLibs\OverHead.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\OverHeadArm.lua LuaLibs\OverHeadArm.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\OverHeadPocket.lua LuaLibs\OverHeadPocket.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Pivot.lua LuaLibs\Pivot.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Rabbet.lua LuaLibs\Rabbet.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\RollerLatch.lua LuaLibs\RollerLatch.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Strike.lua LuaLibs\Strike.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\Viewer.lua LuaLibs\Viewer.lua +"c:\EgtProg\Dll32\luac54" -o Bin\LuaLibs\VisionCutOut.lua LuaLibs\VisionCutOut.lua diff --git a/LuaLibs/ConcealedHinge.lua b/LuaLibs/ConcealedHinge.lua new file mode 100644 index 0000000..ee71ca1 --- /dev/null +++ b/LuaLibs/ConcealedHinge.lua @@ -0,0 +1,1683 @@ +-- +-- 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 +-- +-- ConcealedHinge.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Concealed Hinge dati i valori 'L' e 'H' e 'T' e 'L2' e 'T2' e 'd' e 'p' e 'P' e con nomi attributi + +-- 2016.09.21 V1.011 FM add warning messages +-- 2017.12.08 V1.012 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.013 FM Manage new extra bore parameters (4 couples of bores) +-- 2018.04.05 V1.014 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.015 FM Add parameter to show into message 402 +-- 2018.10.22 V1.016 FM Manage better the big radius fillet parameter +-- 2018.11.09 V1.017 FM Manage flag to enable/disable rotation on profile on extra bores +-- 2018.11.12 V1.018 FM To be compatible to new geometry movement into Main, +-- move any geometries instead of move only layer +-- 2019.10.02 V1.019 FM Manage steel option (disable to generate pocket paths, mortise) +-- 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.29 V2.004 FM Update for aluminum material +-- 2020.05.04 V2.005 FM Manage extra bores as Mortise hinge component +-- 2020.05.25 V2.006 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.05.25 V2.007 FM Manage new parameter mfp and jnb +-- 2020.07.01 V2.008 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 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)) +-- 2024.07.19 V3.005 FM Set note 'NotCheckDir' to pocketing and buttonhole pocketing paths +-- 2024.10.29 V3.006 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal +-- 2025.03.11 V3.021 DS Backset reference side from DGC.ChBsNs. + +-- Tavola per definizione modulo (serve ma non usata) +local ConcealedHinge = {} + +-- 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 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, 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 + EgtSetInfo( hint3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +-- Funzione di sistemazione parametri +function ConcealedHinge.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + + -- do errore se profilo diverso da SQ e EB e non è ammesso + if not DGC.Eah and DGD.tProfs.hingeedge.trimming ~= 'SQ' and DGD.tProfs.hingeedge.trimming ~= 'EB' then + return tMhPar, 1699, string.format(EgtDoorsMsg[429], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) + end + + -- parametro disposizione frame su lato wide (se = nil è sulla porta, se true dispsizione frame sul lato wide, se false dispsozione su lato narrow) + tMhPar.Dws = DGD.Dws + + 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 + + -- se profilo bevel disabilito la giunzione tra face e mortise a meno del parametro di adattamento mortise + 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 + -- se parametro non presente o false disattivo la giunzione + if not tMhPar.mfp then + tMhPar.jnb = false -- giunzione non possibile + else + tMhPar.jnb = true -- giunzione possibile + end + tMhPar.bev = true + else + tMhPar.jnb = true -- giunzione possibile + end + + local bLockOnRight = DGD.Lock == 'R' + + if ( DGD.Lock == 'R' or not DGD.Push) and + ( DGD.Lock == 'R' ~= not DGD.Push) then + if tMhPar.D_X then + tMhPar.D_X = -tMhPar.D_X + end + if tMhPar.DB_X then + tMhPar.DB_X = -tMhPar.DB_X + end + end + + if tMhPar.D_Y then + tMhPar.D_Y = -tMhPar.D_Y + end + if tMhPar.DB_Y then + tMhPar.DB_Y = -tMhPar.DB_Y + end + + -- Assegno parametri da ddf (verifico se configurato Concealed Hinges with Backset from NarrowSide) + if DGC.ChBsNs then + tMhPar.D = DGD.dT - tChPar.H - DGD.BACK_SET + else + tMhPar.D = DGD.BACK_SET + 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 = (tMhPar.D + (tMhPar.H/2)) - (DGD.dT/2) + else + tMhPar.posh = ((tMhPar.D + (tMhPar.H/2)) * cos( 3)) - (DGD.dT/2) + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se ho arrotondamento disabilito il chisel e il cleancorner + if tMhPar.CL then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLH = nil + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.CL and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se porta steel o aluminum disabilito la svuotatura, la mortasa e i fori 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 + + -- 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, + -- se è attivo l'arrotondamento, anche il clean corner + if tMhPar.rf > 0 then + tMhPar.ech = false + if tMhPar.CL then + tMhPar.clc = nil + tMhPar.CLH = nil + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLG + local nLGi = 1 + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLMM + local nLMMi = 1 + + -- se profilo cerniere bevel up + if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + nLGi = 2 + nLMi = 2 + if tMhPar.mfp then + nLAi = 2 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale + nLMMi = 2 + end + elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down + nLGi = 3 + nLMi = 3 + if tMhPar.mfp then + nLAi = 3 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale + nLMMi = 3 + end + end + + if tMhPar.est and tMhPar.LG then + sLG = tMhPar.LG + nLGi = 1 + if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LM then + sLM = tMhPar.LM + nLMi = 1 + if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + end + + if tMhPar.LA then + sLA = tMhPar.LA + nLAi = 1 + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end + end + + if tMhPar.LMM then + sLMM = tMhPar.LMM + nLMMi = 1 + if DGD.MachEn > 0 and tMhPar.d2a then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMM, nLMMi) end + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + nLGi = 1 + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) 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 <= 0 then + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLG, nLGi, tMhPar.d, dNumLog, sMchngName0) + elseif tMhPar.est and nTempT0 then + tMhPar.d = nTempT0 + end + + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName2) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + end + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + if not tMhPar.est and tMhPar.d2a and nTempT3 and nTempT3 <= 0 then + if DGD.bProoduce and not tMhPar.jn2 then -- se non si concatenano i due percorsi + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMM, nLMMi, tMhPar.d2a, dNumLog, sMchngName3) + end + elseif not tMhPar.est and nTempT3 then + tMhPar.d2a = nTempT3 + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + end + + -- 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 = -1691 + 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 = -1698 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jnb and tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1697 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if( not tMhPar.jn or not tMhPar.jnb) and tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1696 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + + -- se seconda mortise concatenata a prima e a face e la profondità della seconda mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jn2 and + tMhPar.T2a and dMaxMat1 and tMhPar.T2a > dMaxMat1 then + dNumLog = -1693 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2a), EgtToUiUnits(dMaxMat1)) + tMhPar.T2a = dMaxMat1 + end + + -- se seconda mortise concatenata a prima ma non a face e la profondità della seconda mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and tMhPar.jn2 and + tMhPar.T2a and dMaxMat2 and tMhPar.T2a > dMaxMat2 then + dNumLog = -1692 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2a), EgtToUiUnits(dMaxMat2)) + tMhPar.T2a = dMaxMat2 + end + + -- se la profondità della seconda mortise non è concatenata ed è maggiore della capacità utensile limito la profondità ed emetto un warning + if not tMhPar.jn and not tMhPar.jn2 and + tMhPar.T2a and dMaxMat3 and tMhPar.T2a > dMaxMat3 then + dNumLog = -1694 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2a), EgtToUiUnits(dMaxMat3)) + tMhPar.T2a = dMaxMat3 + 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 + + -- 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 = -1690 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName,'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -1690 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName,'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2a and abs(tMhPar.T2a) > tMhPar.TTP then + dNumLog = -1690 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2a', EgtToUiUnits(tMhPar.T2a), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2a = tMhPar.TTP + 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 ConcealedHinge.Draw( tConcldPar, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- setto un parametro atteso nel componente _latch + tConcldPar.invG = 1 + + -- Assegno le dimensioni + local L = tConcldPar.L + local H = tConcldPar.H + local T = tConcldPar.T + local D = tConcldPar.D + local L2 = tConcldPar.L2 + local H2 = tConcldPar.H2 + local T2 = tConcldPar.T2 + local sf = tConcldPar.sf + local rf = tConcldPar.rf + local clc = tConcldPar.clc + local ccr = tConcldPar.ccr + local s = tConcldPar.s + local d = tConcldPar.d + local p = tConcldPar.p + local jn = tConcldPar.jn -- flag per giunzione prima cava face con seconda cava (mortasa) + local jnb = tConcldPar.jnb -- flag che indica se profilo tipo bevel o no + local mfp = tConcldPar.mfp -- flag che indica se la mortasa deve seguire il profilo + local d2 = tConcldPar.d2 + local p2 = tConcldPar.p2 + local CL = tConcldPar.CL + local D_X = tConcldPar.D_X -- delta on X pos on mortise + local D_Y = tConcldPar.D_Y -- delta on X pos on mortise + local L2a = tConcldPar.L2a + local H2a = tConcldPar.H2a + local T2a = tConcldPar.T2a + local d2a = tConcldPar.d2a + local p2a = tConcldPar.p2a + local s2a = tConcldPar.s2a + local posh = tConcldPar.posh -- posizione in Y del foro di tastatura + local posp = tConcldPar.posp -- posizione in X del foro di tastatura + local jn2 = tConcldPar.jn2 -- flag per giunzione seconda cava (mortasa) con terza cava ( seconda mortasa) + local DB_X = tConcldPar.DB_X -- delta on X pos on second mortise + local DB_Y = tConcldPar.DB_Y -- delta on Y pos on second mortise + local invG = tConcldPar.invG + local ech = tConcldPar.ech + local est = tConcldPar.est + local kbs = tConcldPar.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tConcldPar.pbs + local dws = tConcldPar.Dws + local dthd = tConcldPar.dThD + local ttp = tConcldPar.TTP + local tExtraBore = {} + table.insert( tExtraBore, { tConcldPar.D3, tConcldPar.T3, tConcldPar.I3, tConcldPar.PX3, tConcldPar.PY3, tConcldPar.EB3, tConcldPar.HB3, tConcldPar.IT3}) + table.insert( tExtraBore, { tConcldPar.D4, tConcldPar.IY4, tConcldPar.T4, tConcldPar.I4, tConcldPar.PX4, tConcldPar.PY4, tConcldPar.RP4, tConcldPar.EB4, tConcldPar.EBH4, tConcldPar.HB4, tConcldPar.AR4, tConcldPar.RCI4, tConcldPar.IT4, tConcldPar.RCIT4}) + table.insert( tExtraBore, { tConcldPar.D5, tConcldPar.IY5, tConcldPar.T5, tConcldPar.I5, tConcldPar.PX5, tConcldPar.PY5, tConcldPar.RP5, tConcldPar.EB5, tConcldPar.EBH5, tConcldPar.HB5, tConcldPar.AR5, tConcldPar.RCI5, tConcldPar.IT5, tConcldPar.RCIT5}) + table.insert( tExtraBore, { tConcldPar.D6, tConcldPar.IY6, tConcldPar.T6, tConcldPar.I6, tConcldPar.PX6, tConcldPar.PY6, tConcldPar.RP6, tConcldPar.EB6, tConcldPar.EBH6, tConcldPar.HB6, tConcldPar.AR6, tConcldPar.RCI6, tConcldPar.IT6, tConcldPar.RCIT6}) + + -- Assegno i nomi dei layer + local LG = tConcldPar.LG + local LM = tConcldPar.LM + local LG2 = tConcldPar.LG2 + local LA = tConcldPar.LA + local CLH = tConcldPar.CLH + local LGM = tConcldPar.LGM + local LMM = tConcldPar.LMM + local CH = tConcldPar.CH + local LH = 'Hinge_Probe' + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tConcldPar.Nome + local nCompoNpar = tConcldPar.Npar + local sCompoPath = tConcldPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tConcldPar.nCod + local sCodAdj = tConcldPar.sCod + -- nomi parametri per messaggi + local sNamePar1 = tConcldPar.N1 or 'L' + local sNamePar2 = tConcldPar.N2 or 'H' + local sNamePar3 = tConcldPar.N3 or 'T' + local sNamePar4 = tConcldPar.N4 or 'D' + local sNamePar5 = tConcldPar.N5 or 'L2' + local sNamePar6 = tConcldPar.N6 or 'T2' + local sNamePar7 = tConcldPar.N7 or 's' + local sNamePar8 = tConcldPar.N8 or 'd' + local sNamePar9 = tConcldPar.N9 or 'p' + local sNamePar11 = tConcldPar.N11 or 'd2' + local sNamePar12 = tConcldPar.N12 or 'sf' + local sNamePar13 = tConcldPar.N13 or 'D_X' + local sNamePar14 = tConcldPar.N14 or 'D_Y' + local sNamePar15 = tConcldPar.N15 or 'H2' + local sNamePar16 = tConcldPar.N16 or 'H2a' + local sNamePar17 = tConcldPar.N17 or 'T2a' + local sNamePar18 = tConcldPar.N18 or 'DB_X' + local sNamePar19 = tConcldPar.N19 or 'DB_Y' + local sNamePar20 = tConcldPar.N20 or 'd2a' + local sNamePar21 = tConcldPar.N21 or 'rf' + local sNamePar22 = tConcldPar.N22 or 'p2' + local sNamePar23 = tConcldPar.N23 or 'L2a' + local sNamePar24 = tConcldPar.N24 or 'p2a' + local sNamePar25 = tConcldPar.N25 or 's2a' + local sNamePar26 = tConcldPar.N26 or 'clc' + local sNamePar27 = tConcldPar.N27 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1650 + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeMortGeom2nd = true + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + clc = nil + CLH = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom then + if L >= H then + if rf > (H/2) then + rf = (H/2) + tConcldPar.rf = rf + end + else + if rf > (L/2) then + rf = (L/2) + tConcldPar.rf = rf + end + end + end + + if not bRunByCompo then RC = false end + if not T then T = 0 end + -- se junzione impossibilitata disattivo il join tra face e mortasa + if not jnb then + jn = false + tConcldPar.jn = false + end + + 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 + tConcldPar.LG = LG + if nDrawMach == 1 then -- se ho abilitato solo le geometrie di lavorazione + nForceMakeFace = 2 + end + end + + -------------------------------------------------------- + -- set parametri attesi nel componente _latch o _mortise + -- o che potrebbero non esserci nei vecchi lua + -------------------------------------------------------- + + -- posizione in X mortasa dal centro face + if not D_X then + D_X = 0 + tConcldPar.D_X = 0 + end + + -- posizione in Y mortasa dal centro face + if not D_Y then + D_Y = 0 + tConcldPar.D_Y = 0 + end + + -- qui utilizzo un bool ma nel componente _latch uso un numero per definire l'arrotondamento + if bMakeFaceGeom and CL then + cl = 3 -- setto entrambe gli estremi raccordati + tConcldPar.cl = 3 + else + cl = 0 -- setto nessun estremo raccordato + tConcldPar.cl = 0 + end + + -- altezza mortise, setto come altezza face per compatibilità con i vecchi lua + if not H2 then + H2 = H + tConcldPar.H2 = H + end + + if est or ( not L2 or not H2) then + bMakeMortGeom = false + -- disattivo i join + jn = false + jn2 = false + end + + if not T2 then + T2 = 0 + end + + if est or ( not L2a or not H2a) then + bMakeMortGeom2nd = false + jn2 = false + end + + if not T2a then + T2a = 0 + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + elseif not p2 and bMakeMortGeom then + p2 = p + end + -- se seconda e terza cava giuntate assegno il diametro della terza cava uguale alla seconda + if jn2 and bMakeMortGeom and bMakeMortGeom2nd then + d2a = d2 + p2a = p2 + end + + -- posizione in X seconda mortise dal centro mortise + if bMakeMortGeom2nd and not DB_X then + DB_X = 0 + if bMakeMortGeom then + DB_X = D_X + end + tConcldPar.DB_X = DB_X + end + + -- posizione in Y seconda mortise dal centro mortise + if bMakeMortGeom2nd and not DB_Y then + DB_Y = 0 + if bMakeMortGeom then + DB_Y = D_Y + end + tConcldPar.DB_Y = DB_Y + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EM = string.format(EgtDoorsMsg[400],sNamePar8,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile 'd' deve essere >= di + EC = 1 + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and d2 < DgMin then + EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile 'd2' deve essere >= di + EC = 2 + d2 = DgMin + elseif bMakeMortGeom2nd and nDrawMach > 0 and d2a < DgMin then + EM = string.format(EgtDoorsMsg[400],sNamePar20,EgtToUiUnits(d2a),EgtToUiUnits(DgMin)) -- il diametro utensile 'd2a' deve essere >= di + EC = 3 + d2a = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + EC = 4 + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and H2 < d2 then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[405],sNamePar15,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + EC = 5 + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and H2a < d2a then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[405],sNamePar16,EgtToUiUnits(H2a),EgtToUiUnits(d2a), sCompoPath) -- il parametro 'H2a' deve essere >= del diametro utensile + EC = 6 + H2a = d2a + else + d2a = H2a - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile + EC = 7 + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and L2 <= d2 then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[402],sNamePar5,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + EC = 8 + L2 = d2 + 0.002 + else + d2 = L2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and L2a <= d2a then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[402],sNamePar23,EgtToUiUnits(L2a),sNamePar20,EgtToUiUnits(d2a), sCompoPath) -- il parametro 'L2a' deve essere maggiore al diametro utensile + EC = 9 + L2a = d2a + 0.002 + else + d2a = L2a - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EM = string.format(EgtDoorsMsg[403],sNamePar9,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + EC = 10 + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and p2 and ( p2 < PtMin or p2 > PtMax) then + EM = string.format(EgtDoorsMsg[403],sNamePar22,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + EC = 11 + p2 = 0.8 + elseif bMakeMortGeom2nd and nDrawMach > 0 and p2a and ( p2a < PtMin or p2a > PtMax) then + EM = string.format(EgtDoorsMsg[403],sNamePar24,p2a,PtMin,PtMax, sCompoPath) -- il parametro 'p2a' deve essere compreso tra + EC = 12 + p2a = 0.8 + elseif bMakeFaceGeom and T < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + EC = 13 + T = 0 + elseif bMakeMortGeom and T2 <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + EC = 14 + T2 = 0.1 + elseif bMakeMortGeom2nd and T2a < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(T2a), sCompoPath) -- il parametro 'T2a' deve essere >= 0 + EC = 15 + T2a = 0 + elseif D < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar4,EgtToUiUnits(D), sCompoPath) -- il parametro 'D' deve essere >= 0 + EC = 16 + D = 0 + elseif bMakeFaceGeom and bMakeMortGeom and L2 >= L then + EM = string.format(EgtDoorsMsg[406],sNamePar5,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + EC = 17 + L2 = L - 0.1 + elseif bMakeMortGeom and bMakeMortGeom2nd and L2a >= L2 then + EM = string.format(EgtDoorsMsg[406],sNamePar23,EgtToUiUnits(L2a),sNamePar5,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L2a' deve essere < 'L2' + EC = 18 + L2a = L2 - 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 <= T then + EM = string.format(EgtDoorsMsg[407],sNamePar6,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + EC = 19 + T2 = T + 0.1 + elseif bMakeMortGeom and bMakeMortGeom2nd and not dws and T2a <= T2 then + EM = string.format(EgtDoorsMsg[407],sNamePar17,EgtToUiUnits(T2a),sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2a' deve essere > 'T2' + EC = 20 + T2a = T2 + 0.1 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar12,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + EC = 21 + sf = d + elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + EC = 22 + s = d2 + elseif bMakeMortGeom2nd and nDrawMach > 0 and s2a and s2a <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar25,EgtToUiUnits(s2a), sCompoPath) -- il parametro 's2a' deve essere > 0 + EC = 23 + s2a = d2a + elseif bMakeFaceGeom and CL and rf < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar21,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + EC = 24 + rf = H/2 + elseif bMakeFaceGeom and CL and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + EC = 25 + L = H+5 + elseif bMakeFaceGeom and CL and rf < (H/2) and L <= (rf*2) then + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar21..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2' + EC = 26 + L = (rf*2)+5 + elseif bMakeFaceGeom and bMakeMortGeom and CL and (L-(rf*2)) < (L2 - d2 + (2*abs(D_X))) then + EM = string.format(EgtDoorsMsg[423],sNamePar13,EgtToUiUnits(D_X),EgtToUiUnits((L-(rf*2)-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + EC = 27 + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and not CL and L < (L2+(2*abs(D_X))) then + EM = string.format(EgtDoorsMsg[423],sNamePar13,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + EC = 28 + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar15,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2' + EC = 29 + H2 = H + elseif bMakeMortGeom and bMakeMortGeom2nd and H2a > H2 then + EM = string.format(EgtDoorsMsg[422],sNamePar15,EgtToUiUnits(H2),sNamePar16,EgtToUiUnits(H2a), sCompoPath) -- il parametro 'H2' deve essere >= del parametro 'H2a' + EC = 30 + H2a = H2 + elseif bMakeMortGeom and nDrawMach > 0 and jn and H < (H2+abs(2*D_Y)) then + EM = string.format(EgtDoorsMsg[423],sNamePar14,EgtToUiUnits(abs(D_Y)),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D_Y' é troppo grande, max valore: + EC = 31 + D_Y = 0 + elseif bMakeFaceGeom and bMakeMortGeom2nd and H2a > H then + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar16,EgtToUiUnits(H2a), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2a' + EC = 32 + H2a = H + elseif bMakeFaceGeom and CLH and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 33 + EM = string.format(EgtDoorsMsg[407],sNamePar26,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 + + -- variabili dei percorsi geometrici + local nGeom1, nGeom2, nGeom3 + local nPkToJoin1, nPkToJoin2, nPkToJoin3, nPkToJoin + local nPkJoin1 + local hint3, hint5 + + local Lg, Dm + local sRequireCompoName + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + tConcldPar.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + sRequireCompoName = '_Latch' + + if bMakeFaceGeom then + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, tConcldPar, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom1 then EgtSetInfo(nGeom1,'SideDoor','SideLH') end + if nPkToJoin1 then EgtSetInfo(nPkToJoin1,'SideDoor','SideLH') end + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + + 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 + EgtSetInfo( CLC1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + EgtSetInfo( CLC1,'SideDoor','SideLH') + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + else + -- disattivo il join dei percorsi + jn = false + tConcldPar.jn = false + end + + if bMakeMortGeom then + -- cava mortasa + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.L3 = L2a + dMortise.H3 = H2a + dMortise.LGM = LG2 + dMortise.LMM = LA + dMortise.Nome = sCompoName + dMortise.jne = jn2 + dMortise.mfp = mfp + -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva + if jn2 then + dMortise.D_X = (DB_X-D_X) + end + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom2 then + if mfp then + EgtSetInfo(nGeom2,'SideDoor','SideLH') + else + EgtSetInfo(nGeom2,'SideDoor','LockLH') + end + end + if nPkToJoin2 then + if mfp then + EgtSetInfo(nPkToJoin2,'SideDoor','SideLH') + else + EgtSetInfo(nPkToJoin2,'SideDoor','LockLH') + end + end + end + + if EC == 0 and ( nGeom2 or nPkToJoin2) then + if D_X ~= 0 or D_Y ~= 0 then + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,D_Y,0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,D_Y,0) - ORIG()) + end + end + end + + if bMakeMortGeom2nd then + + -- cava mortasa + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T2 + dMortise.L2 = L2a + dMortise.H2 = H2a + dMortise.T2 = T2a + dMortise.s = s2a + dMortise.d = d2a + dMortise.p = p2a + dMortise.jn = jn2 + dMortise.d3 = d2a + dMortise.p3 = p2a + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.jne = false -- non ci sono ulteriori cave, disabilito il join alla successiva + dMortise.LGM = LGM + dMortise.LMM = LMM + dMortise.Nome = sCompoName + -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva + dMortise.D_X = 0 + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom3, nPkToJoin3 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom3 then + if mfp then + EgtSetInfo(nGeom3,'SideDoor','SideLH') + else + EgtSetInfo(nGeom3,'SideDoor','LockLH') + end + end + if nPkToJoin3 then + if mfp then + EgtSetInfo(nPkToJoin3,'SideDoor','SideLH') + else + EgtSetInfo(nPkToJoin3,'SideDoor','LockLH') + end + end + end + + if EC == 0 and ( nGeom3 or nPkToJoin3) then + if DB_X ~= 0 or DB_Y ~= 0 then + if nGeom3 then + EgtMove( nGeom3, Point3d(DB_X,DB_Y,0) - ORIG()) + end + if nPkToJoin3 then + EgtMove( nPkToJoin3, Point3d(DB_X,DB_Y,0) - ORIG()) + end + end + end + + -- se percorsi fatti con lo stesso utensile, li concateno + if jn and EC == 0 and nDrawMach > 0 and nPkToJoin1 and nPkToJoin2 then + nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + if nPkToJoin then + EgtSetName( nPkToJoin, LM) + EgtSetInfo( nPkToJoin, 'NotCheckDir', '1') + -- se mantiene backset anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 34 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and nDrawMach > 0 then -- altrimenti se non devo concatenare + -- se mantiene backset su face + if kbs and kbs > 0 and nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + -- se mantiene backset su face e mortise + elseif kbs and kbs > 0 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + end + if pbs and pbs > 0 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + -- se mantiene backset su face e mortise + elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + end + + if jn2 and EC == 0 and nDrawMach > 0 and ( nPkToJoin or nPkToJoin2) and nPkToJoin3 then + if nPkToJoin then -- se riuscito primo concatenamento + nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin,nPkToJoin3}, true) + else + nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin2,nPkToJoin3}, true) + end + + if nPkJoin1 then + if nPkToJoin then + EgtSetName( nPkJoin1, LM) + EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') + -- se mantiene backset anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + else + EgtSetName( nPkJoin1, LA) + EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + else + EC = ErrorBase + 35 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn2 and EC == 0 and nDrawMach > 0 and nPkToJoin3 then -- altrimenti se non devo concatenare + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + + -- aggiungo foro/i probe + if EC == 0 and nDrawMach > 0 and posh then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- 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 + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + + if EC == 0 then + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local IT10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + 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] + AR10 = tExtraBore[k][11] + RCI10 = tExtraBore[k][12] + IT10 = tExtraBore[k][13] + RCIT10 = tExtraBore[k][14] + 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 + + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, dInt10, dIntT10, + D10, 0, -PY10, T10, RP10, + AR10, RCI10, kbs, bEqualTh, HB10, + dws, 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 + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, dInt10, -dIntT10, + D10, 0, -PY10, T10, RP10, + AR10, RCI10, kbs, bEqualTh, HB10, + dws, pbs, RCIT10) + end + + -- se l'interasse lungo l'altezza porta è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, -dInt10, dIntT10, + D10, 0, -PY10, T10, RP10, + AR10, RCI10, kbs, bEqualTh, HB10, + dws, 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 + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, -dInt10, -dIntT10, + D10, 0, -PY10, T10, RP10, + AR10, RCI10, kbs, bEqualTh, HB10, + dws, pbs, RCIT10) + end + end + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if nGeom1 then + nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom2 then + nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom3 then + nIdSideBoxUp = EgtCopyGlob( nGeom3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + --spostamento layer + -- EgtMove( Lg, Point3d(0,-(D+(H/2)),0) - ORIG()) + -- ciclo di spostamento di tutta la geometria + local nSubIdGeom = EgtGetFirstInGroup( Lg) + + while nSubIdGeom do + EgtMove( nSubIdGeom, Point3d(0,-(D+(H/2)),0) - ORIG()) + nSubIdGeom = EgtGetNext(nSubIdGeom) + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart( Pz, sCompoName, nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo( Lg, 'Type' ,'ConceleadHinge') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'D' ,D) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'jn' ,jn) + EgtSetInfo( Lg, 'jnb' ,jnb) + EgtSetInfo( Lg, 'mfp' ,mfp) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'p2' ,p2) + EgtSetInfo( Lg, 'D_X' ,D_X) + EgtSetInfo( Lg, 'D_Y' ,D_Y) + EgtSetInfo( Lg, 'L2a' ,L2a) + EgtSetInfo( Lg, 'H2a' ,H2a) + EgtSetInfo( Lg, 'T2a' ,T2a) + EgtSetInfo( Lg, 'd2a' ,d2a) + EgtSetInfo( Lg, 'p2a' ,p2a) + EgtSetInfo( Lg, 's2a' ,s2a) + EgtSetInfo( Lg, 'jn2' ,jn2) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'dws' ,dws) + EgtSetInfo( Lg, 'dthd' ,dthd) + EgtSetInfo( Lg, 'ttp' ,ttp) + EgtSetInfo( Lg, 'DB_X' ,DB_X) + EgtSetInfo( Lg, 'DB_Y' ,DB_Y) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'LG' ,LG) + EgtSetInfo( Lg, 'LM' ,LM) + EgtSetInfo( Lg, 'LG2' ,LG2) + EgtSetInfo( Lg, 'LA' ,LA) + EgtSetInfo( Lg, 'LGM' ,LGM) + EgtSetInfo( Lg, 'LMM' ,LMM) + EgtSetInfo( Lg, 'CLH' ,CLH) + EgtSetInfo( Lg, 'LH' ,LH) + EgtSetInfo( Lg, 'CH' ,CH) + EgtSetInfo( Lg, 'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return ConcealedHinge diff --git a/LuaLibs/DOORMatch.lua b/LuaLibs/DOORMatch.lua new file mode 100644 index 0000000..bcd908f --- /dev/null +++ b/LuaLibs/DOORMatch.lua @@ -0,0 +1,214 @@ +-- +-- 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 +-- +-- DOORMatch.lua by EgalWare s.r.l. +-- definizione del Modulo +local DOORMatch = {} +DOORMatch.OutTemplate = "" +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- dichairazione delle variabili locali del modulo che devono essere caricate all'avvio +local TemplateDirectory -- direttorio + file template +local MatchTable -- tabella delle associazioni + +local CompoDirectory = "" +local CompoPath = "" +local OutTemplate = "" + +-- ricavo il direttorio sorgente +local function CurrCompoDirectory(Path) + local PatternSubString= "(.*)Compo.*" + CompoDirectory = string.match(Path, PatternSubString) .."Compo\\" + return CompoDirectory +end +-- + +--costruisce il percorso completo della componente RICEVE IL NOME DEL TEMPLATE E IL PERCORSO DEL DIRETTORIO DELLE COMPONENTI +local function CompletetPath() + --local sDir, sName, sExt = EgtSplitPath( CurrCompoPath .. "\\" .. CurrTemplate) + --local sCompletePath = sDir ..'\\' .. sName ..'.lua' + local sCompletePath = CompoDirectory .. "\\" .. TemplateDirectory + CurrCompoDirectory(sCompletePath) -->C:/EgtData/Doors/EgtCompoBase/Compo/ + return sCompletePath +end +-- + +--legge i direttori della tabella controlla cosa deve essere associato +local function CompareDirectory(TemplateTable) + if string.match(TemplateTable,"*")=="*" then + TemplateTable=string.gsub(TemplateTable,"*","(.*)") + end + TemplateTable = string.match(CompoPath, TemplateTable) + -- la stringa della tabella e quella passata non hanno nulla in comune allora ritorno falso + if TemplateTable == nil then + return false + else + return true + end +end +-- + + --restituisce il nome del file da associare +local function ComputeDirectory(Dir) + -- controllo se ha "*" + if string.match(Dir,"*")=="*" then + -- allora riscrivo la stringa i modo da poter copiare l'argomento al posto dell'asterisco + Dir=string.gsub(Dir,"*","(.*)") + end + -- se il nome passato coincide completamente con quello scritto in tabella allora non devo ricalcolare il percorso + if CompoDirectory==Dir then + return "" + else + -- recupero dal template il nome completo del file da associare alla cartella dei frame + Dir = string.match(CompoPath, Dir) --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS/216 - Hinges/SOSS/(.*) + return Dir --> 216 + end +end +-- + +-- legge nel file .lua la dischiarazione di associazione +local function ReadDefaultParam(File) + ReadingFile = File..".lua" + local f = io.open(ReadingFile,"r") + local t = f:read("*l") + i=0 + while t~=nil do + i =1+i + if string.match(t,"%s*--%s*%[Graphic parameters%]")==t then + t = f:read("*l") + t = string.match(t,"%s*--%s*Default%s*=%s*(.*)") + return t + end + t = f:read("*l") + end + f:close() + return "1" +end +-- + +-- ricerca all'interno del file lua chiamante se esiste un'associazione +local function FileNameInLua( sFile) + local f = io.open( sFile,"r") + if not f then return end + local t = f:read("*l") + local i = 0 + while t~=nil do + i = 1 + i + if string.match( t, "%s*--%s*%[Match%]")==t then + t = f:read( "*l") + t = string.match( t, "%s*--%s*FileName%s*=%s*(.*)") + f:close() + return t + end + t = f:read("*l") + end + f:close() +end +-- + +-- controlla che il file passato esista +local function FileExist( NameFile) + return EgtExistsFile( NameFile) +end +-- +-------------------------------------------------------------------------------------------------------------------------------------- +--legge la tabella e ricostruisce le associazioni restituendo il file associato +function DOORMatch.Matching(sSourceDirectory ,sTemplateDirectory ,tMatchTable) + print("\n DOORMatch") + print(" ", sTemplateDirectory) + -- caricamento delle variabili + CompoDirectory = sSourceDirectory --< C:/EgtData/Doors/EgtCompoBase/Compo/Hinges + TemplateDirectory = sTemplateDirectory --< SOSS/216 + MatchTable = tMatchTable + local OutDirectory = "" + local FIleNameTemlpate = "" + -- costruisco il percorso compoleto + CompoPath = CompletetPath() -->C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS/216 + -- ricerco all'inetrno del file se esiste un'associazione diretta + local AppOutTemplate = FileNameInLua( CompoPath) + if AppOutTemplate then + -- print("\n [Match] FileName = ", AppOutTemplate, "\n") + local sDir, sName, sExt = EgtSplitPath( AppOutTemplate) + return sDir ..sName + end + -- se la ricerca fallisce inizio la ricerca all'interno della tabella delle associazioni + for i=1, #MatchTable do + if CompareDirectory(MatchTable[i].InTemplate) then + -- print("\n",CompoPath, "--> row",i," ", MatchTable[i].InTemplate) + -- carico il valore associato nella tabella in uscita + AppOutTemplate = MatchTable[i].OutTemplate + -- controllo se ha estensione "*" + if string.match( AppOutTemplate,"*") == "*" then --> Hinges/SOSS.Frame/* + AppOutTemplate = string.gsub(AppOutTemplate,"*","") --> Hinges/SOSS.Frame/ + OutDirectory = CompoDirectory .. AppOutTemplate --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS.Frame/ + FIleNameTemlpate = ComputeDirectory(MatchTable[i].InTemplate) --> 216 + OutDirectory = OutDirectory .. FIleNameTemlpate --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS.Frame/216 + if FileExist( OutDirectory .. ".lua") then --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS.Frame/216.lua + DOORMatch.OutTemplate = OutDirectory + print("\n", AppOutTemplate .. FIleNameTemlpate) --> Hinges/SOSS.Frame/216 + return AppOutTemplate .. FIleNameTemlpate + else + -- print("\n" ,OutDirectory ," doesn't exist") + AppOutTemplate = nil + FIleNameTemlpate = "" + OutDirectory = "" + end + else --> Hinges/SOSS.Frame/212 + -- il template in uscita è direttamente un file + OutDirectory = CompoDirectory .. AppOutTemplate --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS.Frame/212 + if FileExist( OutDirectory .. ".lua") then --> C:/EgtData/Doors/EgtCompoBase/Compo/Hinges/SOSS.Frame/212.lua + DOORMatch.OutTemplate = OutDirectory + --STU.OutTemplate = AppOutTemplate + print(" ",AppOutTemplate) + return AppOutTemplate + else + print("\n", OutDirectory ," doesn't exist") + AppOutTemplate = nil + OutDirectory = "" + end + end + end + end + -- terminato il ciclo for + if AppOutTemplate == nil then + print("\n no match found") + end + end + +function DOORMatch.ReadDefaultParam() + sFile = DOORMatch.OutTemplate ..".lua" + local f = io.open( sFile, "r") + local t = f:read("*l") + local i = 0 + while t~=nil do + i =1+i + if string.match(t,"%s*--%s*%[Graphic parameters%]")==t then + t = f:read("*l") + t = string.match(t,"%s*--%s*Default%s*=%s*(.*)") + f:close() + print("Configuration Hardware: ",t) + return t + end + t = f:read("*l") + end + f:close() + return "1" +end +-- + +return DOORMatch \ No newline at end of file diff --git a/LuaLibs/EPT.lua b/LuaLibs/EPT.lua new file mode 100644 index 0000000..dddfb0a --- /dev/null +++ b/LuaLibs/EPT.lua @@ -0,0 +1,1589 @@ +-- +-- 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 +-- +-- EPT.lua by EgalWare s.r.l. 2017.03.13 +-- Autore: Filippo Monchi +-- EPT + +-- 2018.02.16 V1.018 FM Fix problem when both P3 and P4 have both extradeep value +-- 2018.04.05 V1.019 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.01a FM Add parameter to show into message 402 +-- 2018.10.22 V1.01b FM Manage better the big radius fillet parameter +-- 2018.11.06 V1.01c FM Manage parameter posp to make probe point external to face +-- 2018.11.08 V1.01d FM Manage better insert probe point in case face or mortise are disabled (It checks also bores) +-- 2018.12.20 V1.01e FM Manage interax parameters for horizontal bored +-- 2019.10.02 V1.01f FM Manage steel option (disable to generate pocket paths, mortise and bores) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.28 V2.001 FM Add clean corner geometries +-- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2020.04.29 V2.003 FM Update for aluminum material +-- 2020.05.04 V2.004 FM Manage extra bores +-- 2020.05.25 V2.005 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.06.18 V2.006 FM Manage better checking mortise dpeth with tool depth when parameter mfp is on or off +-- 2020.06.18 V2.006 FM fix wrong error message number (now 407 instead of 404) +-- 2020.07.01 V2.007 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.01.25 V3.001 FM Fix error when variable posp is not defined (disabled from hardware manager) +-- 2021.03.12 V3.002 FM Manage rotation parameters on extra bores/buttonhole +-- 2021.03.12 V3.002 FM Add missing functions DrawLocAddLineDrawCircle and DrawLocAddCircleDrawCircle +-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.004 FM Modification to use compiled code +-- 2024.07.19 V3.005 FM Set note 'NotCheckDir' to pocketing and buttonhole pocketing +-- 2024.10.29 V3.006 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local EPT = {} + +-- 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 function DrawLocAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, + nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine +end + +local function DrawLocAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + + if idTable then + table.insert( idTable, nCircle) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumCircle = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nCircle, nNumCircle, sMVar +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione creazione foro o asola o rampa per asola +local function MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, PX10, Int10, D10, + dParH, PY10, T10, RP10, AR10, + RCI10, kbs, bEqualTh, HB10, dws, + pbs) + + local pIni, pEnd, pCen + local hint3, hint5 + local tPath = {} + local tPathPok = {} + + if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti + + pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + hint3 = EgtCurveCompo( Lg, tPath, true) + EgtModifyCurveThickness( hint3, -T10) + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale + + EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione + local nStep = ceil(T10/RP10) -- numero di passate + local dStep = (T10/nStep) -- passo ricalcolato + local nPass = 1 + local dZedStart = 0 + local dZedWork + local nInv = 1 + + pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart) + + while nPass <= nStep do + + dZedWork = dZedStart - (dStep/2) + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + dZedWork = dZedStart - dStep + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + -- se ho altri passi scendo in z + if nPass < nStep then + dZedStart = dZedWork + end + nPass = nPass + 1 + end + -- faccio passata di ritorno + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),-T10) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + + hint5 = EgtCurveCompo( Lg, tPathPok, true) + EgtModifyCurveThickness( hint5, 0) + EgtSetName( hint5, EBH10) + EgtSetInfo( hint5, 'NotCheckDir', '1') + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + else + EgtSetName( hint3, EBH10) + end + elseif EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + -- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso) + if AR10 ~= 0 and RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + EgtSetInfo( hint3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +-- Funzione di sistemazione parametri +function EPT.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dMaxMat4 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + + -- do errore se profilo diverso da SQ o BU o BD + -- do errore se profilo tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.hingeedge.trimming == 'CV' or + DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or + DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or + DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or + DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B') then + return tMhPar, 1699, string.format(EgtDoorsMsg[589], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) + end + + -- parametro disposizione frame su lato wide (se = nil è sulla porta, se true dispsizione frame sul lato wide, se false dispsozione su lato narrow) + tMhPar.Dws = DGD.Dws + + 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 + + -- se profilo bevel disabilito la giunzione tra face e mortise a meno del parametro di adattamento mortise + 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 + -- se parametro non presente o false disattivo la giunzione + if not tMhPar.mfp then + tMhPar.jnb = false -- giunzione non possibile + else + tMhPar.jnb = true -- giunzione possibile + end + else + tMhPar.jnb = true -- giunzione possibile + end + + local bLockOnRight = DGD.Lock == 'R' + + if ( DGD.Lock == 'R' or not DGD.Push) and + ( DGD.Lock == 'R' ~= not DGD.Push) then + if tMhPar.D_X then + tMhPar.D_X = -tMhPar.D_X + end + if tMhPar.DB_X then + tMhPar.DB_X = -tMhPar.DB_X + end + end + + if tMhPar.D_Y then + tMhPar.D_Y = -tMhPar.D_Y + end + if tMhPar.DB_Y then + tMhPar.DB_Y = -tMhPar.DB_Y + end + + -- se non ho il parametro D_XE lo setto a 0 + if not tMhPar.D_XE then + tMhPar.D_XE = 0 + end + + -- se non esistono setto gli interassi a 0 + if not tMhPar.IB3_X then + tMhPar.IB3_X = 0 + end + if not tMhPar.IB4_X then + tMhPar.IB4_X = 0 + end + + -- setto il parametro a 0 in modo da non spostare la geometria come per le concealed hinges + tMhPar.D = 0 + + -- calcolo la posizione del centro foro sullo spessore porta + tMhPar.posh = DGD.FACETOCL - (DGD.dT/2) + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se ho arrotondamento disabilito il chisel e il cleancorner + if tMhPar.CL then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLH = nil + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.CL and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + tMhPar.sopp = ( DGD.Lock == 'L' and DGD.Push) or ( DGD.Lock == 'R' and not DGD.Push) + if DGD.sFrame then -- se è un assemblato + -- leggo la nota con il tipo di pezzo + local nTypePiece = EgtGetInfo( DGD.PZ, 'Piece Type', 'i') + if nTypePiece == 4 or nTypePiece == 3 then + tMhPar.sopp = not tMhPar.sopp + end + end + + -- se porta steel o aluminum disabilito la svuotatura, la mortasa e i fori 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 + tMhPar.H3 = nil + tMhPar.H4 = nil + else + tMhPar.est = nil + 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, + -- se è attivo l'arrotondamento, anche il clean corner + if tMhPar.rf > 0 then + tMhPar.ech = false + if tMhPar.CL then + tMhPar.clc = nil + tMhPar.CLH = nil + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLG + local nLGi = 1 + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLG3 + local nLG3i = 1 + local sLG4 + local nLG4i = 1 + + -- se profilo cerniere bevel up + if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + nLGi = 2 + nLMi = 2 + if tMhPar.mfp then + nLAi = 2 + nLG3i = 2 + nLG4i = 2 + end + elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down + nLGi = 3 + nLMi = 3 + if tMhPar.mfp then + nLAi = 3 + nLG3i = 3 + nLG4i = 3 + end + 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 + + if tMhPar.LG3 then + sLG3 = tMhPar.LG3 + if DGD.MachEn > 0 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLG3, nLG3i) end + end + + if tMhPar.LG4 then + sLG4 = tMhPar.LG4 + if DGD.MachEn > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLG4, nLG4i) 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 <= 0 then + dNumLog = -1695 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName2) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -1695 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + end + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + 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 = -1694 + 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 = -1698 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jnb and tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1697 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if ( not tMhPar.jn or not tMhPar.jnb) and tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1696 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + + -- se primo foro abilitato e profondità foro è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.T3 and dMaxMat3 and tMhPar.T3 > dMaxMat3 then + dNumLog = -1693 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat3)) + tMhPar.T3 = dMaxMat3 + end + + -- se secondo foro abilitato e profondità foro è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.T4 and dMaxMat4 and tMhPar.T4 > dMaxMat4 then + dNumLog = -1692 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T4), EgtToUiUnits(dMaxMat4)) + tMhPar.T4 = dMaxMat4 + end + + -- se ho altro materiale annullo i raccordi se sono più piccoli del raggio utensile + if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.CL and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + 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 + + -- 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 = -1691 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -1691 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T3 and abs(tMhPar.T3) > tMhPar.TTP then + dNumLog = -1691 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T3', EgtToUiUnits(tMhPar.T3), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T3 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T4 and abs(tMhPar.T4) > tMhPar.TTP then + dNumLog = -1691 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T4', EgtToUiUnits(tMhPar.T4), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T4 = tMhPar.TTP + 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 EPT.Draw( tEpcParameter, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- setto un parametro atteso nel componente _latch + tEpcParameter.invG = 1 + + -- Assegno le dimensioni + local L = tEpcParameter.L + local H = tEpcParameter.H + local T = tEpcParameter.T + local D = tEpcParameter.D + local L2 = tEpcParameter.L2 + local H2 = tEpcParameter.H2 + local T2 = tEpcParameter.T2 + local sf = tEpcParameter.sf + local rf = tEpcParameter.rf + local clc = tEpcParameter.clc + local ccr = tEpcParameter.ccr + local s = tEpcParameter.s + local d = tEpcParameter.d + local p = tEpcParameter.p + local jn = tEpcParameter.jn -- flag per giunzione prima cava face con seconda cava (mortasa) + local jnb = tEpcParameter.jnb -- flag che indica se profilo tipo bevel o no + local mfp = tEpcParameter.mfp -- flag che indica se la mortasa deve seguire il profilo + local d2 = tEpcParameter.d2 + local p2 = tEpcParameter.p2 + local CL = tEpcParameter.CL + local D_X = tEpcParameter.D_X -- delta on X pos on mortise + local D_Y = tEpcParameter.D_Y -- delta on X pos on mortise + local H3 = tEpcParameter.H3 + local T3 = tEpcParameter.T3 + local IB3_X = tEpcParameter.IB3_X + local H4 = tEpcParameter.H4 + local T4 = tEpcParameter.T4 + local IB4_X = tEpcParameter.IB4_X + local posh = tEpcParameter.posh -- posizione in Y del foro di tastatura + local posp = tEpcParameter.posp -- posizione in X del foro di tastatura + local DB_X = tEpcParameter.DB_X -- delta on X pos on bores + local DB_Y = tEpcParameter.DB_Y -- delta on Y pos on bores + local D_XE = tEpcParameter.D_XE -- Extra delta on X pos for all geometries + local invG = tEpcParameter.invG + local ech = tEpcParameter.ech + local est = tEpcParameter.est + local kbs = tEpcParameter.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tEpcParameter.pbs + local sopp = tEpcParameter.sopp + local dws = tEpcParameter.Dws + local dthd = tEpcParameter.dThD + local ttp = tEpcParameter.TTP + local tExtraBore = {} + table.insert( tExtraBore, { tEpcParameter.D5, tEpcParameter.T5, tEpcParameter.I5, tEpcParameter.PX5, tEpcParameter.PY5, tEpcParameter.EB5, tEpcParameter.HB5}) + table.insert( tExtraBore, { tEpcParameter.D6, tEpcParameter.IY6, tEpcParameter.T6, tEpcParameter.I6, tEpcParameter.PX6, tEpcParameter.PY6, tEpcParameter.RP6, tEpcParameter.EB6, tEpcParameter.EBH6, tEpcParameter.HB6, tEpcParameter.AR6, tEpcParameter.RCI6}) + table.insert( tExtraBore, { tEpcParameter.D7, tEpcParameter.IY7, tEpcParameter.T7, tEpcParameter.I7, tEpcParameter.PX7, tEpcParameter.PY7, tEpcParameter.RP7, tEpcParameter.EB7, tEpcParameter.EBH7, tEpcParameter.HB7, tEpcParameter.AR7, tEpcParameter.RCI7}) + table.insert( tExtraBore, { tEpcParameter.D8, tEpcParameter.IY8, tEpcParameter.T8, tEpcParameter.I8, tEpcParameter.PX8, tEpcParameter.PY8, tEpcParameter.RP8, tEpcParameter.EB8, tEpcParameter.EBH8, tEpcParameter.HB8, tEpcParameter.AR8, tEpcParameter.RCI8}) + + -- Assegno i nomi dei layer + local LG = tEpcParameter.LG + local LM = tEpcParameter.LM + local LG2 = tEpcParameter.LG2 + local LA = tEpcParameter.LA + local CLH = tEpcParameter.CLH + local LG3 = tEpcParameter.LG3 + local LG4 = tEpcParameter.LG4 + local CH = tEpcParameter.CH + local LH = 'Hinge_Probe' + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tEpcParameter.Nome + local nCompoNpar = tEpcParameter.Npar + local sCompoPath = tEpcParameter.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tEpcParameter.nCod + local sCodAdj = tEpcParameter.sCod + -- nomi parametri per messaggi + local sNamePar1 = tEpcParameter.N1 or 'L' + local sNamePar2 = tEpcParameter.N2 or 'H' + local sNamePar3 = tEpcParameter.N3 or 'T' + local sNamePar4 = tEpcParameter.N4 or 'D' + local sNamePar5 = tEpcParameter.N5 or 'L2' + local sNamePar6 = tEpcParameter.N6 or 'T2' + local sNamePar7 = tEpcParameter.N7 or 's' + local sNamePar8 = tEpcParameter.N8 or 'd' + local sNamePar9 = tEpcParameter.N9 or 'p' + local sNamePar11 = tEpcParameter.N11 or 'd2' + local sNamePar12 = tEpcParameter.N12 or 'sf' + local sNamePar13 = tEpcParameter.N13 or 'D_X' + local sNamePar14 = tEpcParameter.N14 or 'D_Y' + local sNamePar15 = tEpcParameter.N15 or 'H2' + local sNamePar16 = tEpcParameter.N16 or 'H3' + local sNamePar17 = tEpcParameter.N17 or 'T3' + local sNamePar18 = tEpcParameter.N18 or 'DB_X' + local sNamePar19 = tEpcParameter.N19 or 'DB_Y' + local sNamePar20 = tEpcParameter.N20 or 'H4' + local sNamePar21 = tEpcParameter.N21 or 'rf' + local sNamePar22 = tEpcParameter.N22 or 'p2' + local sNamePar23 = tEpcParameter.N23 or 'T4' + local sNamePar24 = tEpcParameter.N24 or 'clc' + local sNamePar25 = tEpcParameter.N25 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1650 + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + tEpcParameter.jn = false + clc = nil + CLH = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom then + if L >= H then + if rf > (H/2) then + rf = (H/2) + tEpcParameter.rf = rf + end + else + if rf > (L/2) then + rf = (L/2) + tEpcParameter.rf = rf + end + end + end + + if not bRunByCompo then RC = false end + if not T then T = 0 end + if not T2 then T2 = 0 end + if not T3 then T3 = 0 end + if not T4 then T4 = 0 end + -- se junzione impossibilitata disattivo il join tra face e mortasa + if not jnb then + jn = false + tEpcParameter.jn = false + end + + 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 + tEpcParameter.LG = LG + if nDrawMach == 1 then -- se ho abilitato solo le geometrie di lavorazione + nForceMakeFace = 2 + end + end + + -------------------------------------------------------- + -- set parametri attesi nel componente _latch o _mortise + -- o che potrebbero non esserci nei vecchi lua + -------------------------------------------------------- + + -- posizione in X mortasa dal centro face + if not D_X then + D_X = 0 + tEpcParameter.D_X = 0 + end + + -- posizione in Y mortasa dal centro face + if not D_Y then + D_Y = 0 + tEpcParameter.D_Y = 0 + end + + -- qui utilizzo un bool ma nel componente _latch uso un numero per definire l'arrotondamento + if bMakeFaceGeom and CL then + cl = 3 -- setto entrambe gli estremi raccordati + tEpcParameter.cl = 3 + else + cl = 0 -- setto nessun estremo raccordato + tEpcParameter.cl = 0 + end + + -- altezza mortise, setto come altezza face per compatibilità con i vecchi lua + if not H2 then + H2 = H + tEpcParameter.H2 = H + end + + if est or ( not L2 or not H2) then + bMakeMortGeom = false + -- disattivo il join + jn = false + tEpcParameter.jn = false + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + elseif not p2 and bMakeMortGeom then + p2 = p + end + + -- posizione in X seconda mortise dal centro mortise + if ( H3 or H4) and not DB_X then + DB_X = 0 + if bMakeMortGeom then + DB_X = D_X + end + tEpcParameter.DB_X = DB_X + end + + -- posizione in Y seconda mortise dal centro mortise + if ( H3 or H4) and not DB_Y then + DB_Y = 0 + if bMakeMortGeom then + DB_Y = D_Y + end + tEpcParameter.DB_Y = DB_Y + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EM = string.format(EgtDoorsMsg[400],sNamePar8,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile 'd' deve essere >= di + EC = 1 + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and d2 < DgMin then + EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile 'd2' deve essere >= di + EC = 2 + d2 = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + EC = 3 + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and H2 < d2 then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[405],sNamePar15,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + EC = 4 + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile + EC = 5 + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and L2 <= d2 then + if DGD.bProoduce then + EM = string.format(EgtDoorsMsg[402],sNamePar5,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + EC = 6 + L2 = d2 + 0.002 + else + d2 = L2 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EM = string.format(EgtDoorsMsg[403],sNamePar9,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + EC = 7 + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and p2 and ( p2 < PtMin or p2 > PtMax) then + EM = string.format(EgtDoorsMsg[403],sNamePar22,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + EC = 8 + p2 = 0.8 + elseif bMakeFaceGeom and T < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + EC = 9 + T = 0 + elseif bMakeMortGeom and T2 <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + EC = 10 + T2 = 0.1 + elseif H3 and T3 < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere >= 0 + EC = 11 + T3 = 0 + elseif H4 and T4 < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar23,EgtToUiUnits(T4), sCompoPath) -- il parametro 'T4' deve essere >= 0 + EC = 12 + T4 = 0 + elseif D < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar4,EgtToUiUnits(D), sCompoPath) -- il parametro 'D' deve essere >= 0 + EC = 13 + D = 0 + elseif bMakeFaceGeom and bMakeMortGeom and L2 >= L then + EM = string.format(EgtDoorsMsg[406],sNamePar5,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + EC = 14 + L2 = L - 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 < T then + EM = string.format(EgtDoorsMsg[407],sNamePar6,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + EC = 15 + T2 = T + 0.1 + elseif bMakeMortGeom and H3 and not dws and T3 < T2 then + EM = string.format(EgtDoorsMsg[407],sNamePar17,EgtToUiUnits(T3),sNamePar6,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T3' deve essere > 'T2' + EC = 16 + T3 = T2 + 0.1 + elseif H3 and H4 and not dws and T4 < T3 then + EM = string.format(EgtDoorsMsg[407],sNamePar23,EgtToUiUnits(T4),sNamePar17,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T4' deve essere > 'T3' + EC = 17 + T4 = T3 + 0.1 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar12,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + EC = 18 + sf = d + elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + EC = 19 + s = d2 + elseif bMakeFaceGeom and CL and rf < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar21,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + EC = 20 + rf = H/2 + elseif bMakeFaceGeom and CL and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + EC = 21 + L = H+5 + elseif bMakeFaceGeom and CL and rf < (H/2) and L <= (rf*2) then + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar21..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2' + EC = 22 + L = (rf*2)+5 + elseif bMakeFaceGeom and bMakeMortGeom and L < (L2+(2*abs(D_X))) then + EM = string.format(EgtDoorsMsg[423],sNamePar13,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + EC = 23 + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar15,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2' + EC = 24 + H2 = H + elseif bMakeMortGeom and H3 and H3 > H2 then + EM = string.format(EgtDoorsMsg[422],sNamePar15,EgtToUiUnits(H2),sNamePar16,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H2' deve essere >= del parametro 'H3' + EC = 25 + H3 = H2 + elseif H3 and H4 and H4 > H3 then + EM = string.format(EgtDoorsMsg[422],sNamePar16,EgtToUiUnits(H3),sNamePar20,EgtToUiUnits(H4), sCompoPath) -- il parametro 'H3' deve essere >= del parametro 'H4' + EC = 26 + H4 = H3 + elseif bMakeMortGeom and nDrawMach > 0 and jn and H < (H2+abs(2*D_Y)) then + EM = string.format(EgtDoorsMsg[423],sNamePar14,EgtToUiUnits(abs(D_Y)),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D_Y' é troppo grande, max valore: + EC = 27 + D_Y = 0 + elseif bMakeFaceGeom and H3 and H3 > H then + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar16,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H3' + EC = 28 + H3 = H + elseif bMakeFaceGeom and CLH and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 29 + EM = string.format(EgtDoorsMsg[407],sNamePar24,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 + + -- variabili dei percorsi geometrici + local nGeom1, nGeom2, nGeom3, nGeom4, nGeom31, nGeom41, nAS1, nAS2 + local nPkToJoin1, nPkToJoin2, nPkToJoin + local nPkJoin1 + + local Lg, Dm + local sRequireCompoName + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + tEpcParameter.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + sRequireCompoName = '_Latch' + + if bMakeFaceGeom then + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1, nAS1, nAS2 = MHgen.Draw( EC, EM, tEpcParameter, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom1 then EgtSetInfo(nGeom1,'SideDoor','SideLH') end + if nPkToJoin1 then EgtSetInfo(nPkToJoin1,'SideDoor','SideLH') end + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + + 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 + EgtSetInfo( CLC1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + if mfp then + EgtSetInfo( CLC1,'SideDoor','SideLH') + else + EgtSetInfo( CLC1,'SideDoor','LockLH') + end + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + else + -- disattivo il join dei percorsi + jn = false + end + + if bMakeMortGeom then + -- cava mortasa + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.LGM = LG2 + dMortise.LMM = LA + dMortise.Nome = sCompoName + dMortise.jne = false + dMortise.D_X = D_X + dMortise.mfp = mfp + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom2 then + if mfp then + EgtSetInfo(nGeom2,'SideDoor','SideLH') + else + EgtSetInfo(nGeom2,'SideDoor','LockLH') + end + end + if nPkToJoin2 then + if mfp then + EgtSetInfo(nPkToJoin2,'SideDoor','SideLH') + else + EgtSetInfo(nPkToJoin2,'SideDoor','LockLH') + end + end + end + + if EC == 0 and ( nGeom2 or nPkToJoin2) then + if D_X ~= 0 or D_Y ~= 0 then + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,D_Y,0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,D_Y,0) - ORIG()) + end + end + end + + if H3 then + if abs(IB3_X) <= H3 then -- se interasse minore del diametro lo setto a 0 + IB3_X = 0 + end + nGeom3 = EgtCircle( Lg, Point3d(-(IB3_X/2),0,0), H3/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom3, -T3) + EgtSetName( nGeom3, LG3) + -- se interasse maggiore del diametro creo secondo foro + if abs(IB3_X) > H3 then + nGeom31 = EgtCircle( Lg, Point3d((IB3_X/2),0,0), H3/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom31, -T3) + EgtSetName( nGeom31, LG3) + end + end + + -- se foro fatto correttamente lo posiziono + if EC == 0 and ( nGeom3 or nGeom31) then + if nGeom3 then + if mfp then + EgtSetInfo(nGeom3,'SideDoor','SideLH') + else + EgtSetInfo(nGeom3,'SideDoor','LockLH') + end + + if DB_X ~= 0 or DB_Y ~= 0 then + EgtMove( nGeom3, Point3d(DB_X,DB_Y,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nGeom3, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + if nGeom31 then + if mfp then + EgtSetInfo(nGeom31,'SideDoor','SideLH') + else + EgtSetInfo(nGeom31,'SideDoor','LockLH') + end + + if DB_X ~= 0 or DB_Y ~= 0 then + EgtMove( nGeom31, Point3d(DB_X,DB_Y,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nGeom31, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom31, 'ProbeSide', '1') + end + end + end + + if H4 then + if abs(IB4_X) <= H4 then -- se interasse minore del diametro lo setto a 0 + IB4_X = 0 + end + nGeom4 = EgtCircle( Lg, Point3d(-(IB4_X/2),0,0), H4/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom4, -T4) + EgtSetName( nGeom4, LG4) + -- se interasse maggiore del diametro creao secondo foro + if abs(IB4_X) > H4 then + nGeom41 = EgtCircle( Lg, Point3d((IB4_X/2),0,0), H4/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom41, -T4) + EgtSetName( nGeom41, LG4) + end + end + + -- se foro fatto correttamente lo posiziono + if EC == 0 and ( nGeom4 or nGeom41) then + if nGeom4 then + if mfp then + EgtSetInfo(nGeom4,'SideDoor','SideLH') + else + EgtSetInfo(nGeom4,'SideDoor','LockLH') + end + + if DB_X ~= 0 or DB_Y ~= 0 then + EgtMove( nGeom4, Point3d(DB_X,DB_Y,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nGeom4, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom4, 'ProbeSide', '1') + end + end + if nGeom41 then + if mfp then + EgtSetInfo(nGeom41,'SideDoor','SideLH') + else + EgtSetInfo(nGeom41,'SideDoor','LockLH') + end + + if DB_X ~= 0 or DB_Y ~= 0 then + EgtMove( nGeom41, Point3d(DB_X,DB_Y,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 0 then + EgtSetInfo( nGeom41, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom41, 'ProbeSide', '1') + end + end + end + + -- se percorsi fatti con lo stesso utensile, li concateno + if jn and EC == 0 and nDrawMach > 0 and nPkToJoin1 and nPkToJoin2 then + nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + if nPkToJoin then + EgtSetName( nPkToJoin, LM) + EgtSetInfo( nPkToJoin, 'SideDoor', 'SideLH') + EgtSetInfo( nPkToJoin, 'NotCheckDir', '1') + -- se mantiene backset anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 34 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and nDrawMach > 0 then -- altrimenti se non devo concatenare + -- se mantiene backset su face + if kbs and kbs > 0 and nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + -- se mantiene backset su face e mortise + elseif kbs and kbs > 0 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom1, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + EgtSetInfo( nGeom2, 'KeepBackSet', 'w') -- setto 'w' perché il backset viene mantenuto sul lato wide + end + end + if pbs and pbs > 0 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + end + + -- aggiungo fori extra + if EC == 0 and nDrawMach >= 0 then + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + local AR10 + local RCI10 + + if k == 1 then + D10 = tExtraBore[k][1] + T10 = tExtraBore[k][2] + I10 = tExtraBore[k][3] + PX10 = tExtraBore[k][4] + PY10 = tExtraBore[k][5] + EB10 = tExtraBore[k][6] + HB10 = tExtraBore[k][7] + else + D10 = tExtraBore[k][1] + IY10 = tExtraBore[k][2] + T10 = tExtraBore[k][3] + I10 = tExtraBore[k][4] + PX10 = tExtraBore[k][5] + PY10 = tExtraBore[k][6] + RP10 = tExtraBore[k][7] + EB10 = tExtraBore[k][8] + EBH10 = tExtraBore[k][9] + HB10 = tExtraBore[k][10] + AR10 = tExtraBore[k][11] + RCI10 = tExtraBore[k][12] + end + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + if D10 and T10 and ( EB10 or EBH10) then + if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then + + if not IY10 then IY10 = 0 end + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + if not AR10 then AR10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 = PX10 * EgtIf( sopp, 1, -1) + + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs) + + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs) + end + end + end + end + end + + if EC == 0 and nDrawMach > 0 then + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if nGeom1 then + nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom2 then + nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom3 then + nIdSideBoxUp = EgtCopyGlob( nGeom3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom31 then + nIdSideBoxUp = EgtCopyGlob( nGeom31, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom4 then + nIdSideBoxUp = EgtCopyGlob( nGeom4, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom41 then + nIdSideBoxUp = EgtCopyGlob( nGeom41, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + -- aggiungo foro probe + if EC == 0 and nDrawMach > 0 and posh then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + local dHalfGeom = 0 + + if bMakeFaceGeom and L then + dHalfGeom = L/2 + elseif bMakeMortGeom and L2 then + dHalfGeom = L2/2 + elseif nGeom3 and H3 then + dHalfGeom = (H3+IB3_X)/2 + if nGeom4 and H4 and (H4+IB4_X) > (H3+IB3_X) then + dHalfGeom = (H4+IB4_X)/2 + end + elseif nGeom4 and H4 then + dHalfGeom = (H4+IB4_X)/2 + end + + if posp and posp > 0 then + dPosProbe = dHalfGeom + posp + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + + local pCentr = Point3d( dPosProbe,posh,0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo = 'SideLH' + if DGC.Fpd then + sSideDoorInfo = 'LockLH' + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr,LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + if dPosProbe ~= 0 then + pCentr = Point3d(-(dHalfGeom+(posp or 0)),posh,0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + + if EC == 0 and D_XE and D_XE ~= 0 then + -- muovo tutte le geometrie del layer + local nIdGeom = EgtGetFirstInGroup( Lg) + while nIdGeom do + EgtMove( nIdGeom, Point3d( (D_XE * EgtIf( sopp, 1, -1)),0,0) - ORIG()) + nIdGeom = EgtGetNext(nIdGeom) + end + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart( Pz, sCompoName, nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'SPT') + EgtSetInfo(Lg,'Nome' ,sCompoName) + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'D' ,D) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'clc' ,clc) + EgtSetInfo(Lg,'ccr' ,ccr) + EgtSetInfo(Lg,'sf' ,sf) + EgtSetInfo(Lg,'L2' ,L2) + EgtSetInfo(Lg,'H2' ,H2) + EgtSetInfo(Lg,'T2' ,T2) + EgtSetInfo(Lg,'s' ,s) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'jn' ,jn) + EgtSetInfo(Lg,'jnb' ,jnb) + EgtSetInfo(Lg,'mfp' ,mfp) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'p2' ,p2) + EgtSetInfo(Lg,'D_X' ,D_X) + EgtSetInfo(Lg,'D_Y' ,D_Y) + EgtSetInfo(Lg,'H3' ,H3) + EgtSetInfo(Lg,'T3' ,T3) + EgtSetInfo(Lg,'posh' ,posh) + EgtSetInfo(Lg,'posp' ,posp) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'sopp' ,sopp) + EgtSetInfo(Lg,'dws' ,dws) + EgtSetInfo(Lg,'dthd' ,dthd) + EgtSetInfo(Lg,'ttp' ,ttp) + EgtSetInfo(Lg,'DB_X' ,DB_X) + EgtSetInfo(Lg,'DB_Y' ,DB_Y) + EgtSetInfo(Lg,'IB3_X' ,IB3_X) + EgtSetInfo(Lg,'IB4_X' ,IB4_X) + EgtSetInfo(Lg,'invG' ,invG) + EgtSetInfo(Lg,'D_XE' ,D_XE) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LG2' ,LG2) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LG3' ,LG3) + EgtSetInfo(Lg,'LG4' ,LG4) + EgtSetInfo(Lg,'CLH' ,CLH) + EgtSetInfo(Lg,'LH' ,LH) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return EPT diff --git a/LuaLibs/EdgePullFlat.lua b/LuaLibs/EdgePullFlat.lua new file mode 100644 index 0000000..43b54a8 --- /dev/null +++ b/LuaLibs/EdgePullFlat.lua @@ -0,0 +1,1704 @@ +-- +-- 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 +-- +-- EdgePullFlat.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Lock edge pull dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'd2' e con nomi attributi + +-- 2016.09.21 V1.011 FM Add warning messages +-- 2016.09.21 V1.011 FM Disabled to use reverse geometries _R on tool diameter caculation +-- 2017.08.30 V1.012 FM Manage Offset_WS if present +-- 2017.09.05 V1.013 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.04.05 V1.014 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.07.20 V1.015 FM Assign note 'LikeStrike' to all geometries if runned as Strike +-- 2018.10.17 V1.016 FM Add parameter to show into message 402 +-- 2018.10.22 V1.017 FM Add new parameter D_XE to move all geometries +-- 2018.12.06 V1.018 FM Manage geometry for calculate box without EdgePullFlat volume +-- 2019.10.10 V1.019 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.25 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.29 V2.004 FM Update for aluminum material +-- 2020.05.26 V2.005 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.05.25 V2.006 FM Manage geometries for calculate region when frame(jamb) is disposed on narrow side +-- 2020.07.01 V2.007 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2022.07.27 V3.001 FM Modification to use compiled code +-- 2022.08.25 V3.002 FM Fix error on use wrong geometry name name hintAS1 instead of hintAs1 +-- 2024.07.19 V3.003 FM Set note 'NotCheckDir' to pocketing, antisplint paths +-- 2024.10.04 V3.004 FM Manage probe geometry and their offset position when template is disposed +-- 2024.10.29 V3.005 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local LockEdgePull = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DgMin = 4. -- valore minimo diametro utensile +local PtMin = 0.1 +local PtMax = 1.0 +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + + if idTable then + table.insert( idTable, nLine) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumLine = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function 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 di sistemazione parametri +function LockEdgePull.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat1x + local dMaxMat2x + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT1x + local nTempT2x + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName1x + local sMchngName2x + + -- 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 lock tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or + DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') then + return tMhPar, 1999, string.format(EgtDoorsMsg[431], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLG + local nLGi = 1 + local dOffset = 0 + + -- 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 + end + + -- calcolo altezza effettiva in relazione allo spessore porta + -- e calcolo punto di partena in Y + tMhPar.OriH = tMhPar.H + tMhPar.bETh = true + tMhPar.fht = 0 -- setto il face h top a 0 + tMhPar.fhb = 0 -- setto il face h bottom a 0 + + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + tMhPar.H = tMhPar.H / cos(3) + if DGD.OFFSET and DGD.OFFSET > 0 then + dOffset = ( DGD.OFFSET / cos(3)) + end + -- setto il flag che indica profilo bevel + tMhPar.bev = true + else + if DGD.OFFSET and DGD.OFFSET > 0 then + dOffset = DGD.OFFSET + end + end + + -- setto parametro riferimento profondità roller + tMhPar.drf = DGD.dT/6 + + if DGD.sFrame then -- se è un assemblato + tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato + end + + -- se altezza supera lo spessore porta la riporto allo stesso valore + if (tMhPar.OriH-DGD.dT) > 0.001 then -- se altezza oltre lo spessore porta + if tMhPar.H > tMhPar.OriH then -- se sono su bevel + tMhPar.H = DGD.dT / cos(3) + else + tMhPar.H = DGD.dT + end + tMhPar.OriH = DGD.dT + if DGD.OFFSET and DGD.OFFSET > 0 then + tMhPar.StY = dOffset + else + tMhPar.StY = tMhPar.H/2 + end + tMhPar.ech = false -- disattivo il chiseling + tMhPar.rf = 0 -- disattivo il radius face + tMhPar.clc = nil + tMhPar.CLC = nil + elseif abs(tMhPar.OriH-DGD.dT) < 0.001 then -- uguale allo spessore porta + if DGD.OFFSET and DGD.OFFSET > 0 then + tMhPar.StY = dOffset + else + tMhPar.StY = tMhPar.H/2 + end + tMhPar.ech = false -- disattivo il chiseling + tMhPar.rf = 0 -- disattivo il radius face + tMhPar.clc = nil -- disattivo il clean corner + tMhPar.CLC = nil + else -- minore dello spessore porta + if tMhPar.H > tMhPar.OriH then -- se sono su bevel + if DGD.OFFSET and DGD.OFFSET > 0 then + tMhPar.StY = dOffset + else + tMhPar.StY = ( ( DGD.dT / cos(3)) * 0.5) + end + else + if DGD.OFFSET and DGD.OFFSET > 0 then + tMhPar.StY = dOffset + else + tMhPar.StY = ( DGD.dT * 0.5) + end + end + tMhPar.bETh = false + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template non è sui lati top e bottom + if DGD.SDF and DGD.SDF > 1 then + + -- calcolo la posizione del centro foro sullo spessore porta + if dOffset > 0 then + tMhPar.posh = -(DGD.dT/2) + DGD.OFFSET + else + tMhPar.posh = 0 + end + + if tMhPar.bev and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + + -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- profilo serratura bevel up + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLGi = 3 + nLMi = 3 + nLAi = 3 + else + nLGi = 2 + nLMi = 2 + nLAi = 2 + end + elseif DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB' then -- profilo serratura bevel dw + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLGi = 2 + nLMi = 2 + nLAi = 2 + else + nLGi = 3 + nLMi = 3 + nLAi = 3 + end + end + + if tMhPar.est and tMhPar.LG then -- se altro materiale + 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 + if DGD.MachEn > 0 and tMhPar.d then nTempT1x, dMaxMat1x, sMchngName1x = MB.GetToolDataFromAttrib( sLM ..'_R', 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 + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2x, dMaxMat2x, sMchngName2x = MB.GetToolDataFromAttrib( sLA ..'_R', nLAi) end + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) 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 <= 0 then + dNumLog = -1996 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 and nTempT1x and nTempT1x <= 0 then + dNumLog = -1990 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est then + if nTempT1 and nTempT1 > 0 then + tMhPar.d = nTempT1 + elseif nTempT1x and nTempT1x > 0 then + tMhPar.d = nTempT1x + end + end + + -- antischeggia + if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 and nTempT2x and nTempT2x <= 0 then + dNumLog = -1990 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif not tMhPar.est then + if nTempT2 and nTempT2 > 0 then + tMhPar.d2 = nTempT2 + elseif nTempT2x and nTempT2x > 0 then + tMhPar.d2 = nTempT2x + end + end + end + + -- Regola applicazione chiseling: + -- se ho impostato un raccordo, anche se poi viene annullato perché inferiore del raggio fresa + -- disabilito il chiseling perché implica che 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.CLC = 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 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 + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + 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 = -1995 + 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) and ( dMaxMat1x and tMhPar.T > dMaxMat1x)) then + dNumLog = -1998 + dNumMessage = 460 + if dMaxMat1 and tMhPar.T > dMaxMat1 then + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 + elseif dMaxMat1x and tMhPar.T > dMaxMat1x then + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1x)) + tMhPar.T = dMaxMat1x + end + 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) and (dMaxMat2x and tMhPar.T > dMaxMat2x)) then + dNumLog = -1997 + dNumMessage = 462 + if dMaxMat2 and tMhPar.T > dMaxMat2 then + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 + elseif dMaxMat2x and tMhPar.T > dMaxMat2x then + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2x)) + tMhPar.T = dMaxMat2x + end + 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 = -1994 + 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 DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' 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.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function LockEdgePull.Draw( tLckP, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni + local L = tLckP.L + local H = tLckP.H + local T = tLckP.T + local R = tLckP.rf + local clc = tLckP.clc + local ccr = tLckP.ccr + local d = tLckP.d + local p = tLckP.p + local s = tLckP.sf + local d2 = tLckP.d2 + local ech = tLckP.ech + local est = tLckP.est -- altro materiale trovato + local bEqualTh = tLckP.bETh + local nStartY = tLckP.StY + local kbs = tLckP.kbs -- keep backset (0: none, 1: only face, 2: all) + local pbs = tLckP.pbs + local stk = tLckP.stk + local fht = tLckP.fht + local fhb = tLckP.fhb + local drf = tLckP.drf + local dws = tLckP.Dws + local dthd = tLckP.dThD + local posh = tLckP.posh -- posizione in Y del foro di tastatura + local posp = tLckP.posp -- posizione in X del foro di tastatura + -- Disassamento globale + local D_XE = tLckP.D_XE -- Extra delta on X pos for all geometries + -- Assegno i nomi + local LG = tLckP.LG + local LM = tLckP.LM + local LA = tLckP.LA + local CH = tLckP.CH + local CLC = tLckP.CLC + local DM = 'DUMMY' + local LH = 'Shuttle_Probe' + -- variabili per messaggi e settaggi vari + local sCompoName = tLckP.Nome + local nCompoNpar = tLckP.Npar + local sCompoPath = tLckP.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLckP.nCod + local sCodAdj = tLckP.sCod + -- nomi parametri per messaggi + local sNamePar1 = tLckP.N1 or 'L' + local sNamePar2 = tLckP.N2 or 'H' + local sNamePar3 = tLckP.N3 or 'T' + local sNamePar4 = tLckP.N4 or 'd' + local sNamePar5 = tLckP.N5 or 'p' + local sNamePar6 = tLckP.N6 or 'd2' + local sNamePar7 = tLckP.N7 or 's' + local sNamePar8 = tLckP.N8 or 'R' + local sNamePar9 = tLckP.N9 or 'clc' + local sNamePar10 = tLckP.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 = 1900 + + if bRunByCompo == nil or 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 + + if not D_XE then + D_XE = 0 + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if nDrawMach == nil 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 + if nDrawMach == 1 then -- se ho abilitato solo le geometrie di lavorazione + 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 < 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 + if DGD.bProoduce then + EC = 3 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d + else + d = H - 0.002 + end + elseif nDrawMach > 0 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 <= 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 < 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 < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif 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 < 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[404],sNamePar8,EgtToUiUnits(R), sCompoPath) -- il parametro 'R' deve essere >= 0 + R = d/2 + elseif 2*R >= L then + EC = 11 + EM = string.format(EgtDoorsMsg[406],sNamePar8,EgtToUiUnits(R),sNamePar1..'/2',EgtToUiUnits(L/2), sCompoPath) -- il parametro 'R' deve essere > 0 + R = d/2 + elseif R >= H then + EC = 12 + EM = string.format(EgtDoorsMsg[406],sNamePar8,EgtToUiUnits(R),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'R' deve essere > 0 + R = d/2 + elseif CLC 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) + + 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, hintPkR, hintAsR1, hintAsR2 + local pIni, pEnd, pCen + local pIni2, pEnd2 + + if nForceMakeFace ~= 1 then -- se abilitata geometria esterna + + -- Costruzione della geometria + if bEqualTh then -- se cava alta come lo spessore porta disegno un contorno chiuso + if est then -- se altro materiale + hint1 = DrawAddLineDrawCircle( Point3d(-((L/2)-(d/2)-dExtraH),(nStartY+(d/2)+dExtraH),0), Point3d((L/2),(nStartY+(d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint2 = DrawAddLineDrawCircle( Point3d((L/2),(nStartY+(d/2)+dExtraH),0), Point3d((L/2),(nStartY-(H+(d/2)+dExtraH)),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint3 = DrawAddLineDrawCircle( Point3d((L/2),(nStartY-(H+(d/2)+dExtraH)),0), Point3d(-(L/2),(nStartY-(H+(d/2)+dExtraH)),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint4 = DrawAddLineDrawCircle( Point3d(-(L/2),(nStartY-(H+(d/2)+dExtraH)),0), Point3d(-(L/2),(nStartY+(d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint5 = DrawAddLineDrawCircle( Point3d(-(L/2),(nStartY+(d/2)+dExtraH),0), Point3d(-((L/2)-(d/2)-dExtraH),(nStartY+(d/2)+dExtraH),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + else + hint1 = DrawAddLineDrawCircle( Point3d(0,nStartY,0), Point3d((L/2),nStartY,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint2 = DrawAddLineDrawCircle( Point3d((L/2),nStartY,0), Point3d((L/2),(nStartY-H),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint3 = DrawAddLineDrawCircle( Point3d((L/2),(nStartY-H),0), Point3d(-(L/2),(nStartY-H),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint4 = DrawAddLineDrawCircle( Point3d(-(L/2),(nStartY-H),0), Point3d(-(L/2),nStartY,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint5 = DrawAddLineDrawCircle( Point3d(-(L/2),nStartY,0), Point3d(0,nStartY,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + end + hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) + else -- altrimenti contorno aperto + + local tPocket = {} + + if est then -- se altro materiale + pIni = Point3d(-((L/2)-(d/2)-dExtraH),(nStartY+(d/2)+dExtraH),0) + pEnd = Point3d(L/2,(nStartY+(d/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(L/2,nStartY,0) + end + + if R > 0 then + pEnd = Point3d(L/2,(nStartY-H+R),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L/2)-R),(nStartY-H),0) + pCen = Point3d(((L/2)-R),(nStartY-H+R),0) + DrawAddCircleDrawCircle( pCen, R, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(L/2,(nStartY-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),(nStartY-H),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-(L/2),(nStartY-H+R),0) + pCen = Point3d((-(L/2)+R),(nStartY-H+R),0) + DrawAddCircleDrawCircle( pCen, R, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(-(L/2),(nStartY-H),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if est then -- se altro materiale + pEnd = Point3d(-(L/2),(nStartY+(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),(nStartY+(d/2)+dExtraH),0) + else + pEnd = Point3d(-(L/2),nStartY,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + hint = EgtCurveCompo( Lg, tPocket, true) + end + + if hint then + EgtModifyCurveThickness(hint, -T) + EgtSetName(hint,LG) + EgtSetInfo(hint,'SideDoor','Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + if est then + EgtSetInfo( hint, 'StartFromExt', 1) + end + if stk then + EgtSetInfo(hint,'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + + -- Clean corner + if CLC and clc and clc > 0 and clc < H and clc < L then + + local CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T) + if CLC1 then + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + EgtSetInfo( CLC1,'SideDoor','Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + if stk then + EgtSetInfo( CLC1,'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- angolo x+y- + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC2, Point3d((L/2),nStartY-H,0) - ORIG()) + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L/2),nStartY-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 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 = (nStartY-(d2/4)) + dEndPosY2 = (nStartY-H+(d2/4)) + else + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + end + else + if (H-R) > 0 then + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + else + dEndPosY = (nStartY-H+(d2/2)) + dEndPosY2 = (nStartY-(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),(nStartY+(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),(nStartY-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 = (nStartY-(d2/4)) + dEndPosY2 = (nStartY-H+(d2/4)) + else + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + end + else + if (H-R) > 0 then + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + else + dEndPosY = (nStartY-H+(d2/2)) + dEndPosY2 = (nStartY-(d2/2)) + end + end + + dIniPosY = (nStartY+(d2*3/4)) + dIniPosY2 = (nStartY-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) + EgtSetName( hintAs1, LA) + EgtSetInfo( hintAs1, 'SideDoor', 'Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + if stk then + EgtSetInfo( hintAs1, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + end + + if ( #tPocketAs2 > 0) then + hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true) + if hintAs2 then + EgtModifyCurveThickness(hintAs2, -T) + EgtSetName( hintAs2, LA) + EgtSetInfo( hintAs2, 'SideDoor', 'Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + if stk then + EgtSetInfo( hintAs2, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + 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 = (nStartY-(d2/4)) + dEndPosY2 = (nStartY-H+(d2/4)) + else + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + end + else + if (H-R) > 0 then + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + else + dEndPosY = (nStartY-H+(d2/2)) + dEndPosY2 = (nStartY-(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),(nStartY+(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),(nStartY-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 = (nStartY-(d2/4)) + dEndPosY2 = (nStartY-H+(d2/4)) + else + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + end + else + if (H-R) > 0 then + dEndPosY = (nStartY-(H-R)) + dEndPosY2 = (nStartY-R) + else + dEndPosY = (nStartY-H+(d2/2)) + dEndPosY2 = (nStartY-(d2/2)) + end + end + + dIniPosY = (nStartY+(d2*3/4)) + dIniPosY2 = (nStartY-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(-((L-d2)/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 + EgtSetName( hintAs1, LA) + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + EgtSetInfo( hintAs1, 'SideDoor', 'Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + if stk then + EgtSetInfo( hintAs1, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + 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 + EgtSetName( hintAs2, LA) + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + EgtSetInfo( hintAs2, 'SideDoor', 'Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + if stk then + EgtSetInfo( hintAs2, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + 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,(nStartY+(d*3/4)),dZedWork) + pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + -- linea in Y con centro utensile fuori + pEnd = Point3d(-((L-d)/2) + 0.2,(nStartY+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),(nStartY+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(((L-d)/2),(nStartY+(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),(nStartY-H-dExtraH),dZedWork) + else + pEnd = Point3d(((L-d)/2),(nStartY-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),(nStartY-H-dExtraH),dZedWork) + else + pEnd = Point3d(-((L-d)/2),(nStartY-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),(nStartY+(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 -- NB se c'è il raggio non è passante + -- linea entrante in Y + pEnd = Point3d(((L-d)/2),(nStartY-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),(nStartY-H+(d/2)),dZedWork) + pCen = Point3d(((L/2)-R),(nStartY-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),(nStartY-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),(nStartY-H+R),dZedWork) + pCen = Point3d((-(L/2)+R),(nStartY-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),(nStartY-H-dExtraH),dZedWork) + else + pEnd = Point3d(((L-d)/2),(nStartY-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),(nStartY-H-dExtraH),dZedWork) + else + pEnd = Point3d(-((L-d)/2),(nStartY-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),(nStartY+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),(nStartY+dExtraH),dZedWork) + else + pEnd = Point3d((((L*2)-(d*3))/4),(nStartY+dExtraH),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pIni = pEnd + + local nDirVers = EgtIf( bStartOppo, 1, -1) + local nDistYcentr = (d*p) + local nPosYcentr = (nStartY+dExtraH) - nDistYcentr + local bContinue + local nDeltaXPk = 0 + + if bEqualTh then + bContinue = nPosYcentr > nStartY-H + else + bContinue = nPosYcentr > (nStartY-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 < (nStartY-H+R) then + local nDeltaY = nPosYcentr - (nStartY-H+R) + nDeltaXPk = (R-(d/2)) - sqrt( ((R-(d/2))*(R-(d/2))) - (nDeltaY*nDeltaY)) + end + + if bContinue then + pEnd = Point3d((-nDirVers * ((((L*2)-(d*3))/4)-nDeltaXPk)),nPosYcentr,dZedWork) + end + + -- 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 > nStartY-H + else + bContinue = nPosYcentr > (nStartY-H+(d/2)) + end + + -- calcolo il delta x relativo alla presenza del raccordo + if bContinue and R > (d/2) and nPosYcentr < (nStartY-H+R) then + local nDeltaY = nPosYcentr - (nStartY-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(), (nStartY+(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, 'SideDoor', 'Sidelh') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintPk, 'NotCheckDir', '1') + if stk then + EgtSetInfo( hintPk, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'w' -- setto di default per mantenere il lato wide + 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 + -- 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)) + local nIdSideBoxUp = EgtRectangle2P( Lg, Point3d((L/2),0,nStartY), Point3d(-(L/2),-fhb,nStartY), GDB_RT.GRID) +-- nIdSideBoxUp = EgtRectangle2P( Lg, Point3d(-(L/2)+D_SS,0,((H/2)+HS)), Point3d(-(L/2)+D_SS+LS,-fhb,((H/2)+HS)), GDB_RT.GRID) + if nIdSideBoxUp then + if bEqualTh then + EgtModifyCurveThickness(nIdSideBoxUp, -dThickDoor) + else + EgtModifyCurveThickness(nIdSideBoxUp, -H) + end + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + else -- altrimenti frame viene disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + end + + -- aggiungo foro probe + if EC == 0 and nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo = 'Sidelh' + if DGC.Fpd then + sSideDoorInfo = 'Lock' + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + if stk then + EgtSetInfo( hintPr, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + end + if dPosProbe > 0 then + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + if stk then + EgtSetInfo( hintPr, 'LikeStrike', '1') -- setto una nota per indicare che è una geometria trattata come strike + end + end + end + end + + if EC == 0 and D_XE and D_XE ~= 0 then + EgtMove( Lg, Point3d(0,D_XE,0) - ORIG()) + 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 + 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 + 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 serratura + EgtSetInfo( Lg, 'Type' ,'EdgePullFlat') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'R' ,R) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'T' ,T) + 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, 'nStartY' ,nStartY) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'stk' ,stk) + EgtSetInfo( Lg, 'fht' ,fht) + EgtSetInfo( Lg, 'fhb' ,fhb) + EgtSetInfo( Lg, 'drf' ,drf) + EgtSetInfo( Lg, 'dws' ,dws) + EgtSetInfo( Lg, 'dthd' ,dthd) + EgtSetInfo( Lg, 'D_XE' ,D_XE) + EgtSetInfo( Lg, 'LG' ,LG) + EgtSetInfo( Lg, 'LM' ,LM) + EgtSetInfo( Lg, 'LA' ,LA) + EgtSetInfo( Lg, 'CLC' ,CLC) + 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 LockEdgePull diff --git a/LuaLibs/EdgePullMortiseCyl.lua b/LuaLibs/EdgePullMortiseCyl.lua new file mode 100644 index 0000000..67584c4 --- /dev/null +++ b/LuaLibs/EdgePullMortiseCyl.lua @@ -0,0 +1,1573 @@ +-- +-- 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 +-- +-- EdgePullMortiseCyl.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- edge pull tipo mortise o cilindrica + +-- 2016.09.21 V1.011 FM add warning messages +-- 2017.08.30 V1.012 FM Add flag for not rotate Face on bevel profile +-- 2018.04.05 V1.013 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.014 FM Add parameter to show into message 402 +-- 2018.10.22 V1.015 FM Manage better the big radius fillet parameter +-- 2018.10.22 V1.015 FM Add new parameter D_XE to move all geometries +-- 2019.10.10 V1.016 FM Manage steel option (disable to generate pocket paths, mortise) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.25 V2.001 FM Add clean corner geometries +-- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.003 FM fix a bug on clean corner direction path in case main path turn reverse +-- 2020.04.29 V2.004 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.11.24 V3.001 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.002 FM Modification to use compiled code +-- 2024.07.19 V3.003 FM Set note 'NotCheckDir' to pocketing and antisplint paths +-- 2024.09.17 V3.004 FM Fix error on not assigned parameters: H2 and D_X +-- 2024.10.03 V3.005 FM Manage probe geometry and their offset position when template is disposed +-- 2024.10.29 V3.006 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local EdgePullMortiseCyl = {} + +-- 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 function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function EdgePullMortiseCyl.AdjustParams( tMhPar) + + tMhPar.invG = 1 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local dOffset = DGD.OFFSET or 0 + + -- do errore se profilo tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or + DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') then + return tMhPar, 1999, string.format(EgtDoorsMsg[431], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se profilo bevel disabilito la giunzione tra face e mortise + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + tMhPar.jnb = false + -- setto il flag che indica profilo bevel + tMhPar.bev = true + else + tMhPar.jnb = true + end + + -- se serratura su lato destro setto il flag per invertire i percorsi + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + tMhPar.SL = DGD.Lock + + if tMhPar.dl and tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.jnb then + -- se non ruoto face risetto il flag che impedisce il chain tra face e mortise + tMhPar.jnb = true + -- ricalcolo la profondità per avere spessore minomo = al valore di .T + tMhPar.T = tMhPar.T + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + -- ricalcolo anche lo spessore seconda cava, se presente + if tMhPar.T2nd and tMhPar.T2nd > 0 then + tMhPar.T2nd = tMhPar.T2nd + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + end + else + tMhPar.dl = false + end + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then + tMhPar.sf = tMhPar.T + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template non è sui lati top e bottom + if DGD.SDF and DGD.SDF > 1 then + + -- calcolo la posizione del centro foro sullo spessore porta + if dOffset > 0 then + if DGD.Push then + tMhPar.posh = (DGD.dT/2) - dOffset + else + tMhPar.posh = -(DGD.dT/2) + dOffset + end + else + tMhPar.posh = 0 + end + + if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + + -- se non ho il parametro di arrotondamento lati lo setto disabilitato + if not tMhPar.cl then + tMhPar.cl = 0 + end + + -- se arrotondo entrambe le estremità disabilito il chisel e il cleancorner + if tMhPar.cl == 3 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.cl > 0 and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLA3 + local nLA3i = 1 + local sLGH + local nLGHi = 1 + local sLG + local nLGi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.LA3 = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + tMhPar.d3 = nil + else + tMhPar.est = nil + end + + -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- profilo serrratura bevel up + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 3 + nLGi = 3 + else + nLMi = 2 + nLGi = 2 + end + elseif DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB' then -- profilo serrratura bevel dn + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 2 + nLGi = 2 + else + nLMi = 3 + nLGi = 3 + end + end + + if tMhPar.est and tMhPar.LG then -- se altro materiale + 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.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) 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 + + if tMhPar.LA3 then + sLA3 = tMhPar.LA3 + if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLA3, nLA3i) end + end + + if tMhPar.mh and tMhPar.LGH then + sLGH = tMhPar.LGH + if DGD.MachEn > 0 then nTempT4, dMaxMat2, sMchngName4 = MB.GetToolDataFromAttrib( sLGH, nLGHi) 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 <= 0 then + dNumLog = -1988 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1990 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + dNumLog = -1990 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + if not tMhPar.est and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -1990 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLA3, nLA3i, tMhPar.d3, dNumLog, sMchngName3) + end + elseif not tMhPar.est and nTempT3 then + tMhPar.d3 = nTempT3 + end + + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat2 then + dNumLog = -1989 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLGH, nLGHi, nil, dNumLog, sMchngName4) + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + end + + -- se la profondità della face 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 = -1987 + 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 = -1998 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità della seconda face è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T2nd and dMaxMat1 and tMhPar.T2nd > dMaxMat1 then + dNumLog = -1997 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2nd), EgtToUiUnits(dMaxMat1)) + tMhPar.T2nd = dMaxMat1 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and not tMhPar.mh and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1996 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 - 0.02 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if ( not tMhPar.jn or tMhPar.mh or not tMhPar.jnb) and + tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1995 + if tMhPar.mh then + dNumMessage = 463 + else + dNumMessage = 461 + end + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 - 0.02 + end + + -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1994 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 - 0.02 + end + + -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and + tMhPar.T3 and dMaxMat1 and tMhPar.T3 > dMaxMat1 then + dNumLog = -1993 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat1)) + tMhPar.T3 = dMaxMat1 + end + + -- se solo le mortise concatenate a face e la profondità della seconda mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and + tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then + dNumLog = -1992 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) + tMhPar.T3 = dMaxMat2 + end + + -- se nessuna mortise è concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and not tMhPar.jn2 and + tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then + dNumLog = -1991 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) + tMhPar.T3 = dMaxMat2 + end + + -- 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.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function EdgePullMortiseCyl.Draw( tLckP, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni geometria + local L = tLckP.L -- lunghezza face + local H = tLckP.H -- larghezza face + local T = tLckP.T -- spessore face + local T2nd = tLckP.T2nd -- seconda profondità cava doppia + local nPosT2nd = tLckP.nPosT2nd -- posizione cava con profondità maggiorata. solo valori -1 o 1 + local d = tLckP.d -- diametro utensile face + local p = tLckP.p -- percentuale uso utensile face + local sf = tLckP.sf -- passo affondamento face + local dl = tLckP.dl -- disponi face come lock, cioè non ruotata su bevel + local mh = tLckP.mh -- crea foro: true o mortasa: false + local L2 = tLckP.L2 -- lunghezza mortasa (seconda cava) + local H2 = tLckP.H2 -- larghezza mortasa o diametro foro + local T2 = tLckP.T2 -- profondità mortasa o foro + local d2 = tLckP.d2 -- diametro utensile svuotatura mortasa ( non per foro) + local p2 = tLckP.p2 -- percentuale uso utensile mortasa + local s = tLckP.s -- passo affondamento mortasa + local L3 = tLckP.L3 -- lunghezza seconda mortasa ( terza cava) + local H3 = tLckP.H3 -- larghezza seconda mortasa ( terza cava) + local T3 = tLckP.T3 -- profondità seconda mortasa ( terza cava) + local d3 = tLckP.d3 -- diametro utensile svuotatura seconda mortasa + local p3 = tLckP.p3 -- percentuale uso utensile seconda mortasa + local s3 = tLckP.s3 -- passo affondamento seconda mortasa + local cl = tLckP.cl -- arrotonda estremità face, 0: nessun arrotondamento, 1: arrotonda a sinistra, + -- 2: arrotonda a destra, 3: arrotonda entrambe i lati + local rf = tLckP.rf -- raggio arrotondamento face + local clc = tLckP.clc + local ccr = tLckP.ccr + local ech = tLckP.ech -- abilitazione chisel + local est = tLckP.est -- altro materiale trovato + local kbs = tLckP.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tLckP.pbs + local SL = tLckP.SL + -- Assegno i flag + local jn = tLckP.jn -- flag per giunzione prima cava face con seconda cava (mortasa) + local jn2 = tLckP.jn2 -- flag per giunzione seconda cava (mortasa) con terza cava ( seconda mortasa) + local jnb = tLckP.jnb -- flag che indica se profilo tipo bevel o meno + -- Inserimento geometrie probe + local posh = tLckP.posh -- posizione in Y del foro di tastatura + local posp = tLckP.posp -- posizione in X del foro di tastatura + -- Disassamento delle 2 cave rispetto alla face + local D_X = tLckP.D_X -- disassamento seconda cava (mortasa o foro) da centro lunghezza face + local D_X3 = tLckP.D_X3 -- disassamento terza cava (seconda mortasa) da centro lunghezza face + -- Disassamento globale + local D_XE = tLckP.D_XE -- Extra delta on X pos for all geometries + -- gestione inversione percorsi + local invG = tLckP.invG -- flag per invertire il senso dei percorsi di lavorazione + -- Assegno le label degli attributi fianco porta + local LG = tLckP.LG -- nome geometria face: per la doppia face, la prima geometria è LG..'1st' + local LG2 = tLckP.LG2 -- nome geometria seconda cava (mortasa) + local LG3 = tLckP.LG3 -- nome geometria terza cava (seconda mortasa) + local LM = tLckP.LM -- nome geometria lavorazione face: per la doppia face, la prima geometria è LM..'1st' + local LA = tLckP.LA -- nome geometria lavorazione seconda cava (mortasa) + local LA3 = tLckP.LA3 -- nome geometria lavorazione terza cava (seconda mortasa) + local CH = tLckP.CH -- nome suffisso lavorazione chisel + local CLC = tLckP.CLC -- nome geometria clean corner + -- Assegno le label alla geometria foro profondo di lato + local LGH = tLckP.LGH -- nome geometria seconda cava (foro) + -- variabile nome geometrie probe + local LH = 'Shuttle_Probe' + -- variabili per messaggi e settaggi vari + local sCompoName = tLckP.Nome + local nCompoNpar = tLckP.Npar + local sCompoPath = tLckP.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLckP.nCod + local sCodAdj = tLckP.sCod + -- variabili per messaggi di errore + local sNamePar1 = tLckP.NPL or 'L' + local sNamePar2 = tLckP.NPH or 'H' + local sNamePar3 = tLckP.NPT or 'T' + local sNamePar13 = tLckP.NPT2nd or 'T2nd' + local sNamePar4 = tLckP.NPd or 'd' + local sNamePar5 = tLckP.NPp or 'p' + local sNamePar7 = tLckP.NL2 or 'L2' + local sNamePar8 = tLckP.NT2 or 'T2' + local sNamePar9 = tLckP.NPd2 or 'd2' + local sNamePar10 = tLckP.NPp2 or 'p2' + local sNamePar11 = tLckP.NPS or 's' + local sNamePar12 = tLckP.NPH2 or 'H2' + local sNamePar14 = tLckP.NL3 or 'L3' + local sNamePar15 = tLckP.NL3 or 'H3' + local sNamePar16 = tLckP.NT3 or 'T3' + local sNamePar17 = tLckP.NPd3 or 'd3' + local sNamePar18 = tLckP.NPp3 or 'p3' + local sNamePar19 = tLckP.NPS3 or 's3' + local sNamePar20 = tLckP.NPD_X or 'D_X' + local sNamePar21 = tLckP.NPD_X3 or 'D_X3' + local sNamePar48 = tLckP.NPSF or 'sf' + local sNamePar49 = tLckP.NPRF or 'rf' + local sNamePar50 = tLckP.N50 or 'clc' + local sNamePar51 = tLckP.N51 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1900 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeMortGeom2nd = true + + if not bRunByCompo then + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + clc = nil + CLC = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom then + if L >= H then + if rf > (H/2) then + rf = (H/2) + end + else + if rf > (L/2) then + rf = (L/2) + end + end + end + + -- se rilevato profilo bevel disattivo il join tra face e mortasa + if not jnb then + jn = false + end + + if not T then T = 0 end + if not D_X then D_X = 0 end + if not D_XE then D_XE = 0 end + + if mh then + if not H2 then + bMakeMortGeom = false + end + -- disattivo i join sul foro + jn = false + jn2 = false + else + if not L2 or not H2 then + bMakeMortGeom = false + -- disattivo i join + jn = false + jn2 = false + end + end + + if not T2 then + T2 = 0 + end + + if not L3 or not H3 then + bMakeMortGeom2nd = false + end + + if not T3 then + T3 = 0 + end + + if est then + bMakeMortGeom = false + bMakeMortGeom2nd = false + -- disattivo i join + jn = false + jn2 = false +-- jnb = false + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + end + -- se seconda e terza cava giuntate assegno il diametro della terza cava uguale alla seconda + if jn2 and bMakeMortGeom and bMakeMortGeom2nd then + d3 = d2 + p3 = p2 + s3 = s + end + + -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione + if not nDrawMach then + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and L <= 0 then + EC = 1 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d*2 + elseif bMakeMortGeom and not mh and L2 < 0 then + EC = 2 + EM = string.format(EgtDoorsMsg[404],sNamePar7,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L2' deve essere >= 0 + L2 = d2*2 + elseif bMakeMortGeom2nd and L3 < 0 then + EC = 3 + EM = string.format(EgtDoorsMsg[404],sNamePar14,EgtToUiUnits(L3), sCompoPath) -- il parametro 'L3' deve essere >= 0 + L3 = d3*2 + elseif bMakeFaceGeom and H <= 0 then + EC = 4 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d + elseif bMakeMortGeom and H2 <= 0 then + EC = 5 + EM = string.format(EgtDoorsMsg[401],sNamePar12,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 + H2 = d2 + elseif bMakeMortGeom2nd and H3 <= 0 then + EC = 6 + EM = string.format(EgtDoorsMsg[401],sNamePar15,EgtToUiUnits(H3), sCompoPath) -- il parametro 'H3' deve essere > 0 + H3 = d3 + elseif bMakeFaceGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and T2 <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + T2 = 0.1 + elseif bMakeMortGeom2nd and T3 <= 0 then + EC = 9 + EM = string.format(EgtDoorsMsg[401],sNamePar16,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere > 0 + T3 = 0.1 + elseif bMakeFaceGeom and T2nd and T2nd < 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[404],sNamePar13,EgtToUiUnits(T2nd), sCompoPath) -- il parametro 'T2nd' deve essere >= 0 + T2nd = 0 + elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EC = 11 + 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 bMakeMortGeom and nDrawMach > 0 and not mh and L2 <= d2 then + if DGD.bProoduce then + EC = 12 + EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L2 = d2 + 0.002 + else + d2 = L2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and L3 <= d3 then + if DGD.bProoduce then + EC = 13 + EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L3 = d3 + 0.002 + else + d3 = L3 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EC = 14 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not mh and H2 < d2 then + if DGD.bProoduce then + EC = 15 + EM = string.format(EgtDoorsMsg[405],sNamePar12,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and H3 < d3 then + if DGD.bProoduce then + EC = 16 + EM = string.format(EgtDoorsMsg[405],sNamePar15,EgtToUiUnits(H3),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H3' deve essere >= del diametro utensile + H3 = d3 + else + d3 = H3 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 17 + EM = string.format(EgtDoorsMsg[400],sNamePar4, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not mh and d2 < DgMin then + EC = 18 + EM = string.format(EgtDoorsMsg[400],sNamePar9, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeMortGeom2nd and nDrawMach > 0 and d3 < DgMin then + EC = 19 + EM = string.format(EgtDoorsMsg[400],sNamePar17, EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 20 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and ( p2 < PtMin or p2 > PtMax) then + EC = 21 + EM = string.format(EgtDoorsMsg[403],sNamePar10,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + p2 = 0.8 + elseif bMakeMortGeom2nd and nDrawMach > 0 and ( p3 < PtMin or p3 > PtMax) then + EC = 22 + EM = string.format(EgtDoorsMsg[403],sNamePar18,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeFaceGeom and bMakeMortGeom and not mh and L2 >= L then + EC = 23 + EM = string.format(EgtDoorsMsg[406],sNamePar7,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + L2 = L - 0.1 +-- elseif bMakeMortGeom and bMakeMortGeom2nd and not mh and L3 >= L2 then +-- EC = 24 +-- EM = string.format(EgtDoorsMsg[406],sNamePar14,EgtToUiUnits(L3),sNamePar7,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L3' deve essere < 'L2' +-- L3 = L2 - 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EC = 25 + EM = string.format(EgtDoorsMsg[456],sNamePar12,EgtToUiUnits(H2),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H2' deve essere <= 'H' + H2 = H + elseif bMakeMortGeom and bMakeMortGeom2nd and H3 > H2 then + EC = 26 + EM = string.format(EgtDoorsMsg[456],sNamePar15,EgtToUiUnits(H3),sNamePar12,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H3' deve essere <= 'H2' + H3 = H2 + elseif bMakeFaceGeom and bMakeMortGeom and T2 <= T then + EC = 27 + EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + T2 = T + 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and T2nd and T2 <= T2nd then + EC = 28 + EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar13,EgtToUiUnits(T2nd), sCompoPath) -- il parametro 'T2' deve essere > 'T2nd' + T2 = T2nd + 0.1 + elseif bMakeMortGeom and bMakeMortGeom2nd and T3 <= T2 then + EC = 29 + EM = string.format(EgtDoorsMsg[407],sNamePar16,EgtToUiUnits(T3),sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T3' deve essere > 'T2' + T3 = T2 + 0.1 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and s and s <= 0 then + EC = 30 + EM = string.format(EgtDoorsMsg[401],sNamePar11,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d2 + elseif bMakeMortGeom2nd and nDrawMach > 0 and s3 and s3 <= 0 then + EC = 31 + EM = string.format(EgtDoorsMsg[401],sNamePar19,EgtToUiUnits(s3), sCompoPath) -- il parametro 's3' deve essere > 0 + s3 = d3 + elseif bMakeFaceGeom and bMakeMortGeom and not mh and D_X and abs(2*D_X) > (L-L2) then -- se il decentramento è troppo altro e fa sbordare la cava2 dalla 1 + EC = 32 + EM = string.format(EgtDoorsMsg[423],sNamePar20,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and mh and D_X and abs(2*D_X) > (L-H2) then -- se il decentramento è troppo altro e fa sbordare la cava2 dalla 1 + EC = 33 + EM = string.format(EgtDoorsMsg[423],sNamePar20,EgtToUiUnits(D_X),EgtToUiUnits((L-H2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 +-- elseif bMakeMortGeom and bMakeMortGeom2nd and not mh and D_X and D_X3 and abs(2*(D_X-D_X3)) > (L2-L3) then -- se il decentramento è troppo altro e fa sbordare la cava3 dalla 2 +-- EC = 34 +-- EM = string.format(EgtDoorsMsg[423],sNamePar21,EgtToUiUnits(D_X3),EgtToUiUnits(((L2-L3)/2)-D_X), sCompoPath) -- il parametro 'D_X3' é troppo grande, max valore: +-- D_X3 = 0 +-- elseif bMakeFaceGeom and bMakeMortGeom2nd and D_X3 and abs(2*D_X3) > (L-L3) then -- se il decentramento è troppo altro e fa sbordare la cava3 dalla 1 +-- EC = 35 +-- EM = string.format(EgtDoorsMsg[423],sNamePar21,EgtToUiUnits(D_X3),EgtToUiUnits((L-L3)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: +-- D_X3 = 0 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 36 + EM = string.format(EgtDoorsMsg[401],sNamePar48,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMakeFaceGeom and cl and cl > 0 and rf < 0 then + EC = 37 + EM = string.format(EgtDoorsMsg[404],sNamePar49,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + rf = H/2 + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 38 + EM = string.format(EgtDoorsMsg[407],sNamePar50,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 + local bMakeTwinFace = false + -- variabili dei percorsi geometrici + local nGeomFace, nGeom1st, nGeom1, nGeom2, nGeom3 + local nPkToJoin1st, nPkToJoin1, nPkToJoin2, nPkToJoin3 + local nPkJoin, nPkJoin1 + local nPosFace = 0 + local nPos1st = 0 + local nPos2nd = 0 + local bMakeSecondFace = false + local dFirstface = {} + local dSecondface = {} + local nForceMakeFace = nDrawMach + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale + EgtSetName(Lg,sCompoName) + + -- verifico le condizioni necessarie per creare la doppia face + if jnb and H and H2 and abs(H - H2) < GEO.EPS_SMALL and not mh and bMakeFaceGeom and cl == 0 then + bMakeTwinFace = true + end + + if bMakeFaceGeom then + + -- se posizione cava profondità maggiorata non è definita o con valori non idonei, + -- la setto di default a -1 ( inserimento a sinistra) + if not nPosT2nd or ( nPosT2nd ~= -1 and nPosT2nd ~= 1) then + nPosT2nd = -1 + end + + -- se seconda profondità non definita o nulla la setto uguale alla profondità generale + if not T2nd or T2nd < GEO.EPS_SMALL then + T2nd = T + end + + if bMakeTwinFace then -- se doppia cava face preparo la relativa tabella con i parametri + + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPosFace = H/4 + elseif cl == 2 then -- se arrotondamento a destra + nPosFace = -H/4 + else + nPosFace = 0 + end + + -- se contorno più percorsi lavorazione, faccio fare solo contorno + if nDrawMach > 1 then + nForceMakeFace = 0 + end + + -- cava face solo contorno + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = L + dFirstface.H = H + dFirstface.T = T + dFirstface.d = d + dFirstface.p = p + dFirstface.sf = sf + dFirstface.jn = false -- disattivo il join della prima cava face + dFirstface.L2 = L2 + dFirstface.H2 = H2 + dFirstface.cl = cl + dFirstface.rf = rf + dFirstface.est = est + dFirstface.invG = invG + dFirstface.LG = LG + dFirstface.LM = LM + dFirstface.Nome = sCompoName + dFirstface.D_X = 0 -- annullo lo spostamento della mortasa + dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + -- lancio il primo componente base con settato il parametro per disegnare solamente il contorno esterno + -- senza lavorazione + MHgen = require( '_Latch') + nGeomFace = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- riassegno il valore impostazione originario + nForceMakeFace = nDrawMach + + -- prima semi-cava face completa + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = ((L-L2)/2) + ( D_X * nPosT2nd) + (d/2) + dExtraH + if est then + dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + else + dFirstface.smr = -nPosT2nd -- crea i raccordini in base alla posizione cava + end + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dFirstface.LG = LG .. '_1st' .. 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 + else + dFirstface.LG = LG .. '_1st' + end + if LM then + dFirstface.LM = LM .. '_1st' + else + dFirstface.LM = nil + end + nPos1st = ( dFirstface.L - L)/2 * nPosT2nd + -- lancio il primo componente base per disegnare prima semi-face + MHgen = require( '_Latch') + nGeom1st, nPkToJoin1st = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- seconda semi-cava face + bMakeSecondFace = true + -- assegno i valori coerenti con la tabella del componente + dSecondface.L = ((L-L2)/2) - ( D_X * nPosT2nd) + (d/2) + dExtraH + dSecondface.H = H + dSecondface.T = T2nd + dSecondface.d = d + dSecondface.p = p + dSecondface.sf = sf + dSecondface.jn = jn + dSecondface.L2 = L2 + dSecondface.H2 = H2 + dSecondface.cl = cl + dSecondface.rf = rf + dSecondface.est = est + dSecondface.invG = invG + if est then + dSecondface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + else + dSecondface.smr = nPosT2nd -- crea i raccordini in base alla posizione cava + end + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dSecondface.LG = LG .. CH + else + dSecondface.LG = LG + end + dSecondface.LM = LM + dSecondface.Nome = sCompoName + nPos2nd = (L - dSecondface.L)/2 * nPosT2nd + -- calcolo la posizione dal centro cava 2nd face al centro della mortasa + dSecondface.D_X = D_X - nPos2nd + -- lancio il primo componente base per disegnare seconda semi-face + MHgen = require( '_Latch') + nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, dSecondface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + else -- altrimenti cava face completa + + -- verifico se è fattibile la seconda semi-cava + if abs(T2nd-T) > GEO.EPS_SMALL and + ( ( ( cl == 0 or cl == 2) and nPosT2nd < 0) or + ( ( cl == 0 or cl == 1) and nPosT2nd > 0)) then + bMakeSecondFace = true + else + T2nd = T -- se non faccio la semicava secondaria rimetto lo spessore della face intera + end + + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPos1st = rf/2 + elseif cl == 2 then -- se arrotondamento a destra + nPos1st = -(rf/2) + else + nPos1st = 0 + end + + -- prima cava face completa + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = L + dFirstface.H = H + dFirstface.T = T + dFirstface.d = d + dFirstface.p = p + dFirstface.sf = sf + -- se c'è la seconda cava disattivo il join + if bMakeSecondFace then + dFirstface.jn = false -- disattivo il join della prima cava face + else + dFirstface.jn = jn + end + dFirstface.L2 = L2 + dFirstface.H2 = H2 + dFirstface.cl = cl + dFirstface.rf = rf + dFirstface.est = est + dFirstface.invG = invG + dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dFirstface.LG = LG .. '_1st' .. 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 + else + dFirstface.LG = LG .. '_1st' + end + if LM then + dFirstface.LM = LM .. '_1st' + else + dFirstface.LM = nil + end + dFirstface.Nome = sCompoName + dFirstface.D_X = -nPos1st + D_X + nPos2nd = 0 + -- lancio il primo componente base per disegnare la face completa + MHgen = require( '_Latch') + nGeom1st, nPkToJoin1st = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- se seconda profondità face differisce dalla profondita generale face + -- e non ci sono raccordi, creo la seconda semi-cava + if bMakeSecondFace then + -- seconda semi-cava face + -- assegno i valori coerenti con la tabella del componente + dSecondface.L = ((L-L2)/2) - ( D_X * nPosT2nd) + (d/2) + dExtraH + dSecondface.H = H + dSecondface.T = T2nd + dSecondface.d = d + dSecondface.p = p + dSecondface.sf = sf + dSecondface.jn = jn + dSecondface.L2 = L2 + dSecondface.H2 = H2 + dSecondface.cl = 0 -- faccio solo semi-cava rettangolare + dSecondface.rf = rf + dSecondface.invG = invG + if est then + dSecondface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + else + dSecondface.smr = nPosT2nd -- crea i raccordini in base alla posizione cava + end + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dSecondface.LG = LG .. CH + else + dSecondface.LG = LG + end + dSecondface.LM = LM + dSecondface.Nome = sCompoName + nPos2nd = (L - dSecondface.L)/2 * nPosT2nd + -- calcolo la posizione dal centro cava 2nd face al centro della mortasa + dSecondface.D_X = D_X - nPos2nd + + -- lancio il primo componente base + MHgen = require( '_Latch') + nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, dSecondface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + end + end + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + local sSide = EgtIf( dl, 'Lock', 'Side') + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo + if CLC and clc and clc > 0 and clc < H and clc < L then + + local CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset + if kbs and kbs > 0 then + EgtSetInfo( CLC1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + EgtSetInfo( CLC1,'SideDoor',sSide) + if cl <= 1 or cl == 3 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + if cl == 1 then + EgtErase(CLC1) + end + end + if cl == 0 or cl >= 2 then + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + end + + if nGeomFace then + EgtSetInfo(nGeomFace,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nGeomFace, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeomFace, 'ProbeSide', '1') + end + end + if nGeom1st then + EgtSetInfo(nGeom1st,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nGeom1st, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom1st, 'ProbeSide', '1') + end + end + if nPkToJoin1st then + EgtSetInfo(nPkToJoin1st,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin1st, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1st, 'ProbeSide', '1') + end + end + if nGeom1 then + EgtSetInfo(nGeom1,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nGeom1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + end + if nPkToJoin1 then + EgtSetInfo(nPkToJoin1,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + end + end + end + + if bMakeMortGeom then -- se seconda cava abilitata + + if mh then -- se devo fare il foro + + nGeom2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom2, -T2) + EgtSetName( nGeom2, LGH) + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + -- cava mortasa + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + if jn then + dMortise.T = T2nd + else + dMortise.T = T + end + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.LGM = LG2 + dMortise.LMM = LA + dMortise.Nome = sCompoName + dMortise.jne = jn2 + -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva + if jn2 then + dMortise.D_X = (D_X3-D_X) + end + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + end + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom2 then EgtSetInfo(nGeom2,'SideDoor','Lock') end + if nPkToJoin2 then EgtSetInfo(nPkToJoin2,'SideDoor','Lock') end + end + + if bMakeMortGeom2nd then -- se terza cava abilitata + + -- cava mortasa + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T2 + dMortise.L2 = L3 + dMortise.H2 = H3 + dMortise.T2 = T3 + dMortise.s = s3 + dMortise.d = d3 + dMortise.p = p3 + dMortise.jn = jn2 + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.jne = false -- non ci sono ulteriori cave, disabilito il join alla successiva + dMortise.LGM = LG3 + dMortise.LMM = LA3 + dMortise.Nome = sCompoName + -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva + dMortise.D_X = 0 + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom3, nPkToJoin3 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if nGeom3 then EgtSetInfo(nGeom3,'SideDoor','Lock') end + if nPkToJoin3 then EgtSetInfo(nPkToJoin3,'SideDoor','Lock') end + end + + if EC == 0 and nGeomFace and abs(nPosFace) > GEO.EPS_SMALL then -- se esiste solo la geometria face + EgtMove( nGeomFace, Point3d(nPosFace,0,0) - ORIG()) + end + + if EC == 0 and ( nGeom1st or nPkToJoin1st) and abs(nPos1st) > GEO.EPS_SMALL then -- se esiste la prima face + if nGeom1st then + EgtMove( nGeom1st, Point3d(nPos1st,0,0) - ORIG()) + end + if nPkToJoin1st then + EgtMove( nPkToJoin1st, Point3d(nPos1st,0,0) - ORIG()) + end + end + + if EC == 0 and ( nGeom1 or nPkToJoin1) and abs(nPos2nd) > GEO.EPS_SMALL then -- se esiste la seconda face + if nGeom1 then + EgtMove( nGeom1, Point3d(nPos2nd,0,0) - ORIG()) + end + if nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d(nPos2nd,0,0) - ORIG()) + end + end + + if EC == 0 and mh and nGeom2 and abs(D_X) > GEO.EPS_SMALL then -- se esiste il secondo foro + EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) + end + + if EC == 0 and not mh and ( nGeom2 or nPkToJoin2) and abs(D_X) > GEO.EPS_SMALL then -- se esiste la seconda cava + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,0,0) - ORIG()) + end + end + + if EC == 0 and ( nGeom3 or nPkToJoin3) and abs(D_X3) > GEO.EPS_SMALL then -- se esiste la terza cava + if nGeom3 then + EgtMove( nGeom3, Point3d(D_X3,0,0) - ORIG()) + end + if nPkToJoin3 then + EgtMove( nPkToJoin3, Point3d(D_X3,0,0) - ORIG()) + end + end + + -- se percorsi fatti con lo stesso utensile, li concateno + if bMakeSecondFace then -- se doppia cava face + if jn and EC == 0 and nPkToJoin1 and nPkToJoin2 then + nPkJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM) + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 40 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and nPkToJoin2 then + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + else -- seconda semi-cava non presente + if not bMakeTwinFace then -- creata face completa + if jn and EC == 0 and nPkToJoin1st and nPkToJoin2 then + nPkJoin = EgtCurveCompo( Lg, {nPkToJoin1st,nPkToJoin2}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM) + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 41 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and nPkToJoin2 then + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( nGeom2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + end + end + + if jn2 and EC == 0 and nDrawMach > 0 then + if nPkJoin then -- se riuscito primo concatenamento + nPkJoin1 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin3}, true) + else + nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin2,nPkToJoin3}, true) + end + + if nPkJoin1 then + if nPkJoin then + EgtSetName( nPkJoin1, LM) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + if nGeom3 then + EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin1, 'ProbeSide', '1') + if nGeom3 then + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + else + EgtSetName( nPkJoin1, LA) + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + if nGeom3 then + EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin1, 'ProbeSide', '1') + if nGeom3 then + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + end + EgtSetInfo( nPkJoin1, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') + else + EC = ErrorBase + 42 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn2 and EC == 0 and nDrawMach > 0 then -- altrimenti se non devo concatenare + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + if nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if nGeom3 then + EgtSetInfo( nGeom3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + end + if nGeom3 then + EgtSetInfo( nGeom3, 'ProbeSide', '1') + end + end + end + + -- aggiungo foro probe + if EC == 0 and nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + else + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo + if DGC.Fpd then + sSideDoorInfo = 'Lock' + else + sSideDoorInfo = EgtIf( dl, 'Lock', 'Side') + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + if dPosProbe > 0 then + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + + if EC == 0 and D_XE and D_XE ~= 0 then + EgtMove( Lg, Point3d(0,D_XE,0) - ORIG()) + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo( Lg, 'Type' ,'EdgePullMortiseCyl') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'T2nd' ,T2nd) + EgtSetInfo( Lg, 'nPosT2nd' ,nPosT2nd) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'dl' ,dl) + EgtSetInfo( Lg, 'mh' ,mh) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'p2' ,p2) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'L3' ,L3) + EgtSetInfo( Lg, 'H3' ,H3) + EgtSetInfo( Lg, 'T3' ,T3) + EgtSetInfo( Lg, 'd3' ,d3) + EgtSetInfo( Lg, 'p3' ,p3) + EgtSetInfo( Lg, 's3' ,s3) + EgtSetInfo( Lg, 'cl' ,cl) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'jn' ,jn) + EgtSetInfo( Lg, 'jn2' ,jn2) + EgtSetInfo( Lg, 'jnb' ,jnb) + EgtSetInfo( Lg, 'D_X' ,D_X) + EgtSetInfo( Lg, 'D_X3' ,D_X3) + EgtSetInfo( Lg, 'D_XE' ,D_XE) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'LG' ,LG) + EgtSetInfo( Lg, 'LG2' ,LG2) + EgtSetInfo( Lg, 'LG3' ,LG3) + EgtSetInfo( Lg, 'LM' ,LM) + EgtSetInfo( Lg, 'LA' ,LA) + EgtSetInfo( Lg, 'LA3' ,LA3) + EgtSetInfo( Lg, 'CLC' ,CLC) + EgtSetInfo( Lg, 'LGH' ,LGH) + 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 EdgePullMortiseCyl diff --git a/LuaLibs/EgtDoorsBase.lua b/LuaLibs/EgtDoorsBase.lua new file mode 100644 index 0000000..cae6321 --- /dev/null +++ b/LuaLibs/EgtDoorsBase.lua @@ -0,0 +1,979 @@ +-- +-- 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 +-- +-- EgtDoorsBase.lua by EgalWare s.r.l. 2016.06.22 +-- Doors Base library + +-- 2016.06.22 V1.000 FM First version +-- 2019.10.01 V1.001 FM Add function FindProperty +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.25 V2.001 FM Add function MakeClcPath +-- 2020.09.30 V2.002 FM Fix error on call EgtVerticalDimension or EgtHorizontalDimension into AssignSize function +-- 2020.09.30 V2.003 FM Fix error into AddSurfTmByExtrusion with open paths +-- 2021.05.27 V2.004 FM Manage hatching regions (special) into AddSurfTmByExtrusion +-- 2021.06.08 V2.005 FM Modify function MakeClcPath to clean corner for DiamondShape +-- 2022.01.17 V2.006 FM Add function MakeConeClcPath +-- 2024.02.21 V2.007 FM Add function mm() + +require( 'EgtBase') +require( 'EgtConst') +require( 'EgtLinearDimension') + +-- Tavola per definizione modulo +local EgtDoorsBase = {} + +print( 'EgtDoorsBase started') + + +----------------------------------------------------------------- +-- *** log file id *** +----------------------------------------------------------------- +if not sLogIdFile then + sLogIdFile = nil +end + +----------------------------------------------------------------- +-- *** DDF file scanning *** +----------------------------------------------------------------- +local g_fh = nil +local g_sUnLine = nil +local g_nLine = 0 + +----------------------------------------------------------------- +function OpenFile( sFile) + g_fh = io.open( sFile) + g_nLine = 0 + return g_fh +end + +----------------------------------------------------------------- +function CloseFile() + if not g_fh then return false end + g_fh:close() + g_fh = nil + g_sUnLine = nil + return true +end + +----------------------------------------------------------------- +function GetLine() + -- se c'è linea rifiutata + if g_sUnLine then + local sLine = g_sUnLine + g_sUnLine = nil + return sLine + end + -- altrimenti cerco una nuova linea + while true do + -- leggo la prossima linea + local sLine = g_fh:read( '*l') + g_nLine = g_nLine + 1 + -- se non esiste, esco + if not sLine then return nil end + -- elimino spazi finali (compresi tab e simili) + sLine = EgtTrimRight( sLine) + -- se linea contiene qualcosa + if sLine:len() > 0 then + -- se non ci sono commenti + local nI = sLine:find( '#', 1, true) + if not nI then return sLine end + -- elimino parti di commento + if nI > 1 and + ( sLine:sub( nI-1, nI-1) == ' ' or sLine:sub( nI-1, nI-1) == '\9') then + sLine = EgtTrimRight( sLine:sub( 1, nI-2)) + -- se stringa non vuota + if sLine:len() > 0 then return sLine end + end + end + end +end + +----------------------------------------------------------------- +function UngetLine( sLine) + g_sUnLine = sLine +end + +----------------------------------------------------------------- +function GetLineNumber() + return g_nLine +end + +----------------------------------------------------------------- +-- *** Utilities *** +----------------------------------------------------------------- +function OpenPrbFile( sFile, sOpenMode) + local IdPrbFile = io.open( sFile, sOpenMode) + return IdPrbFile +end + +----------------------------------------------------------------- +function OpenLogFile( sFile, sOpenMode) + sLogIdFile = io.open( sFile, sOpenMode) + return sLogIdFile +end + +----------------------------------------------------------------- +function DoorOutLog( sMessTowrite, nModeWrite) + + -- prima scrivo il log dell'egtcam + if nModeWrite <= 0 then + EgtOutLog( sMessTowrite) + end + + -- poi scrivo il log del file porta + if sLogIdFile and nModeWrite >= 0 then + sLogIdFile:write( sMessTowrite .. '\n') + end +end + +----------------------------------------------------------------- +function CloseLogFile() + if not sLogIdFile then return false end + sLogIdFile:close() + sLogIdFile = nil + return true +end + +function inch( val) + return val * GEO.ONE_INCH +end + +function mm( val) + return val * GEO.ONE_MM +end + +-------------------------------------------------------------------------------- +function MakeClcPath( clc, ccr, CL, nGroup, dThick, bInvertPath, bDiamondShape, nIpo1, nIpo2, nIpo3) + + local tHint = {} + local nPath + local pIni, pEnd, pCen + + -- disegno angolo x-y+ + if not bDiamondShape and ccr and ccr > 0 then -- se devo inserire lo scarico dello spigolo + -- calcolo la distanza del centro che equivale alla distanza di inizio arco + local dDeltaCorner = ccr * 0.1 -- calcolo il 10% del raggio + local dCentrDist = (ccr-dDeltaCorner) * sin(45) + local dArcDist = sqrt((ccr*ccr)-(dCentrDist*dCentrDist)) + dCentrDist + local dMidPoindDist = dDeltaCorner * sin(45) + -- linea iniziale + pIni = Point3d(0,-clc,0) + pEnd = Point3d(0,-dArcDist,0) + local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + -- arco + pIni = pEnd + pCen = Point3d(-dMidPoindDist,dMidPoindDist,0) + pEnd = Point3d(dArcDist,0,0) + local nIdArc = EgtArc3P( nGroup, pIni, pCen, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdArc) + -- linea finale + pIni = pEnd + pEnd = Point3d(clc,0,0) + nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + else + if bDiamondShape then + -- linea iniziale + pIni = Point3d( nIpo2, -nIpo1,0) + pEnd = Point3d(0,0,0) + local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + -- accorcio la linea + EgtTrimExtendCurveByLen( nIdLine,(clc-nIpo3), pIni, GDB_RT.LOC) + -- linea finale + pIni = pEnd + pEnd = Point3d( nIpo2, nIpo1,0) + nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + -- accorcio la linea + EgtTrimExtendCurveByLen( nIdLine,(clc-nIpo3), pEnd, GDB_RT.LOC) + else + -- linea iniziale + pIni = Point3d(0,-clc,0) + pEnd = Point3d(0,0,0) + local nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + -- linea finale + pIni = pEnd + pEnd = Point3d(clc,0,0) + nIdLine = EgtLine( nGroup, pIni, pEnd, GDB_RT.LOC) + table.insert( tHint, nIdLine) + end + end + + nPath = EgtCurveCompo( nGroup, tHint, true) + if nPath then + EgtModifyCurveThickness( nPath, dThick) + EgtSetName( nPath, CL) + if bInvertPath then + -- inverto il percorso + EgtInvertCurve(nPath) + end + end + + return nPath +end + +-------------------------------------------------------------------------------- +function MakeConeClcPath( CLCN, nGroup, dThick, dLengthOri, dMode) + + local tHint = {} + local nPath + local pEnd + local nAuxId + local ptApPoint + local dLongLine = EgtIf( dLengthOri, dLengthOri + 1, 1) + -- versori utilizzati + local vtExtrExit, vtExtr + local vtN2 = Vector3d(0,-1,0) + local vtN3 = Vector3d(1,0,0) + + -- disegno angolo x-y+ + -- sommo i tre versori per avere una direzione media + vtExtrExit = vtN2 + vtN3 + vtExtrExit:normalize() + vtExtr = vtExtrExit + Z_AX() + vtExtr:normalize() + + if dMode < GEO.EPS_SMALL then + -- prima linea discendente + nAuxId = EgtLine( nGroup, Point3d(0,0,0), Point3d(0,0,dThick), GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- seconda linea + ptApPoint = Point3d( 0, -dLongLine, dThick) + nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), ptApPoint, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- creo linea di ritorno + nAuxId = EgtLine( nGroup, ptApPoint, Point3d(0,0,dThick), GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- quarta linea + ptApPoint = Point3d( dLongLine, 0, dThick) + nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), ptApPoint, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- creo linea di ritorno + nAuxId = EgtLine( nGroup, ptApPoint, Point3d(0,0,dThick), GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- ultima linea di distacco (5mm in direzione utensile) + pEnd = Point3d(0,0,dThick) + ( 5 * vtExtr) + nAuxId = EgtLine( nGroup, Point3d(0,0,dThick), pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + else + -- prima linea discendente al valore di dMode + pEnd = Point3d(0,0,-dMode) + nAuxId = EgtLine( nGroup, Point3d(0,0,0), pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- seconda linea + ptApPoint = Point3d( 0, -dLongLine, -dMode) + nAuxId = EgtLine( nGroup, pEnd, ptApPoint, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- creo linea di ritorno + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- quarta linea + ptApPoint = Point3d( dLongLine, 0, -dMode) + nAuxId = EgtLine( nGroup, pEnd, ptApPoint, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- creo linea di ritorno + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- linea discendente a metà spessore - 1 + ptApPoint = pEnd + pEnd = Point3d(0,0,( ( dThick/2) - 1)) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- linea di distacco (pari a dLongLine in direzione utensile) + ptApPoint = pEnd + pEnd = ptApPoint + ( dLongLine * vtExtr) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- linea discendente alla profondità pari allo spessore + ptApPoint = pEnd + pEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), dThick) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- linea discendente inclinata sulla direzione dello spigolo + ptApPoint = pEnd + pEnd = ptApPoint - ( dLongLine * vtExtr) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- risalita a metà spessore + 1 + ptApPoint = pEnd + pEnd = Point3d( ptApPoint:getX(), ptApPoint:getY(), ( ( dThick/2) + 1)) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + -- ultima linea di distacco (5mm in direzione utensile) + ptApPoint = pEnd + pEnd = Point3d(0,0,( ( dThick/2) + 1)) + ( 5 * vtExtr) + nAuxId = EgtLine( nGroup, ptApPoint, pEnd, GDB_RT.GLOB) + table.insert( tHint, nAuxId) + end + + -- trasformo in percorso + if #tHint > 0 then + nPath = EgtCurveCompo( nGroup, tHint, true) + end + + if nPath then + EgtModifyCurveThickness( nPath, 0) + EgtSetName( nPath, CLCN) + -- modifico versore direzione + EgtModifyCurveExtrusion( nPath, vtExtr, GDB_RT.GLOB) + EgtSetInfo( nPath, 'ActiveStopMach', 1) + EgtSetInfo( nPath, 'SetMaxElev', 1) + end + + return nPath +end + +-------------------------------------------------------------------------------- +local function SetUpRegion( nSrfU, pIni, ptMin, ptMax, sNameDwReg, sNameUpReg, bReference, bGenOutput, dThId, vtExtr, bMove) + + local bSurfUp + + if not DGD.Dws then + if bMove then +-- EgtMove( nSrfU, Point3d(0,0,(dThId * vtExtr:getZ())) - ORIG()) + EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) + end + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto + EgtSetName( nSrfU, sNameDwReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = false + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra + EgtSetName( nSrfU, sNameUpReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = true + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfU) + end + else + if DGD.nTypePz == 3 then -- se frame left + if bMove then +-- EgtMove( nSrfU, Point3d((dThId * vtExtr:getX()),0,0) - ORIG()) + EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) + end + if abs( pIni:getX() - ptMin:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto + EgtSetName( nSrfU, sNameDwReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = false + elseif abs( pIni:getX() - ptMax:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra + EgtSetName( nSrfU, sNameUpReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = true + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfU) + end + elseif DGD.nTypePz == 4 then -- se frame right + if bMove then +-- EgtMove( nSrfU, Point3d((dThId * vtExtr:getX()),0,0) - ORIG()) + EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) + end + if abs( pIni:getX() - ptMax:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto + EgtSetName( nSrfU, sNameDwReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = false + elseif abs( pIni:getX() - ptMin:getX()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra + EgtSetName( nSrfU, sNameUpReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = true + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfU) + end + elseif DGD.nTypePz == 5 then -- se frame top + if bMove then +-- EgtMove( nSrfU, Point3d(0,(dThId * vtExtr:getY()),0) - ORIG()) + EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) + end + if abs( pIni:getY() - ptMax:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto + EgtSetName( nSrfU, sNameDwReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = false + elseif abs( pIni:getY() - ptMin:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra + EgtSetName( nSrfU, sNameUpReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = true + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfU) + end + elseif DGD.nTypePz == 6 then -- se frame bottom + if bMove then +-- EgtMove( nSrfU, Point3d(0,(dThId * vtExtr:getY()),0) - ORIG()) + EgtMove( nSrfU, Point3d(dThId * vtExtr) - ORIG()) + end + if abs( pIni:getY() - ptMin:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sotto + EgtSetName( nSrfU, sNameDwReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = false + elseif abs( pIni:getY() - ptMax:getY()) < GEO.EPS_SMALL then -- se geometria è sulla relativa faccia sopra + EgtSetName( nSrfU, sNameUpReg) + EgtSetInfo( nSrfU, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + bSurfUp = true + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfU) + end + end + end + if bGenOutput then + return bSurfUp + end +end + +-------------------------------------------------------------------------------- +function AddSurfTmByExtrusion( ParId, EntId, bSingleGeom, nSpecialGeom, bSideSurf) + + local nIdGeom + local Ls = EgtGetFirstNameInGroup( EgtGetParent(ParId), 'SOLID') + local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) + + if bSingleGeom then + nIdGeom = EntId + else + nIdGeom = EgtGetFirstInGroup( EntId) -- ottengo la prima geometria + end + + if not nSpecialGeom then + nSpecialGeom = 0 + end + local nSpecialGeomMaster = nSpecialGeom + + while nIdGeom do + + local nNextId + local dThId + local bExclude = false + local bReference + local nIdNew + + if bSingleGeom then + nNextId = nil + dThId = EgtCurveThickness( nIdGeom) + bReference = EgtGetInfo( nIdGeom, 'ReferHw', 'b') or false + else + nNextId = EgtGetNext(nIdGeom) + local sNameGeom = EgtGetName( nIdGeom) + if sNameGeom then + sNameGeom = string.lower(sNameGeom) + if sNameGeom == 'flat_up_tmp' or sNameGeom == 'flat_dw_tmp' or sNameGeom == 'flat_up_tmp_sp' or sNameGeom == 'flat_dw_tmp_sp' or + sNameGeom == 'extrusion' or sNameGeom == 'flat_up_blind' or sNameGeom == 'flat_dw_blind' or sNameGeom == 'flat_up_sd_blind' or + sNameGeom == 'flat_dw_sd_blind' then + bExclude = true + end + end + if not bExclude then + dThId = EgtCurveThickness( nIdGeom) + bReference = EgtGetInfo( nIdGeom, 'ReferHw', 'b') or false + end + end + + if not bExclude then + -- recupero versore estrusione in globale + local vtExtr = EgtCurveExtrusion( nIdGeom, GDB_ID.ROOT) + -- recupero versore estrusione in locale + local vtExtrLoc = EgtCurveExtrusion( nIdGeom) + local frEnt = EgtGetGlobFrame( nIdGeom) + local vtMPlane, dDist, dArea = EgtCurveArea( nIdGeom) + -- verifico se è un percorso di hatch + local bHatch = EgtGetInfo( nIdGeom, 'hatch', 'b') + nSpecialGeom = EgtGetInfo( nIdGeom, 'SpecialGeom', 'i') + + -- se è un percorso aperto ed è segnato come hatch creo il percorso di contorno + if not vtMPlane and bHatch and not nSpecialGeom then + + local nId, nId1, nId2, nId3, nId4 + -- faccio gli offset in più e in meno e li unisco con le linee per creare il percorso + nId1 = EgtCopyGlob( nIdGeom, EntId) + EgtOffsetCurve( nId1, 0.5) + nId3 = EgtCopyGlob( nIdGeom, EntId) + EgtOffsetCurve( nId3, -0.5) + -- inverto il percorso 2 + EgtInvertCurve( nId3) + -- prendo i punti da collegare + local pIni = EgtEP( nId1) + local pEnd = EgtSP( nId3) + nId2 = EgtLine( EntId, pIni, pEnd, GDB_RT.LOC) + pIni = EgtEP( nId3) + pEnd = EgtSP( nId1) + nId4 = EgtLine( EntId, pIni, pEnd, GDB_RT.LOC) + -- creo percorso + nId = EgtCurveCompo( EntId, {nId1,nId2,nId3,nId4}, true) + EgtModifyCurveThickness( nId, dThId) + EgtSetInfo( nId, 'hatch', bHatch) + EgtSetInfo( nId, 'SpecialGeom', 3) + end + if not nSpecialGeom then + nSpecialGeom = nSpecialGeomMaster + end + + -- se il percorso è aperto provo a chiudere il percorso + if not vtMPlane then + local _, nNumCurve = EgtCurveDomain( nIdGeom) + -- se ho più curve, provo a chiuderlo + if nNumCurve > 0 then + --faccio la copia del percorso + nIdNew = EgtCopyGlob( nIdGeom, ParId) + EgtSelectObj(nIdNew) + local ptStart = EgtSP( nIdNew) + local ptEnd = EgtEP( nIdNew) + if ptStart and ptEnd then + local nJoin = EgtLine( ParId, ptEnd, ptStart) + if nJoin then + -- unisco + nIdNew, _ = EgtCurveCompoByChain( ParId, {nIdNew, nJoin}, ptStart) + if nIdNew then + vtMPlane, dDist, dArea = EgtCurveArea( nIdNew) + if not vtMPlane then + -- ottengo il piano dalla curva così come è + _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) + EgtErase( nIdNew) + nIdNew = nil + end + else -- ottengo il piano dalla curva così come è + _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) + EgtErase( nJoin) + end + else -- ottengo il piano dalla curva così come è + _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) + EgtErase( nIdNew) + end + else -- ottengo il piano dalla curva così come è + _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) + EgtErase( nIdNew) + end + else -- ottengo il piano dalla curva così come è + _, vtMPlane, dDist = EgtCurveIsFlat( nIdGeom) + end + end + + vtMPlane:toGlob(frEnt) + + local bInvert + if dArea and dArea * ( vtMPlane * vtExtr) < 0 then -- se oraria la inverto + EgtInvertCurve( nIdGeom) + bInvert = true + end + + -- creo le superfici sopra e sotto + local bTrhu + if not DGD.Dws then + bTrhu = ( abs( dThId) > b3Solid:getDimZ() - GEO.EPS_SMALL) + else + if DGD.nTypePz == 5 or DGD.nTypePz == 6 then -- se frames top o bottom + bTrhu = ( abs( dThId) > b3Solid:getDimY() - GEO.EPS_SMALL) + else -- altrimenti frames destro e sinistro + bTrhu = ( abs( dThId) > b3Solid:getDimX() - GEO.EPS_SMALL) + end + end + + if bTrhu then -- se spessore passante creo le superfici di sopra e di sotto + + -- aggiungo estrusione se non è un percorso speciale (da hatching dei componenti cutout) + if nSpecialGeom <= 1 then + local bCanExtrude + -- se è un percorso importato con hatching leggo la nota del percorso + if nSpecialGeom == 1 then + if not bHatch then + bCanExtrude = true + end + else + bCanExtrude = true + end + -- se puù essere fatta estrusione + if bCanExtrude then + local nExtrs = EgtSurfTmByExtrusion( ParId, nIdGeom, vtExtrLoc * dThId) + if nExtrs then + EgtSetName( nExtrs, 'Extrusion') + EgtSetInfo( nExtrs, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + end + end + local nSrfU, nSrfD + if nIdNew then + -- supefice sopra + nSrfU = EgtSurfFlatRegion( ParId, nIdNew) + -- supefice sotto + nSrfD = EgtSurfFlatRegion( ParId, nIdNew) + else + -- supefice sopra + nSrfU = EgtSurfFlatRegion( ParId, nIdGeom) + -- supefice sotto + nSrfD = EgtSurfFlatRegion( ParId, nIdGeom) + end + -- punti massimo e minimo del solido + local ptMin = b3Solid:getMin() + local ptMax = b3Solid:getMax() + local pIni = EgtSP( nIdGeom, GDB_ID.ROOT) + + if nSrfU then + SetUpRegion( nSrfU, pIni, ptMin, ptMax, EgtIf( nSpecialGeom >= 2, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), EgtIf( nSpecialGeom >= 2, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), bReference) + end + if nSrfD then + EgtInvertSurf(nSrfD) + SetUpRegion( nSrfD, pIni, ptMin, ptMax, EgtIf( nSpecialGeom >= 2, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), EgtIf( nSpecialGeom >= 2, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), bReference, false, dThId, vtExtrLoc, true) + end + else + -- aggiungo estrusione se non è un percorso speciale (da percorso di hatching) + if nSpecialGeom <= 1 then + local nExtrs = EgtSurfTmByExtrusion( ParId, nIdGeom, vtExtrLoc * dThId) + if nExtrs then + EgtSetName( nExtrs, 'Extrusion') + EgtSetInfo( nExtrs, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + end + local nSrfU, nSrfD + if nIdNew then + -- supefice sopra + nSrfU = EgtSurfFlatRegion( ParId, nIdNew) + -- supefice sotto + nSrfD = EgtSurfFlatRegion( ParId, nIdNew) + else + -- supefice sopra + nSrfU = EgtSurfFlatRegion( ParId, nIdGeom) + -- supefice sotto + nSrfD = EgtSurfFlatRegion( ParId, nIdGeom) + end + -- punti massimo e minimo del solido + local ptMin = b3Solid:getMin() + local ptMax = b3Solid:getMax() + local pIni = EgtSP( nIdGeom, GDB_ID.ROOT) + local bSurfUp + + if nSrfU then + bSurfUp = SetUpRegion( nSrfU, pIni, ptMin, ptMax, EgtIf( bSpecialGeom, 'FLAT_DW_TMP_SP', 'FLAT_DW_TMP'), EgtIf( bSpecialGeom, 'FLAT_UP_TMP_SP', 'FLAT_UP_TMP'), bReference, true) + end + if nSrfD then +-- if not DGD.Dws then + EgtMove( nSrfD, Point3d(dThId * vtExtrLoc) - ORIG()) +-- EgtMove( nSrfD, Point3d(0,0,(dThId * vtExtrLoc:getZ())) - ORIG()) +-- else +-- if DGD.nTypePz == 3 or DGD.nTypePz == 4 then -- se frame left o right +-- EgtMove( nSrfD, Point3d((dThId * vtExtrLoc:getX()),0,0) - ORIG()) +-- else -- se frame top o bottom +-- EgtMove( nSrfD, Point3d(0,(dThId * vtExtrLoc:getY()),0) - ORIG()) +-- end +-- end + + if bSurfUp then + if bSideSurf then + EgtSetName( nSrfD, 'FLAT_UP_SD_BLIND') + else + EgtSetName( nSrfD, 'FLAT_UP_BLIND') + end + EgtSetInfo( nSrfD, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + elseif not bSurfUp and bSurfUp ~= nil then + if bSideSurf then + EgtSetName( nSrfD, 'FLAT_DW_SD_BLIND') + else + EgtSetName( nSrfD, 'FLAT_DW_BLIND') + end + EgtSetInfo( nSrfD, 'ReferHw', bReference) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + else -- altrimenti geometria con estremi non corrispondenti con il solido, la cancello + EgtErase(nSrfD) + end + end + end + + -- se ho invertito ripristino come precedente + if bInvert then + EgtInvertCurve( nIdGeom) + end + if nIdNew then + EgtErase( nIdNew) + end + if nSpecialGeom and nSpecialGeom == 3 then + EgtErase( nIdGeom) + end + end + + nIdGeom = nNextId + end + + return true +end + +-------------------------------------------------------------------------------- +function AddFlatSurf( ParId, EntId) + + local nIdGeom + local sSurfName + local Ls = EgtGetFirstNameInGroup( EgtGetParent(ParId), 'SOLID') + + nIdGeom = EgtGetFirstInGroup( EntId) -- ottengo la prima geometria + + while nIdGeom do + + sSurfName = EgtGetName( nIdGeom) + local nNextId = EgtGetNext(nIdGeom) + + -- muovo le superfici nel layer SOLID + if sSurfName then + sSurfName = string.lower(sSurfName) + if sSurfName == 'flat_up_tmp' or sSurfName == 'flat_dw_tmp' or sSurfName == 'flat_up_tmp_sp' or sSurfName == 'flat_dw_tmp_sp' or + sSurfName == 'extrusion' or sSurfName == 'flat_up_blind' or sSurfName == 'flat_dw_blind' or sSurfName == 'flat_up_sd_blind' or + sSurfName == 'flat_dw_sd_blind' then + EgtRelocateGlob( nIdGeom, Ls) + end + end + + nIdGeom = nNextId + end + + return true +end + +-------------------------------------------------------------------------------- +function InvertSurfName( ParId) + + local nIdGeom + local sGeomName + + nIdGeom = EgtGetFirstInGroup( ParId) -- ottengo la prima geometria + + while nIdGeom do + + sGeomName = EgtGetName( nIdGeom) + local nNextId = EgtGetNext(nIdGeom) + + -- controllo il nome della geometria + if sGeomName then + sGeomName = string.upper(sGeomName) + if sGeomName == 'FLAT_UP_TMP' then + EgtSetName( nIdGeom, 'FLAT_DW_TMP') + elseif sGeomName == 'FLAT_DW_TMP' then + EgtSetName( nIdGeom, 'FLAT_UP_TMP') + elseif sGeomName == 'FLAT_UP_BLIND' then + EgtSetName( nIdGeom, 'FLAT_DW_BLIND') + elseif sGeomName == 'FLAT_DW_BLIND' then + EgtSetName( nIdGeom, 'FLAT_UP_BLIND') + elseif sGeomName == 'FLAT_UP_SD_BLIND' then + EgtSetName( nIdGeom, 'FLAT_DW_SD_BLIND') + elseif sGeomName == 'FLAT_DW_SD_BLIND' then + EgtSetName( nIdGeom, 'FLAT_UP_SD_BLIND') + end + end + + nIdGeom = nNextId + end + + return true +end + +-------------------------------------------------------------------------------- +local function CreateSizeLayer( ParId, nIdLayer, szLayerName) + if not nIdLayer then + nIdLayer = EgtGroup(ParId,GDB_RT.LOC) + EgtSetName(nIdLayer, szLayerName) + EgtSetColor(nIdLayer,BLACK()) +-- EgtSetStatus( nIdLayer, GDB_ST.OFF) + end + return nIdLayer +end + +-------------------------------------------------------------------------------- +function AssignSize( ParId, nIdLDoor, nTypePiece, nCodeQ, ptP1, ptP2, dValue, bHoriz, nUp, nRigth, cSizeColor, bRadius, sSufx, bAngle, nCustomGrid) + + -- codice valido + if nCodeQ and nCodeQ >= 0 and nCodeQ <= 17 then + + if nCodeQ == 0 and DGD.DIM_DOOR then -- quoto porta + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_DOOR') + elseif nCodeQ == 1 and DGD.DIM_VISION then -- quoto vision cutout + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_VISION') + elseif nCodeQ == 2 and DGD.DIM_LOUVER then -- quoto louver cutout + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_LOUVER') + elseif nCodeQ == 3 and DGD.DIM_LOCK then -- quoto lock + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_LOCK') + elseif nCodeQ == 5 and DGD.DIM_HINGE then -- quoto hinges + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_HINGE') + elseif nCodeQ == 6 and DGD.DIM_MAIL_SLOT then -- quoto mail_slot + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_MAIL_SLOT') + elseif nCodeQ == 7 and DGD.DIM_FLUSH_PULL then -- quoto flush_pull + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_FLUSH_PULL') + elseif nCodeQ == 8 and DGD.DIM_PEEP_HOLE then -- quoto viewer + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_PEEP_HOLE') + elseif nCodeQ == 9 and DGD.DIM_ROLLER_LATCH then -- quoto roller latch + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_ROLLER_LATCH') + elseif nCodeQ == 10 and DGD.DIM_EDGE_PULL then -- quoto edgepull + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_EDGE_PULL') + elseif nCodeQ == 11 and DGD.DIM_FLUSH_BOLT then -- quoto flushbolt + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_FLUSH_BOLT') + elseif nCodeQ == 12 and DGD.DIM_PIVOT then -- quoto pivot + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_PIVOT') + elseif nCodeQ == 14 and DGD.DIM_STRIKE then -- quoto strike + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_STRIKE') + elseif nCodeQ == 17 and DGD.DIM_EPT then -- quoto EPT + nIdLDoor = CreateSizeLayer( ParId, nIdLDoor, 'DIM_EPT') + end + + -- imposto la griglia in base al tipo di pezzo +-- if nTypePiece == 3 or nTypePiece == 4 or nTypePiece == 5 then + if nTypePiece == 3 or nTypePiece == 4 then + EgtSetGridFrame( {{0,0,0},{0,0,1},{0,1,0},{-1,0,0}}) + elseif nTypePiece == 5 or nTypePiece == 6 then + if nCustomGrid then + EgtSetGridFrame( Frame3d( 0,0,0, nCustomGrid)) + else + if nCodeQ == 0 then + EgtSetGridFrame( {{0,DGD.dW,0},{0,-1,0},{0,0,1},{-1,0,0}}) + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + end + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + local dLenghtArrow = min((0.05 * min(DGD.dH,DGD.dW)), abs(0.3 * dValue)) + local dTextSize = min( 30, max( DGD.dW, DGD.dH)) + local dTextDist = 5 + local sLenTxt = EgtNumToString( EgtToUiUnits( dValue),3)..EgtIf(sSufx, sSufx, '') + -- se devo quotare raccordo + if bRadius and nIdLDoor then + local dDistQuote = 50 + dLenghtArrow + local dAmpArc = EgtIf( nRigth ~= 0, dDistQuote*2, dDistQuote*4) + --CreateLinearDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'R', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK()), dValue, dAmpArc) + CreateLinearDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'R', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) + --EgtAlignedDimension( EgtVerticalDimension(nIdLDoor,ptP1, ptP2,{ptP1:getX()+EgtIf( nRigth ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getY(), ptP1:getZ()},sLenTxt,GDB_RT.GRID), EgtIf( cSizeColor, cSizeColor,BLACK()))) + elseif bAngle and nIdLDoor then + dLenghtArrow = abs(0.5 * dValue) + dTextDist = 25 + local dDistQuote = 150 + dLenghtArrow + dTextDist + -- riassegno il valore da stampare perché i gradi non vanno convertiti + sLenTxt = EgtNumToString( dValue)..EgtIf(sSufx, sSufx, '') + CreateAngleDimensionRadial( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dValue, dDistQuote, (dDistQuote*0.25), dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false) , 'A', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) + elseif not bHoriz and nIdLDoor then + local dDistQuote = 50 + dLenghtArrow + if nRigth > 0 then + dDistQuote = dDistQuote + DGD.QXP + elseif nRigth == 0 then + dDistQuote = dDistQuote + DGD.QXM + end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + --CreateLinearDimensionOnY( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nRigth ~= 0, true, false), 'H', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) + local nIdDim = EgtVerticalDimension(nIdLDoor,ptP1, ptP2,{ptP1:getX()+EgtIf( nRigth ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getY(), ptP1:getZ()},sLenTxt,GDB_RT.GRID) + if nIdDim then + EgtSetColor( nIdDim, EgtIf( cSizeColor, cSizeColor,BLACK())) + end + local bBox = EgtGetBBox( ParId, 0) + if nRigth > 0 then + DGD.QXP = bBox:getMax():getX() - ptP1:getX() + elseif nRigth == 0 then + DGD.QXM = ptP1:getX() - bBox:getMin():getX() + end + elseif nIdLDoor then + local dDistQuote = 50 + dLenghtArrow + if nUp > 0 then + dDistQuote = dDistQuote + DGD.QYP + elseif nUp == 0 then + dDistQuote = dDistQuote + DGD.QYM + end + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + --CreateLinearDimensionOnX( nIdLDoor, ptP1, ptP2, sLenTxt, dTextSize, dDistQuote, dLenghtArrow, dTextDist, EgtIf( nUp ~= 0, true, false), 'W', GDB_RT.GRID, EgtIf( cSizeColor, cSizeColor,BLACK())) + local nIdDim = EgtHorizontalDimension(nIdLDoor,ptP1,ptP2,{ptP1:getX(), ptP1:getY()+EgtIf( nUp ~= 0, abs( dDistQuote), -abs( dDistQuote)), ptP1:getZ()}, sLenTxt,GDB_RT.GRID) + if nIdDim then + EgtSetColor( nIdDim, EgtIf( cSizeColor, cSizeColor,BLACK())) + end + local bBox = EgtGetBBox( ParId, 0) + if nUp > 0 then + DGD.QYP = bBox:getMax():getY() - ptP1:getY() + elseif nUp == 0 then + DGD.QYM = ptP1:getY() - bBox:getMin():getY() + end + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + return nIdLDoor + end + + return 0 +end + +-------------------------------------------------------------------------------- +function MatchName ( sToFind, sFind) + + if sToFind and sFind then + local sCompare = string.gsub( sToFind, ' ', '') + if string.lower(sCompare) == string.lower(sFind) then + return true + end + end + + return false +end + +-------------------------------------------------------------------------------- +function FindMaterial ( sToFind, sFind) + + if MatchName( sToFind, sFind) then + return true + end + + return false +end + +-------------------------------------------------------------------------------- +function FindProperty ( tTableToFind, sFind) + + if sFind and tTableToFind and #tTableToFind > 0 then + for i = 1, #tTableToFind do + if MatchName( tTableToFind[i], sFind) then + return true + end + end + end + + return false +end + +----------------------------------------------------------------- +function ResetDoorsLibs() + package.loaded.ConcealedHinge = nil + package.loaded.EdgePullFlat = nil + package.loaded.EdgePullMortiseCyl = nil +-- package.loaded.EgtDoorsBase = nil + package.loaded.EgtDoorsData = nil + package.loaded.EgtDoorsMsg = nil + package.loaded.EPT = nil + package.loaded.FaceDecoration = nil + package.loaded.FlushBolt = nil + package.loaded.FlushPull = nil + package.loaded.Groove = nil + package.loaded.ImportNgeFile = nil + package.loaded._Latch = nil + package.loaded._LatchCorner = nil + package.loaded._LatchStrike = nil + package.loaded.LockMortiseCyl = nil + package.loaded.LouverCutOut = nil + package.loaded.MachiningBase = nil + package.loaded.MailSlot = nil + package.loaded._Mortise = nil + package.loaded._MortiseCorner = nil + package.loaded.MortiseHinge = nil + package.loaded.OverHead = nil + package.loaded._OPivot = nil + package.loaded._OverHeadArm = nil + package.loaded.OverHeadArm = nil + package.loaded._OverHeadPocket = nil + package.loaded.OverHeadPocket = nil + package.loaded.Pivot = nil + package.loaded._PivotL = nil + package.loaded.Rabbet = nil + package.loaded.RollerLatch = nil + package.loaded.Strike = nil + package.loaded._Strike = nil + package.loaded.Viewer = nil + package.loaded.VisionCutOut = nil + package.loaded.Machining = nil + package.loaded.CurrCamInfo = nil + package.loaded.CurrDoorsCustomData = nil +end + +return EgtDoorsBase diff --git a/LuaLibs/EgtDoorsData.lua b/LuaLibs/EgtDoorsData.lua new file mode 100644 index 0000000..e77e3c6 --- /dev/null +++ b/LuaLibs/EgtDoorsData.lua @@ -0,0 +1,228 @@ +-- +-- 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 +-- +-- EgtDoorsData.lua by EgalWare s.r.l. 22.06.2016 +-- Doors Data global + +-- 2018.11.30 V1.001 FM Add variable DGD.NOBVROT to manage the bevel rotation on particular hardware: roller latch +-- 2019.10.15 V1.002 FM Add variables DGD.tDecorations and DGD.Material +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.11.22 V2.001 FM Add vadiables to new profiles section on all sides +-- 2022.07.27 V2.002 FM Modification to use compiled code + +-- Tavola per definizione modulo +local EgtDoorsData = {} + +print( 'EgtDoorsData started') + +----------------------------------------------------------------- +-- Costanti +COS3 = 0.99862953475457387378449205843944 +SIN3 = 0.05233595624294383272211862960908 +TAN3 = 0.05240777928304120403880582447398 + + +----------------------------------------------------------------- +-- Dati generali da file DDF +--if not DGD then +-- DGD = {} +--end + +----------------------------------------------------------------- +function ResetDoorsGlobDataAssembly() + -- Dati generali + DGD.EGR = 0 -- identificativo codice errore globale + DGD.EGM = '' -- messaggi errori globali +end + +----------------------------------------------------------------- +function ResetDoorsGlobData( bImportdxf) + -- Dati generali + DGD.ERR = 0 -- identificativo codice errore + DGD.ERM = '' -- messagi errore + DGD.EMC = '' -- errori di macchina (lavorazioni) + DGD.PZ = GDB_ID.NULL -- identificativo pezzo porta + DGD.bProoduce = true -- flag produzione pezzo + DGD.bMM = true -- flag mm/pollici + DGD.sCode = '' -- codice porta + DGD.tOrder = {} -- tabella con dati dell'ordine + DGD.tOptions = {} -- tabella con dati delle opzioni + DGD.sDate = '' -- data + DGD.dT = 0 -- spessore + if not bImportdxf then + DGD.dW = 0 -- larghezza + DGD.dH = 0 -- altezza + DGD.sSwing = '' -- tipo apertura LH/RH/LHR/RHR/ ... + DGD.sSecSide = '' -- disposizione lato secure UP o DN quando non ci sono profili bevel + DGD.tProfs = {} -- tabella con dati profili ( .trimming, .machining, .offset) + end + DGD.Pressure = 0 -- pressione + DGD.sAliasSwng = '' -- alias tipo di apertura + DGD.tPosition = {} -- posizione rispetto a porta principale + DGD.tSizeLayer = {} -- tabella layer delle quotature + DGD.Material = '' -- Materiale porta (parametri speciali) + DGD.Properties = {} -- proprietà porta (parametri speciali) + DGD.tVisions = {} -- tabella con dati sfinestrature vision ( .shape, ...) + DGD.tLouvers = {} -- tabella con dati sfinestrature louver ( .lenght, ...) + DGD.tMailSlots = {} -- tabella con dati sfinestrature mail_slot ( .template, ...) + DGD.tViewers = {} -- tabella con dati spioncini ( .template, .position, ...) + DGD.tFlushPulls = {} -- tabella con dati sfinestrature flush pull ( .template, .position, .back_set, ...) + DGD.tHinges = {} -- tabella con dati cerniere ( .template, .position, .back_set, .thickness) + DGD.tEPTs = {} -- tabella con dati EPT ( .template, .toptocl, .facetocl, .thickness) + DGD.tLocks = {} -- tabella con dati serrature ( .template, .position, .back_set) + DGD.tFlushBolts = {} -- tabella con dati flush_bolt ( .template, .position, ...) + DGD.tEdgePulls = {} -- tabella con dati edge_pull ( .template, .position, ...) + DGD.tRollerLatchs = {} -- tabella con dati roller_latch ( .template, .side, .position, ...) + DGD.tPivots = {} -- tabella con dati pivot ( .template, .side, .position, ...) + DGD.tStopsAndClosers = {} -- tabella con dati stop and closer ( .template, .position, ...) + DGD.tOHeads = {} -- tabella con dati over head ( .template, .position, ...) + DGD.tStrikes = {} -- tabella con dati strike ( .template, .position, .back_set) + DGD.tGrooves = {} -- tabella con dati groove ( .template, .type, ...) + DGD.tRabbets = {} -- tabella con dati rabbet ( .template, .type, ...) + DGD.tDecorations = {} -- tabella con dati decoration ( .template, .depth, ...) + -- Posizione serratura e flag porta a spinta + DGD.Lock = '' -- 'L' = left, 'R' = right + DGD.Push = false -- true/false + DGD.Position = 0 -- posizione di inserimento della ferramenta + -- posizioni supplementari aggregatore + DGD.PosXItem = 0 -- posizione supplementare aggregatore (per alcuni tipi di ferramenta) + DGD.PosYItem = 0 -- posizione supplementare aggregatore (per alcuni tipi di ferramenta) + DGD.PosZItem = 0 -- posizione supplementare aggregatore (per alcuni tipi di ferramenta) + DGD.PosDir = 1 -- verso di spostamento (positiva/negativa) applicato a posizione supplementare aggregatore + -- variabili per gestire la rotazione delle geometrie su bevel + -- (per quegli item che ruotano tutte le geometrie in esso definite, come ad esempio il roller latch) + DGD.NOBVROT = false -- blocca la rotazione su lato vebel + DGD.LSREF = false -- indica che la geometria base è latch strike, cioè sborda + -- valore posizionamento in Z geometrie con frame exterior + DGD.dZedExtFrame = 0 + -- valore posizionamento in X geometrie con frame exterior + DGD.dSideExtFrame = 0 + -- valore larghezza ribasso su frame exterior laterali con sill + DGD.dWidthRabbet = 0 + -- Coordinate estremi porta + DGD.Lut = 0 -- sinistra sopra alto X di P7 + DGD.Lub = 0 -- sinistra sopra basso X di P1 + DGD.Ldt = 0 -- sinistra sotto alto X di P10 + DGD.Ldb = 0 -- sinistra sotto basso X di P4 + DGD.Lm = 0 -- sinistra medio X di P5 e P11 + DGD.Lmb = 0 -- sinistra medio X di P5 + DGD.Lmt = 0 -- sinistra medio X di P11 + DGD.Rut = 0 -- destra sopra alto X di P8 + DGD.Rub = 0 -- destra sopra basso X di P2 + DGD.Rdt = 0 -- destra sotto alto X di P9 + DGD.Rdb = 0 -- destra sotto basso X di P3 + DGD.Rm = 0 -- destra medio X di P6 e P12 + DGD.Rmb = 0 -- destra medio X di P6 + DGD.Rmt = 0 -- destra medio X di P12 + DGD.Lua = 0 -- sinistra sopra arco X di P13 + DGD.Lda = 0 -- sinistra sotto arco X di P16 + DGD.Lma = 0 -- sinistra medio arco X di P17 + DGD.Rua = 0 -- destra sopra arco X di P14 + DGD.Rda = 0 -- destra sotto arco X di P15 + DGD.Rma = 0 -- destra medio arco X di P18 + DGD.Bul = 0 -- inferiore sopra sinistra Y di P1 + DGD.Bur = 0 -- inferiore sopra destra Y di P2 + DGD.Bdl = 0 -- inferiore sotto sinistra Y di P4 + DGD.Bdr = 0 -- inferiore sotto destra Y di P3 + DGD.Bm = 0 -- inferiore medio Y di P5 e P6 + DGD.Bml = 0 -- inferiore medio Y di P5 + DGD.Bmr = 0 -- inferiore medio Y di P6 + DGD.Tul = 0 -- superiore sopra sinistra Y di P7 + DGD.Tur = 0 -- superiore sopra destra Y di P8 + DGD.Tdl = 0 -- superiore sotto sinistra Y di P10 + DGD.Tdr = 0 -- superiore sotto destra Y di P9 + DGD.Tm = 0 -- superiore medio Y di P11 e P12 + DGD.Tml = 0 -- superiore medio Y di P11 + DGD.Tmr = 0 -- superiore medio Y di P12 + DGD.Aul = 0 -- curva sopra sinistra Y di P13 + DGD.Aur = 0 -- curva sopra destra Y di P14 + DGD.Adl = 0 -- curva sotto sinistra Y di P16 + DGD.Adr = 0 -- curva sotto destra Y di P15 + DGD.Aml = 0 -- curva medio sinistra Y di P17 + DGD.Amr = 0 -- curva medio destra Y di P18 + DGD.Aut = 0 -- curva sopra alto Y di P19 + DGD.Adt = 0 -- curva sotto alto Y di P20 + DGD.Amt = 0 -- curva medio alto Y di P21 + DGD.Cmu = 0 -- curva medio alto top X di P19 + DGD.Cmd = 0 -- curva medio alto bot X di P20 + DGD.Cmm = 0 -- curva medio alto med X di P21 + DGD.RMa = 0 -- curva max destra X di P22 + DGD.LMa = 0 -- curva max sinistra X di P23 + DGD.AMr = 0 -- curva max destra Y di P22 + DGD.AMl = 0 -- curva max sinistra Y di P23 + DGD.rma = 0 -- curva min destra X di P24 + DGD.lma = 0 -- curva min sinistra X di P25 + DGD.amr = 0 -- curva min destra Y di P24 + DGD.aml = 0 -- curva min sinistra Y di P25 + DGD.Dpu = 0 -- Delta proiez angolo sopra Y delta + DGD.Dpd = 0 -- Delta proiez angolo sotto Y delta + DGD.Dpm = 0 -- Delta proiezione angolo Y delta medio + DGD.Ult = 0 -- sopra sinistra alto Z di P7 + DGD.Ulb = 0 -- sopra sinistra basso Z di P1 + DGD.Urt = 0 -- sopra destra alto Z di P8 + DGD.Urb = 0 -- sopra destra basso Z di P2 + DGD.Dlt = 0 -- sotto sinistra alto Z di P10 + DGD.Dlb = 0 -- sotto sinistra basso Z di P4 + DGD.Drt = 0 -- sotto destra alto Z di P9 + DGD.Drb = 0 -- sotto destra basso Z di P3 + DGD.Mlt = 0 -- medio sinistra alto Z di P11 + DGD.Mlb = 0 -- medio sinistra basso Z di P5 + DGD.Mrt = 0 -- medio destra alto Z di P12 + DGD.Mrb = 0 -- medio destra basso Z di P6 + DGD.Ula = 0 -- sopra sinistra arco Z di P13 + DGD.Ura = 0 -- sopra destra arco Z di P14 + DGD.Dla = 0 -- sotto sinistra arco Z di P16 + DGD.Dra = 0 -- sotto destra arco Z di P15 + DGD.Mla = 0 -- medio sinistra arco Z di P17 + DGD.Mra = 0 -- medio destra arco Z di P18 + -- variabile top porta con angolo + DGD.Tpa = nil + -- variabili per lati porta lavorati + DGD.MHS = 0 -- machine hinge side + DGD.MLS = 0 -- machine lock side + DGD.MTS = 0 -- machine top side + DGD.MBS = 0 -- machine bottom side + -- variabili per punti e direzioni porta + DGD.A1 = 0 + DGD.A2 = 0 + DGD.A3 = 0 + DGD.A4 = 0 + DGD.A5 = 0 + DGD.A6 = 0 + DGD.A7 = 0 + DGD.A8 = 0 + -- variabili per quotature + DGD.QXP = 0 + DGD.QXM = 0 + DGD.QYP = 0 + DGD.QYM = 0 + -- variabile conteggio probe + DGD.CPR = 0 + DGD.DPR = 15 + -- variabile match profilo edge break (EB) + DGD.EBP = '' + -- variabile forzatura sbordo lato narrow del tipo hardware Groove + DGD.GRS = nil + -- variabile settata dal prod. 0: nessuna tastatura completa; 1: tastatura completa, fase tastatura porta attivata; 2: tastatura completa: fase generazione porta + -- DGD.PROBE = 0 + -- Flags + -- tipo esecuzione (se non impostato default entrambe) + if not DGD.MachEn then + DGD.MachEn = 2 -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + end + -- Inactive doors con lato bevel invertito automaticamente + DGD.RevInBv = 0 -- 0 non invertito automaticamente, 1 invertito automaticamente + -- Swing drive disposition ( enable or disable) to calculate disposition ( only without bevel profiles) + DGD.SwDD = 1 -- 0 upper and lower geometries found drive the disposition; 1 swing drive disposition +end + +return EgtDoorsData diff --git a/LuaLibs/EgtDoorsMsg.lua b/LuaLibs/EgtDoorsMsg.lua new file mode 100644 index 0000000..56590fc --- /dev/null +++ b/LuaLibs/EgtDoorsMsg.lua @@ -0,0 +1,597 @@ +-- +-- 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 +-- +-- EgtDoorsMsg.lua by EgalWare s.r.l. 22.06.2016 +-- Doors messages + +-- 2019.10.18 V2.000 FM Manage use Materials + +-- Tavola per definizione modulo +local EgtDoorsMsg = {} + +print( 'EgtDoorsMsg started') + +if EgtGetLanguage() == 'ITA' then + EgtDoorsMsg[400] = " Il diametro utensile %s: %s deve essere uguale o maggiore di: %s. Controllare gli utensili" + EgtDoorsMsg[401] = " Il parametro %s: %s deve essere maggiore di 0\n Verificare il parametro nel file: %s " + EgtDoorsMsg[402] = " Il parametro %s: %s deve essere maggiore del diametro utensile(%s): %s\n Verificare gli utensili o il parametro nel file: %s " + EgtDoorsMsg[403] = " Il parametro %s: %s deve essere compreso tra i valori minimo: %s e massimo: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[404] = " Il parametro %s: %s deve essere maggiore o uguale a 0\n Verificare il parametro nel file: %s " + EgtDoorsMsg[405] = " Il parametro %s: %s deve essere maggiore o uguale del diametro utensile: %s\n Verificare gli utensili o il parametro nel file: %s " + EgtDoorsMsg[406] = " Il parametro %s: %s deve essere minore del parametro %s: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[407] = " Il parametro %s: %s deve essere maggiore del parametro %s: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[408] = " Errore! Mancano i parametri delle dimensione L e W o R nel file ddf" + EgtDoorsMsg[409] = " Il parametro interasse fori %s: %s deve essere maggiore del diametro foro maniglia: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[410] = " Il parametro %s: %s deve essere maggiore o uguale della somma tra %s+%s: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[411] = " Errore! File (lua o nge) non riconosciuto: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[412] = " Errore! Impossibile importare il file geometrico: %s. Verificare il file nge " + EgtDoorsMsg[413] = " Errore! La geometria: %s del gruppo %s: %s, ha la nota SideDoor sconosciuta: %s\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[414] = " Errore! La Geometria: %s del gruppo %s: %s, non ha nessuna nota SideDoor specificata\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[415] = " Errore! La geometria: %s profilo %s ha la nota InserPoint sconosciuta: %s\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[416] = " Errore! La Geometria: %s profilo %s non ha nessuna nota InserPoint specificata\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[417] = " Il parametro %s: %s accetta solo valore: 0, 1 o -1\n Verificare il parametro nel file: %s " + EgtDoorsMsg[418] = " Errore! La geometria: %s dello spioncino: %s, ha la nota SideDoor sconosciuta: %s\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[419] = " Errore! La Geometria: %s dello spioncino: %s, non ha nessuna nota SideDoor specificata\n Verificare i file nge importati nel ddf: %s " + EgtDoorsMsg[420] = " Il parametro interasse fori %s: %s deve essere maggiore del diametro spioncino: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[421] = " Errore! Mancano i parametri delle dimensione L e W o R\n Verificare i parametri nel file: %s " + EgtDoorsMsg[422] = " Il parametro %s: %s deve essere maggiore o uguale del parametro %s: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[423] = " Il parametro %s: %s è troppo grande e fa debordare la cava interna, max valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[424] = " Il parametro %s: %s è troppo piccolo e fa debordare la cava interna, min valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[425] = " Concatenamento percorsi inversi non riuscito\n Inviare il file ddf e il file %s al vostro servizio di assistenza " + EgtDoorsMsg[426] = " Concatenamento percorsi non riuscito\n Inviare il file ddf e il file %s al vostro servizio di assistenza " + EgtDoorsMsg[427] = " Creazione percorso composito non riuscito\n Inviare il file ddf e il file %s al vostro servizio di assistenza " + EgtDoorsMsg[428] = " Non è ammesso l'inserimento cerniera Mortise: %s sul lato cerniere con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[429] = " Non è ammesso l'inserimento cerniera Concealed: %s sul lato cerniere con profilo bisello, bullnose o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[430] = " Non è ammesso l'inserimento serratura: %s sul lato serratura con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[431] = " Non è ammesso l'inserimento edge pull: %s sul lato serratura con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[432] = " Impossibile inserire un Over Head Arm: %s. Il Parametro H: %s è più grande o uguale dello spessore porta: %s\n Verificare il file ddf e il file %s" + EgtDoorsMsg[433] = " Lo spessore porta %s è troppo elevato per il raggio profilo %s: %s. Verificare il file ddf " + EgtDoorsMsg[434] = " Errore apertura file ddf. Verificare che file ddf esista e non sia danneggiato" + EgtDoorsMsg[435] = " Errore nella lettura Unità di misura. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[436] = " Errore nella lettura Codice. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[437] = " Errore nella lettura Ordine. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[438] = " Errore nella lettura Data. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[439] = " Errore nella lettura Dimensioni. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[440] = " Errore nella lettura Brandeggio: %s. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[441] = " Errore nella lettura Profili: parametro overmaterial mancante. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[442] = " Nessun VisionCutOut trovato" + EgtDoorsMsg[443] = " Nessun LouverCutOut trovato" + EgtDoorsMsg[444] = " Nessun MailSlot trovato" + EgtDoorsMsg[445] = " Nessun Viewer trovato" + EgtDoorsMsg[446] = " Nessun Flush Pull trovato" + EgtDoorsMsg[447] = " Nessun Hinges trovato" + EgtDoorsMsg[448] = " Nessun Lock trovato" + EgtDoorsMsg[449] = " Nessun Flush Bolt trovato" + EgtDoorsMsg[450] = " Nessun Edge Pull trovato" + EgtDoorsMsg[451] = " Nessun Roller Latch trovato" + EgtDoorsMsg[452] = " Nessun Pivot trovato" + EgtDoorsMsg[453] = " Nessun Stop And Closer trovato" + EgtDoorsMsg[454] = " Errore nella creazione della Porta. Verificare il file ddf" + EgtDoorsMsg[455] = " Errore nelle lavorazioni della Porta. Verificare il file ddf, utensili e lavorazioni" + EgtDoorsMsg[456] = " Il parametro %s: %s deve essere minore o uguale del parametro %s: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[457] = " Impossibile caricare il file geometrico personalizzato: %s. Verificare il file nge " + EgtDoorsMsg[458] = " Errore. La ferramenta tipo %s è ammessa solo su una porta inattiva, tipo porta corrente: %s. Verificare il file ddf " + EgtDoorsMsg[459] = " Il parametro %s: %s deve essere maggiore di 0 e minore o uguale del diametro utensile: %s\n Verificare gli utensili o il parametro nel file: %s " + EgtDoorsMsg[460] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità cava piastrina: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[461] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità cava mortasa: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[462] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità cava piastrina: %s perché è maggiore della massima lavorazione dell'utensile anti scheggia: %s " + EgtDoorsMsg[463] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità del foro: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[464] = " Impossibile inserire un pivot tipo center Hung: %s sul profilo cerniere tipo Bevel: %s " + EgtDoorsMsg[465] = " Impossibile inserire un pivot tipo intermediate: %s sul profilo cerniere tipo bullnose o concavo: %s " + EgtDoorsMsg[466] = " Attenzione! (%s) Non è stata trovata nessuna lavorazione all'indice: %s associata alla geometria: %s\n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[467] = " Attenzione! (%s) Impossibile impostare la lavorazione: %s all'indice: %s associata alla geometria: %s\n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[468] = " Attenzione! (%s) Impossibile acquisire i parametri dalla lavorazione: %s all'indice: %s associata alla geometria: %s \n Verificare la lavorazione \n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[469] = " Attenzione! (%s) Impossibile acquisire l'utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare la lavorazione \n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[470] = " Attenzione! (%s) Impossibile acquisire il diametro utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare i dati utensile \n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[471] = " Attenzione! (%s) Nome geometria: %s non presente o disabilitata in MTable \n Verificare la MTable \n Verrà utilizzato il diametro utensile: %s definito nel modello\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[472] = " Attenzione! (%s) Impossibile acquisire massimo materiale utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare i dati utensile \n Verrà utilizzato il diametro utensile definito nel modello: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[473] = " Attenzione! (%s) Impossibile acquisire massimo materiale utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare i dati utensile \n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[474] = " Errore nel posizionamento grezzo sulla tavola" + EgtDoorsMsg[475] = " Errore nella creazione delle lavorazioni della macchina: %s Il file cnc non verrà generato per questa macchina" + EgtDoorsMsg[476] = "Errore" + EgtDoorsMsg[477] = "ERRORE" + EgtDoorsMsg[478] = "Errore nella generazione del codice CN della macchina: %s. Verificare se ci sono tutti gli utensili richiesti nel file di SetUp: %s" + EgtDoorsMsg[479] = "Porta ribaltata: Secure in alto" + EgtDoorsMsg[480] = "Porta normale: Keyway in alto" + EgtDoorsMsg[481] = ", Top a destra" + EgtDoorsMsg[482] = ", Top a sinistra" + EgtDoorsMsg[483] = " Lavorazione nulla o non definita su geometria: %s id geometria: %s Verificare MTable\n" + EgtDoorsMsg[484] = " Errore! Lavorazione: %s non esistente o non valida ( associata alla geometria: %s id geometria: %s)\n Verificare MTable o MachDb" + EgtDoorsMsg[485] = " Errore! Impossibile inserire o applicare la lavorazione: %s alla geometria: %s id geom: %s\n Verificare la lavorazione e la geometria" + EgtDoorsMsg[486] = "Errore nel caricamento dati CAM presenti nel file: %s" + EgtDoorsMsg[487] = "Errore! File %s: %s non trovato o non leggibile" + EgtDoorsMsg[488] = "Attenzione! Macchina: %s non trovata" + EgtDoorsMsg[489] = "Errore! Dati macchina non validi nel file: %s" + EgtDoorsMsg[490] = "Errore! Tabella MTable non configurate nel file: %s" + EgtDoorsMsg[491] = "Errore! Nome macchina: %s non presente in MTable" + EgtDoorsMsg[492] = " Attenzione! Generazione CN della macchina: %s è disabilitato dai settaggi della MTable" + EgtDoorsMsg[493] = " Nessuna lavorazione per macchina: %s con numero pezzo: %s nome pezzo: %s" + EgtDoorsMsg[494] = " Inizio lavorazioni su macchina: %s" + EgtDoorsMsg[495] = "Disposizione Porta" + EgtDoorsMsg[496] = " alla geometria (numero): " + EgtDoorsMsg[497] = " Saltata geometria: " + EgtDoorsMsg[498] = "Generazione Lavorazioni conclusa " + EgtDoorsMsg[499] = " Attenzione! tabella MTable non presente nel progetto corrente" + EgtDoorsMsg[500] = " Attenzione! Porta non Inattiva con opposti profili tipo bevel. Brandeggio: %s Lato cerniere: %s Lato serratura: %s" + EgtDoorsMsg[501] = "Attenzione" + EgtDoorsMsg[502] = "ATTENZIONE" + EgtDoorsMsg[503] = " Attenzione! (%s) Nome geometria: %s non presente o disabilitata in MTable \n Verificare la MTable \n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[504] = " Attenzione! (%s) Non è stata trovata nessuna lavorazione all'indice: %s associata alla geometria: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[505] = " Attenzione! (%s) Impossibile impostare la lavorazione: %s all'indice: %s associata alla geometria: %s\n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[506] = " Attenzione! (%s) Impossibile acquisire i parametri dalla lavorazione: %s all'indice: %s associata alla geometria: %s \n Verificare la lavorazione \n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[507] = " Attenzione! (%s) Impossibile acquisire l'utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare la lavorazione \n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[508] = " Attenzione! (%s) Impossibile acquisire il diametro utensile dalla lavorazione: %s all'indice: %s associata alla geometria: %s\n Verificare i dati utensile \n Nessuna correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[509] = " Attenzione! (%s) MTable non trovata nelle note del progetto\n Verificare il progetto\n Nessuna correzione diametro utensile ne correzione della profondità della geometria verrà effettuata" + EgtDoorsMsg[510] = ", Distanziale in Y" + EgtDoorsMsg[511] = "Disp" + EgtDoorsMsg[512] = "Parametri incongruenti nel file ddf in prossimità della lina: %s della ferramenta tipo: %s" + EgtDoorsMsg[513] = "Vision ritaglio" + EgtDoorsMsg[514] = "Louver ritaglio" + EgtDoorsMsg[515] = "Mail slot" + EgtDoorsMsg[516] = "Viewer" + EgtDoorsMsg[517] = "Flush pull" + EgtDoorsMsg[518] = "Hinge" + EgtDoorsMsg[519] = "Lock" + EgtDoorsMsg[520] = "FlushBolt" + EgtDoorsMsg[521] = "EdgePull" + EgtDoorsMsg[522] = "Roller latch" + EgtDoorsMsg[523] = "Pivot" + EgtDoorsMsg[524] = "StopAndCloser" + EgtDoorsMsg[525] = "Over Head Stop_Closer" + EgtDoorsMsg[526] = " Nessun Over Head trovato" + EgtDoorsMsg[527] = " Il parametro %s: %s è troppo grande e fa debordare il foro, max valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[528] = " Disposizione per Cms-PF122R8RR :" + EgtDoorsMsg[529] = " Disposizione per Multiax-N1216 :" + EgtDoorsMsg[530] = " Errore su ricerca gruppo tavola MOBILE or FIXED" + EgtDoorsMsg[531] = " Errore in disposizione ventose: insufficienti ventose attive. Verificare le sfinestrature o lavorazioni di hardware in prossimità delle ventose" + EgtDoorsMsg[532] = " Errore in disposizione ventose: troppe ventose disattivate sulla parte destra. Verificare le sfinestrature o lavorazioni di hardware in prossimità delle ventose" + EgtDoorsMsg[533] = " Errore in disposizione ventose: troppe ventose disattivate nella parte centrale della porta. Verificare le sfinestrature o lavorazioni di hardware in prossimità delle ventose" + EgtDoorsMsg[534] = " Errore in disposizione ventose: troppe ventose disattivate nella parte sinistra. Verificare le sfinestrature o lavorazioni di hardware in prossimità delle ventose" + EgtDoorsMsg[535] = " Nessun Strike trovato" + EgtDoorsMsg[536] = " Nessun Groove trovato" + EgtDoorsMsg[537] = " Nessun Rabbet trovato" + EgtDoorsMsg[538] = "Strike" + EgtDoorsMsg[539] = "Groove" + EgtDoorsMsg[540] = " Impossibile inserire la Groove: %s. Il Parametro H: %s è più grande o uguale dello spessore porta: %s\n Verificare il file ddf e il file %s" + EgtDoorsMsg[541] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità del percorso anti scheggia: %s perché è maggiore della massima lavorazione dell'utensile anti scheggia: %s " + EgtDoorsMsg[542] = " Attenzione! (%s) nel modello: %s la larghezza gola: %s è minore dello spessore lama: %s " + EgtDoorsMsg[543] = " il DDF non ha nessun parametro: Secure" + EgtDoorsMsg[544] = " Errore! parametri definizione porta incongruenti. Brandeggio: %s tipo disposizione bevel: %s parametro disposizione SECURE: %s. Verificare il file ddf" + EgtDoorsMsg[545] = " Errore! parametri definizione porta mancanti. profilo bevel non trovato e parametro SECURE non trovato. Verificare il file ddf" + EgtDoorsMsg[546] = " Non è ammesso l'inserimento gola Rabbet sul lato cerniere con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[547] = " Non è ammesso l'inserimento gola Rabbet sul lato serratura con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[548] = " Errore! Parametro side della ferramenta rabbet è incongruente: %s. Verificare il file ddf " + EgtDoorsMsg[549] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità cava: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[550] = "Rabbet" + EgtDoorsMsg[551] = " Errore negli import attrezzaggi utensili\n Verificare se è stato definito un file di attrezzaggio nella sezione SETUP e inserito nel file CurrCamInfo.lua" + EgtDoorsMsg[552] = " Errore nell'attrezzaggio utensili: %s" + EgtDoorsMsg[553] = " Lista utensili non attrezzati o mancanti: " + EgtDoorsMsg[554] = " File di setup vuoto o non caricato: %s" + EgtDoorsMsg[555] = "nessuno" + EgtDoorsMsg[556] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità cava piastrina: %s perché è maggiore della massima lavorazione dell'utensile chisel: %s " + EgtDoorsMsg[557] = " Nessun EPT trovato" + EgtDoorsMsg[588] = "EPT" + EgtDoorsMsg[589] = " Non è ammesso l'inserimento EPT: %s sul lato cerniere con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[590] = " Errore! parametri definizione porta mancanti. Questa porta è priva di profilo bevel e il parametro SECURE non trovato nel file DDF e non trovato nel file CurrCamInfo" + EgtDoorsMsg[591] = " Errore! Parametro: %s non definito o parametro type nel ddf non pertinente. Verificare il file del modello: %s o il parametro Type nel ddf della porta" + EgtDoorsMsg[592] = " Errore! Parametro: %s non definito. Verificare il file ddf della porta" + EgtDoorsMsg[593] = " Attenzione! %s puo essere applicato solo sul lato %s. Verificare il file ddf " + EgtDoorsMsg[594] = " Errore! %s non può essere applicato sul lato %s. Verificare il file ddf " + EgtDoorsMsg[595] = " lavorazione: " + EgtDoorsMsg[596] = " fase: " + EgtDoorsMsg[597] = " Errore! File di tabella non trovato: %s " + EgtDoorsMsg[598] = " Errore! Impossible inserire o applicare la lavorazione: %s alla geometria: %s id geom: %s\n Id errore: %s Errore: %s\n Verificare la lavorazione e la geometria" + EgtDoorsMsg[599] = " Nessuna porta trovata" + EgtDoorsMsg[600] = " Nessuna porta secondaria trovata" + EgtDoorsMsg[601] = " Nessun telaio sinistro trovato" + EgtDoorsMsg[602] = " Nessun telaio destro trovato" + EgtDoorsMsg[603] = " Nessun telaio top trovato" + EgtDoorsMsg[604] = " Errore! Modelli ferramenta non in sequenza. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[605] = "Sinistro" + EgtDoorsMsg[606] = "Destro" + EgtDoorsMsg[607] = "Superiore" + EgtDoorsMsg[608] = "Soglia" + EgtDoorsMsg[609] = " Errore! Definizione parametri telaio incongruenti. Lato pezzo: %s tipo pezzo: %s Serraura su lato: %s. Check ddf file" + EgtDoorsMsg[610] = "Telaio ribaltato: Secure in alto" + EgtDoorsMsg[611] = "Telaio normale: Keyway in alto" + EgtDoorsMsg[612] = " Attenzione! (%s) nel modello: %s è stato ridotto la profondità del percorso ripresa spigoli: %s perché è maggiore della massima lavorazione dell'utensile ripresa spigoli: %s " + EgtDoorsMsg[613] = " Errore nella lettura Profili: parametro raggio o angolo mancante. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[614] = " Errore nella lettura Profili: raggio troppo piccolo. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[615] = " Errore nella lettura Profili: profili laterali non corrispondono con profilo ad arco. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[616] = " Errore! Altezza pezzo (%s) %s + sovramateriale %s: %s eccede max altezza configurata - traslazione in X %s: %s (nel file CurrCamInfo)." + EgtDoorsMsg[617] = " Errore! Altezza pezzo (%s) %s + sovramateriale %s: %s è inferiore min altezza configurata - traslazione in X %s: %s (nel file CurrCamInfo)." + EgtDoorsMsg[618] = " Errore! Larghezza pezzo (%s) %s + doppio sovramateriale %s: %s eccede max larghezza configurata - traslazione in Y %s: %s (nel file CurrCamInfo)." + EgtDoorsMsg[619] = " Errore! Larghezza pezzo (%s) %s + doppio sovramateriale %s: %s è inferiore min larghezza configurata - traslazione in X %s: %s (nel file CurrCamInfo)." + EgtDoorsMsg[620] = " Errore! Spessore pezzo (%s): %s eccede max spessore configurato: %s (nel file CurrCamInfo)." + EgtDoorsMsg[621] = " Errore! Spessore pezzo (%s): %s inferiore min spessore configurato: %s (nel file CurrCamInfo)." + EgtDoorsMsg[622] = " Porta" + EgtDoorsMsg[623] = " Telaio" + EgtDoorsMsg[624] = " Il parametro %s: %s è troppo grande e fa debordare la seconda mortasa, max valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[625] = " Il parametro %s: %s è troppo piccolo e fa debordare la seconda mortasa, min valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[626] = " Il parametro %s: %s è troppo grande, max valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[627] = " Il parametro %s: %s è troppo piccolo, min valore accettato: %s\n Verificare il parametro nel file: %s " + EgtDoorsMsg[628] = " Errore! Non è possibile gestire porta ad arco con funzione tastatura completa." + EgtDoorsMsg[629] = " Errore! Le Dimensioni della porta tastata H=%s W=%s T=%s eccedono la tolleranza DGC.Dh=%s DGC.Dw=%s DGC.Dt=%s rispetto alle dimensioni del del DDF H=%s W=%s T=%s. Verificare il pezzo tastato" + EgtDoorsMsg[630] = " Errore nella creazione della Porta. Verificare le dimensioni del pezzo in macchina" + EgtDoorsMsg[631] = " Errore! In modalità tastatura avanzata, file Dat mancante: %s" + EgtDoorsMsg[632] = " Errore! La lavorazione dei fianchi della porta non è compatibile con la tastatura completa. Disabilitare la lavorazione dei fianchi porta" + EgtDoorsMsg[633] = " Errore nella disposizione barra mobile: La larghezza porta è superiore o inferiore per l'ampiezza barre consentita. Controllare la larghezza porta" + EgtDoorsMsg[634] = " Impossibile inserire la Groove: %s. La cava è a filo o sborda dal lato dove è applicato il groove.\n Verificare il file ddf e il file %s" + EgtDoorsMsg[635] = " il DDF non ha nessun parametro: Properties" + EgtDoorsMsg[636] = " Errore! la proprietà narrow stile è compatibile solo con profilo diritto" + EgtDoorsMsg[637] = " Errore nella lettura Profili: codice profilo mancante. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[638] = "con nome: " + EgtDoorsMsg[639] = " Attenzione! Errato settaggio nella tabella ordinamenti (MTable). Nome geometria %s e' nel gruppo 0.\n" + EgtDoorsMsg[640] = " Errore! File del Post processor non definito. Controllare il parametro CompoMachining nel file CurrCamInfo.lua" + EgtDoorsMsg[641] = " Errore! Nome Macchina non corrispondente. Controllare il nome macchina utilizzato nel file CurrCamInfo.lua e nella MTable" + EgtDoorsMsg[642] = " Profilo #%s Spessore: %s" + EgtDoorsMsg[643] = " Errore! Porta con profilo %s sul lato//i: %s e di spessore: %s non combina con la lista dei profili %s : %s" + EgtDoorsMsg[644] = "Inferiore" + EgtDoorsMsg[645] = " Nessuna Face Decoration trovata" + EgtDoorsMsg[646] = "Face Decoration" + EgtDoorsMsg[647] = " Errore! La lunghezza calcolata: %s sulle linee verticali è errata\n Verificare i parametri nel file: %s" + EgtDoorsMsg[648] = " Errore! La lunghezza calcolata: %s sulle linee orizzontali è errata\n Verificare i parametri nel file: %s" + EgtDoorsMsg[649] = " Errore! Il parametro offset (%s): %s + raggio utensile %s è troppo grande. Max valore: %s\n Verificare i parametri nel file: %s" + EgtDoorsMsg[650] = " Errore! Il parametro distanza di fianco (%s): %s + larghezza rettangolo (%s): %s + raggio utensile %s fanno sbordare la geometria dalla porta (larghezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[651] = " Errore! Il parametro distanza di verticale (%s): %s + altezza rettangolo (%s): %s + raggio utensile %s fanno sbordare la geometria dalla porta (altezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[652] = " Errore! Il parametro distanza di fianco + passo linee + diametro utensile fanno sbordare la geometria dalla porta (larghezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[653] = " Errore! Il parametro distanza di verticale + passo linee + diametro utensile fanno sbordare la geometria dalla porta (altezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[654] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità braccio: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[655] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità corpo: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[656] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità braccio: %s perché è maggiore della massima lavorazione dell'utensile anti-scheggia: %s " + EgtDoorsMsg[657] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità corpo: %s perché è maggiore della massima lavorazione dell'utensile anti-scheggia: %s " + EgtDoorsMsg[658] = " Impossibile inserire il pivot: %s di tipo %s sottotipo %s, sul profilo cerniere di tipo Bevel: %s " + EgtDoorsMsg[659] = " Errore! In modalità tastatura avanzata, il settaggio opzionale .Pms differisce dal corrispondente parametro OPM nel file di tastatura: %s " + EgtDoorsMsg[660] = " Errore nella lettura Profili: parametro raggio e parametro angolo presenti contemporaneamente. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[661] = " Errore nella lettura Profili: parametro posizione X mancante. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[662] = " Errore nella lettura Profili: parametro posizione X ha valore maggiore delle larghezza porta. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[663] = " Errore nella lettura Profili: parametro Angolo maggiore di 45°. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[664] = " Errore nella lettura Profili: Parte top inclinata maggiore o uguale di altezza porta. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[665] = " Errore! Il parametro distanza di fianco (%s): %s - raggio utensile %s fanno sbordare la geometria dalla porta (larghezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[666] = " Errore! Il parametro distanza di verticale (%s): %s - raggio utensile %s fanno sbordare la geometria dalla porta (altezza)\n Verificare i parametri nel file: %s" + EgtDoorsMsg[667] = " Errore! Porta con profili EdgeBreak %s sul lato//i: %s. La configurazione del profilo EdgeBreak è mancante. Inviare un feedback con la porta al vostro servizio di assistenza" + EgtDoorsMsg[668] = " il DDF non ha nessun parametro: Material" + EgtDoorsMsg[669] = " Impossibile inserire un pivot tipo intermediate: %s sul profilo cerniere tipo bullnose: %s " + EgtDoorsMsg[670] = " Attenzione! (%s) nel modello: %s è stata ridotta la profondità: %s perché è maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[671] = " Non è ammesso l'inserimento Roller (latch): %s sul lato serraturay con profilo tipo toro o concavo: %s. Verificare il file ddf " + EgtDoorsMsg[672] = " Attenzione! (%s) nel modello: %s è stata disabilitata la lavorazione: %s perché lo spessore della sfinestratura: %s è uguale o maggiore della massima lavorazione dell'utensile: %s " + EgtDoorsMsg[673] = " Attenzione! (%s) nel modello: %s è stata disabilitata la lavorazione di lama: %s perché una o entrambe le dimensioni della sfinestratura sono inferiori alla minima lunghezza del taglio lama " + EgtDoorsMsg[674] = " Attenzione! (%s) nel modello: %s non è stata disabilitata la lavorazione di lama perché lo spessore della sfinestratura: %s è maggiore della massima lavorazione impostata nel parametro lua : %s " + EgtDoorsMsg[675] = " Disposizione per Multiax-C1016 :" + EgtDoorsMsg[676] = " Disposizione per Multiax NE :" + EgtDoorsMsg[677] = " Errore! Impossibile creare superfici laterali. Verificare il file ddf" + EgtDoorsMsg[678] = " Errore! parte superiore ad arco in tangenza bordo destro ma i loro profili non corrispondono: %s, %s Verificare il file ddf " + EgtDoorsMsg[679] = " Errore! parte superiore ad arco in tangenza bordo sinistro ma i loro profili non corrispondono: %s, %s Verificare il file ddf " + EgtDoorsMsg[680] = " Errore nella lettura Profili: Le impostazioni dell'arco annullano la lunghezza di un lato. Verificare i parametri dell'arco (nel file ddf) " + EgtDoorsMsg[681] = " Attenzione! (%s) nel modello: %s del pezzo: %s il parametro %s di valore %s è stato ridotto a: %s perché è prossimo o maggiore dello spessore pezzo: %s " + EgtDoorsMsg[682] = " Errore nel settaggio tavola. Verificare i parametri nNumTableOnMachine e nNumTableForOtherMaterial nel file CurrcamInfo.lua" + EgtDoorsMsg[683] = " Errore in disposizione morse: insufficienti morse attive. Verificare le lavorazioni in prossimità delle morse" + EgtDoorsMsg[684] = " Errore in disposizione morse: troppe morse disattivate sulla parte destra. Verificare le lavorazioni in prossimità delle morse" + EgtDoorsMsg[685] = " Errore in disposizione morse: troppe morse disattivate nella parte sinistra. Verificare le lavorazioni in prossimità delle morse" + EgtDoorsMsg[686] = " Errore inizializzazione simulazione: %s" + EgtDoorsMsg[687] = " Rilevata colisione testa-pezzo. Verificare nella simulazione: %s" + EgtDoorsMsg[688] = " Extracorsa su asse: %s" + EgtDoorsMsg[689] = " Errore Generale (contattare l'assistenza): %s" + EgtDoorsMsg[690] = " Errore in simulazione. Il codice Cn non è stato generato" + EgtDoorsMsg[691] = " Attenzione! Il file %s é una vecchia versione ddf. Si prega di aprirlo nel EgtDoorCreator e fare clck su salva" + EgtDoorsMsg[692] = " Errore! la Mtable: %s presente nelle note del pezzo non è stata trovata nella configurazione EgtDoor corrente: %s. Probabilmente il ddf corrente è stato creato con un'altra configurazione EgtDoor" + EgtDoorsMsg[693] = " Errore! Il percorso della Mtable: %s presente nelle note del pezzo non corrisponde con il percorso della configurazione EgtDoor corrente: %s. Probabilmente il ddf corrente è stato creato con un'altra configurazione EgtDoor" + EgtDoorsMsg[694] = " Errore! Nessun pezzo o pezzo non salvato nel progetto corrente" + EgtDoorsMsg[695] = " Errore! Esiste più di un taglio di separazione longitudinale o trasversale" + EgtDoorsMsg[696] = "Porta larga ruotata, " + EgtDoorsMsg[697] = "Porta larga, " + EgtDoorsMsg[698] = " Attenzione! (%s) nel modello: %s è stata disabilitata la lavorazione: %s perché lo spessore profilo utensile: %s è uguale o maggiore dello spessore porta: %s" + EgtDoorsMsg[699] = " Il parametro %s: %s deve essere minore dello spessore porta: %s\n Verificare i parametri nel file: %s " + EgtDoorsMsg[700] = " Errore! Il percorso Side Groove arriva troppo vicino all'angolo: %s che ha una distanza minima di sicurezza: %s. Aumentare la distanza max dall'angolo o ridurre la lunghezza gola" + EgtDoorsMsg[701] = " Errore importazione o apertura file dxf: %s. Verificare che file dxf esista e non sia danneggiato" + EgtDoorsMsg[702] = " Errore! Formato file ddf non corrisponde con la sua versione: %s" + EgtDoorsMsg[703] = " Errore DDF versione: %s nella lettura Profili: codice profilo mancante. Verificare il file ddf in prossimità della linea: %s " + EgtDoorsMsg[704] = " Errore! elementi residui: %s. Concatenamento fallito" + EgtDoorsMsg[705] = " Errore! Concatenamento fallito: %s" + EgtDoorsMsg[706] = " Errore! Tipo di file importato non corrisponde al formato dxf" + EgtDoorsMsg[707] = " Errore! Impossibile aprire il file dxf" + EgtDoorsMsg[708] = " Percorso %s non ricostruito" + EgtDoorsMsg[709] = " Layer lato %s non trovato" + EgtDoorsMsg[710] = " Note mancanti" + EgtDoorsMsg[711] = " Note swing mancanti" + EgtDoorsMsg[712] = " Layer Notes non contiene percorso con informazioni necessarie" + EgtDoorsMsg[713] = " Trovato Errore nelle lavorazioni: %s" + EgtDoorsMsg[714] = " Errore nella generazione lavorazioni. Il codice Cn non è stato generato" +else -- default 'ENG' + EgtDoorsMsg[400] = " Tool Diameter %s: %s must be equal or bigger than: %s. Check the tool data " + EgtDoorsMsg[401] = " Parameter %s: %s must be bigger than 0\n Check the parameter into file: %s " + EgtDoorsMsg[402] = " Parameter %s: %s must be bigger than tool diameter(%s): %s\n Check the tool data or parameter into file: %s " + EgtDoorsMsg[403] = " Parameter %s: %s must be between the values min: %s max: %s\n Check the parameter into file: %s " + EgtDoorsMsg[404] = " Parameter %s: %s must be bigger or equal than 0\n Check the parameter into file: %s " + EgtDoorsMsg[405] = " Parameter %s: %s must be bigger or equal than tool diameter: %s\n Check the tool data or parameter into file: %s " + EgtDoorsMsg[406] = " Parameter %s: %s must be smaller than parameter %s: %s\n Check the parameters into file: %s " + EgtDoorsMsg[407] = " Parameter %s: %s must be bigger than parameter %s: %s\n Check the parameters into file: %s " + EgtDoorsMsg[408] = " Error! The dimension parameters are missing L and W or R into ddf" + EgtDoorsMsg[409] = " Interax parameter %s: %s must be bigger than handle diameter bore: %s\n Check the parameters into file: %s" + EgtDoorsMsg[410] = " Parameter %s: %s must be bigger or equal than %s+%s: %s\n Check the parameters into file: %s" + EgtDoorsMsg[411] = " Error! Unrecognized file (lua or nge type): %s\n Verify parameters into file: %s " + EgtDoorsMsg[412] = " Error! Impossible to import custom geometry file: %s. Verify the nge file " + EgtDoorsMsg[413] = " Error! Geometry: %s of %s: %s, has unknow SideDoor note: %s\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[414] = " Error! Geometry: %s of %s: %s, has not specified the SideDoor note\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[415] = " Error! Geometry: %s of %s has unknow InserPoint note: %s\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[416] = " Error! Geometry: %s of %s has not specified the InserPoint note\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[417] = " Parameter %s: %s Can have only theese values: 0 or 1 or -1\n Check the parameter into file: %s " + EgtDoorsMsg[418] = " Error! Geometry: %s of Viewer: %s, has unknow SideDoor note: %s\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[419] = " Error! Geometry: %s of Viewer: %s, has not specified the SideDoor note\n Check the imported nge file loaded into ddf: %s " + EgtDoorsMsg[420] = " Interax parameter %s: %s must be bigger than viewer diameter bore: %s\n Check the parameter into file: %s " + EgtDoorsMsg[421] = " Error! The dimension parameters are missing L and W or R\n Check the parameters into file: %s" + EgtDoorsMsg[422] = " Parameter %s: %s must be bigger or equal than parameter %s: %s\n Check the parameter into file: %s " + EgtDoorsMsg[423] = " Parameter %s: %s is too big and mortise overflow from face. Max value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[424] = " Parameter %s: %s is too small and mortise overflow into face. Min value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[425] = " Cant join the reverse poketing paths\n Please send the ddf file and the file %s to your assistance service " + EgtDoorsMsg[426] = " Cant join the poketing paths\n Please send the ddf file and the file %s to your assistance service " + EgtDoorsMsg[427] = " Cant make the composite path\n Please send the ddf file and the file %s to your assistance service " + EgtDoorsMsg[428] = " Insert a Mortise hinge: %s on bullnose-convex profile hinge edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[429] = " Insert a Concealed hinge: %s on bevel, or bullnose, or concave hinge edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[430] = " Insert a Lock: %s on Bullnose-convex profile lock edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[431] = " Insert an Edge Pull: %s on Bullnose-convex profile lock edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[432] = " Impossible to apply Over Head Arm: %s. Parameter H: %s is bigger or equal than door thickness: %s. Check ddf file and file %s" + EgtDoorsMsg[433] = " Door thickness %s is bigger than profile %s with radius: %s. Check ddf file" + EgtDoorsMsg[434] = " Opening error ddf file. Check ddf file if it exists and it is not damaged" + EgtDoorsMsg[435] = " Error reading Measures. Check ddf file near line: %s " + EgtDoorsMsg[436] = " Error reading Code. Check ddf file near line: %s " + EgtDoorsMsg[437] = " Error reading Order. Check ddf file near line: %s " + EgtDoorsMsg[438] = " Error reading Date. Check ddf file near line: %s " + EgtDoorsMsg[439] = " Error reading Size. Check ddf file near line: %s " + EgtDoorsMsg[440] = " Error reading Swing: %s. Check ddf file near line: %s " + EgtDoorsMsg[441] = " Error reading Profiles: missing overmaterial parameter. Check ddf file near line: %s " + EgtDoorsMsg[442] = " This door has no VisionCutOuts" + EgtDoorsMsg[443] = " This door has no LouverCutOuts" + EgtDoorsMsg[444] = " This door has no MailSlots" + EgtDoorsMsg[445] = " This door has no Viewers" + EgtDoorsMsg[446] = " This door has no Flush Pull" + EgtDoorsMsg[447] = " This door has no Hinges" + EgtDoorsMsg[448] = " This door has no Locks" + EgtDoorsMsg[449] = " This door has no Flush Bolts" + EgtDoorsMsg[450] = " This door has no Edge Pulls" + EgtDoorsMsg[451] = " This door has no Roller Latchs" + EgtDoorsMsg[452] = " This door has no Pivots" + EgtDoorsMsg[453] = " This door has no Stops And Closers" + EgtDoorsMsg[454] = " Error creating Door. Check ddf file " + EgtDoorsMsg[455] = " Error machining Door. Check ddf file, check machining and tools " + EgtDoorsMsg[456] = " Parameter %s: %s must be smaller or equal than parameter %s: %s\n Check the parameters into file: %s " + EgtDoorsMsg[457] = " Impossible to load custom geometry file: %s. Verify the nge file " + EgtDoorsMsg[458] = " Error. Kind of hardware: %s is allowed only on inactive door. actual door type: %s. Check ddf file " + EgtDoorsMsg[459] = " Parameter %s: %s must be bigger than 0 and must be smaller or equal than tool diameter: %s\n Check the tool data or parameter into file: %s " + EgtDoorsMsg[460] = " Warning! (%s) Into model: %s face depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[461] = " Warning! (%s) Into model: %s mortise depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[462] = " Warning! (%s) into model: %s face depth: %s is modified because it's bigger than anti splint tool max depth parameter: %s " + EgtDoorsMsg[463] = " Warning! (%s) Into model: %s bore depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[464] = " Impossible to apply Center Hung Pivot: %s on Bevel profile hinge edge: %s " + EgtDoorsMsg[465] = " Impossible to apply intermediate pivot: %s on Bullnose-convex profile hinge edge: %s " + EgtDoorsMsg[466] = " Warning! (%s) No machining with index: %s linked to geometry name: %s\n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[467] = " Warning! (%s) Impossible to set machining: %s with index: %s to geometry name: %s\n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[468] = " Warning! (%s) Impossible to acquire data from machining: %s with index: %s applied to geometry name: %s\n Verify the machining \n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[469] = " Warning! (%s) Impossible to acquire tool data from machining: %s with index: %s applied to geometry name: %s\n Verify the machining \n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[470] = " Warning! (%s) Impossible to acquire diameter tool data from machining: %s with index: %s applied to geometry name: %s\n Verify tool data \n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[471] = " Warning! (%s) Geometry name: %s not found or disabled in MTable \n Check the MTable \n Will be used the tool diameter: %s defined into model\n No depth correction will be checked and applied" + EgtDoorsMsg[472] = " Warning! (%s) Impossible to acquire max material tool data from machining: %s with index: %s applied to geometry name: %s\n Verify tool data \n Will be used the tool diameter defined into model: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[473] = " Warning! (%s) Impossible to acquire max material tool data from machining: %s with index: %s applied to geometry name: %s\n Verify tool data \n No depth correction will be checked and applied" + EgtDoorsMsg[474] = " Error positioning raw part on table" + EgtDoorsMsg[475] = " Error on machining calculation of machine: %s The code for this machine will not generated" + EgtDoorsMsg[476] = "Error" + EgtDoorsMsg[477] = "ERROR" + EgtDoorsMsg[478] = " Error on Nc part program calculation of machine: %s. Verify if all used tools are loaded into setup: %s" + EgtDoorsMsg[479] = "Door flipped: Secure on top" + EgtDoorsMsg[480] = "Door normal: Keyway on top" + EgtDoorsMsg[481] = ", Top on right" + EgtDoorsMsg[482] = ", Top on left" + EgtDoorsMsg[483] = " Null or undefined machining apply to geometry: %s Id geom: %s Check MTable\n" + EgtDoorsMsg[484] = " Error! Invalid or not exists machining: %s (applied to geometry: %s Id geom:%s)\n Check MTable or MachDb" + EgtDoorsMsg[485] = " Error! Impossible to insert or to apply the machining: %s to geometry: %s Id geom: %s\n Check machining and geometry" + EgtDoorsMsg[486] = "Error on load Cam data from file: %s" + EgtDoorsMsg[487] = "Error! %sfile: %s not found or not loadable" + EgtDoorsMsg[488] = "Warning! Machine: %s not found" + EgtDoorsMsg[489] = "Error! Invalid machine data ino table file: %s" + EgtDoorsMsg[490] = "Error! Invalid MTable into file: %s" + EgtDoorsMsg[491] = "Error! Machine name: %s not found into table" + EgtDoorsMsg[492] = " Warning! NC generation on machine: %s is disabled by MTable settings" + EgtDoorsMsg[493] = "\n No machining for machine: %s piece number: %s piece name: %s" + EgtDoorsMsg[494] = " Start Machining on machine: %s" + EgtDoorsMsg[495] = "Door Disposition" + EgtDoorsMsg[496] = " on geometry name (number): " + EgtDoorsMsg[497] = " Skipped geom Id: " + EgtDoorsMsg[498] = "End of machining generation " + EgtDoorsMsg[499] = " Warning! MTable reference not found into current project" + EgtDoorsMsg[500] = " Warning! Non Inactive door with opposite bevel profile. Swing: %s Hinge prof.: %s Lock prof.: %s" + EgtDoorsMsg[501] = "Warning" + EgtDoorsMsg[502] = "WARNING" + EgtDoorsMsg[503] = " Warning! (%s) Geometry name: %s not found or disabled in MTable \n Check the MTable \n No depth correction will be checked and applied" + EgtDoorsMsg[504] = " Warning! (%s) No machining with index: %s linked to geometry name: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[505] = " Warning! (%s) Impossible to set machining: %s with index: %s to geometry name: %s\n No depth correction will be checked and applied" + EgtDoorsMsg[506] = " Warning! (%s) Impossible to aquire data from machining: %s with index: %s applied to geometry name: %s\n Verify the machining \n No depth correction will be checked and applied" + EgtDoorsMsg[507] = " Warning! (%s) Impossible to acquire tool data from machining: %s with index: %s applied to geometry name: %s\n Verify the machining \n No depth correction will be checked and applied" + EgtDoorsMsg[508] = " Warning! (%s) Impossible to acquire diameter tool data from machining: %s with index: %s applied to geometry name: %s\n Verify tool data \n No depth correction will be checked and applied" + EgtDoorsMsg[509] = " Warning! (%s) MTable not found into project notes\n Check the project \n No diameter tool and depth correction will be checked and applied" + EgtDoorsMsg[510] = ", Add Spacer on Y" + EgtDoorsMsg[511] = "Disp" + EgtDoorsMsg[512] = "Invalid parameters into ddf file near line: %s on feature: %s" + EgtDoorsMsg[513] = "Vision cutout" + EgtDoorsMsg[514] = "Louver cutout" + EgtDoorsMsg[515] = "Mail slot" + EgtDoorsMsg[516] = "Viewer" + EgtDoorsMsg[517] = "Flush pull" + EgtDoorsMsg[518] = "Hinge" + EgtDoorsMsg[519] = "Lock" + EgtDoorsMsg[520] = "FlushBolt" + EgtDoorsMsg[521] = "EdgePull" + EgtDoorsMsg[522] = "Roller latch" + EgtDoorsMsg[523] = "Pivot" + EgtDoorsMsg[524] = "StopAndCloser" + EgtDoorsMsg[525] = "Over Head Stop_Closer" + EgtDoorsMsg[526] = " This door has no Over Heads" + EgtDoorsMsg[527] = " Parameter %s: %s is too big and bore overflow from face. Max value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[528] = " Disposition for Cms-PF122R8RR :" + EgtDoorsMsg[529] = " Disposition for Multiax-N1216 :" + EgtDoorsMsg[530] = " Error on MOBILE or FIXED table bar" + EgtDoorsMsg[531] = " Error on vacuum disposition: the active vacuums are not enought. Check the cutout geometries or hardware machinings near vacuums" + EgtDoorsMsg[532] = " Error on vacuum disposition: too many disabled vacuums on left side door. Check the cutout geometries or hardware machinings near vacuums" + EgtDoorsMsg[533] = " Error on vacuum disposition: too many disabled vacuums on middle door. Check the cutout geometries or hardware machinings near vacuums" + EgtDoorsMsg[534] = " Error on vacuum disposition: too many disabled vacuums on right side door. Check the cutout geometries or hardware machinings near vacuums" + EgtDoorsMsg[535] = " This door has no Strikes" + EgtDoorsMsg[536] = " This door has no Groove" + EgtDoorsMsg[537] = " This door has no Rabbet" + EgtDoorsMsg[538] = "Strike" + EgtDoorsMsg[539] = "Groove" + EgtDoorsMsg[540] = " Impossible to apply Groove: %s. Parameter H: %s is bigger or equal than door thickness: %s\n Check ddf file and file %s" + EgtDoorsMsg[541] = " Warning! (%s) into model: %s anti split path depth: %s is modified because it's bigger than anti splint tool max depth parameter: %s " + EgtDoorsMsg[542] = " Warning! (%s) Into model: %s groove width: %s it's smaller than blade thickness: %s " + EgtDoorsMsg[543] = " This DDF file has no Secure parameter" + EgtDoorsMsg[544] = " Error! definition door parameters conflicting. Swing: %s DDF bevel profile: %s SECURE parameter: %s. Check ddf file" + EgtDoorsMsg[545] = " Error! Missing definition door parameters. DDF bevel profile not found and DDF SECURE parameter not found. Check ddf file" + EgtDoorsMsg[546] = " Insert a Rabbet on bullnose-convex profile hinge edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[547] = " Insert a Rabbet on bullnose-convex profile lock edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[548] = " Error! Parameter side of rabbet is not allowed: %s. Check ddf file " + EgtDoorsMsg[549] = " Warning! (%s) Into model: %s rail depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[550] = "Rabbet" + EgtDoorsMsg[551] = " Error on import all setup tool fle\n Check into SETUP section if exists setup file and if they are defined into CurrCamInfo.lua file" + EgtDoorsMsg[552] = " Error into Setup tool file: %s" + EgtDoorsMsg[553] = " List of not loaded tools and/or missing tool: " + EgtDoorsMsg[554] = " Setup file empty or not loaded: %s" + EgtDoorsMsg[555] = "none" + EgtDoorsMsg[556] = " Warning! (%s) Into model: %s face depth: %s is modified because it's bigger than chisel tool max depth parameter: %s " + EgtDoorsMsg[557] = " This door has no EPT" + EgtDoorsMsg[588] = "EPT" + EgtDoorsMsg[589] = " Insert an EPT: %s on bullnose-convex profile hinge edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[590] = " Error! Missing definition door parameters. This Door without bevel profile, Not found SECURE parameter from DDF and not found from CurrCamInfo file" + EgtDoorsMsg[591] = " Error! Parameter: %s not defined or Type parameter into DDF not suitable. Check the template file: %s or the Type parameter into door ddf file" + EgtDoorsMsg[592] = " Error! Parameter: %s not defined. Verify the door ddf file" + EgtDoorsMsg[593] = " Warning! %s can be applied only on %s side. Check ddf file" + EgtDoorsMsg[594] = " Error! %s can't be applied on side %s. Check ddf file" + EgtDoorsMsg[595] = " machining: " + EgtDoorsMsg[596] = " phase: " + EgtDoorsMsg[597] = " Error! Table file not found: %s " + EgtDoorsMsg[598] = " Error! Impossible to insert or to apply the machining: %s to geometry: %s Id geom: %s\n Error Id: %s Error: %s\n Check machining and geometry" + EgtDoorsMsg[599] = " No door found" + EgtDoorsMsg[600] = " No second door found" + EgtDoorsMsg[601] = " No Left frame found" + EgtDoorsMsg[602] = " No Right frame found" + EgtDoorsMsg[603] = " No Top frame found" + EgtDoorsMsg[604] = " Error! Hardware model out of sequence. Check ddf file near line: %s " + EgtDoorsMsg[605] = "Side Left" + EgtDoorsMsg[606] = "Side Right" + EgtDoorsMsg[607] = "Side Top" + EgtDoorsMsg[608] = "Sill" + EgtDoorsMsg[609] = " Error! definition jamb parameters conflicting. Jamb piece: %s Kind of jamb: %s Lock side on: %s. Check ddf file" + EgtDoorsMsg[610] = "Jamb flipped: Secure on top" + EgtDoorsMsg[611] = "Jamb normal: Keyway on top" + EgtDoorsMsg[612] = " Warning! (%s) into model: %s clean corner path depth: %s is modified because it's deepher than clean corner tool max depth parameter: %s " + EgtDoorsMsg[613] = " Error reading Profiles: missing radius or angle parameter. Check ddf file near line: %s " + EgtDoorsMsg[614] = " Error reading Profiles: radius value is too small. Check ddf file near line: %s " + EgtDoorsMsg[615] = " Error reading Profiles: side profiles not correspond to arc profile. Check ddf file near line: %s " + EgtDoorsMsg[616] = " Error! Piece (%s) height is bigger. Height %s + overmaterial %s: %s is bigger than max piece height configured minus X shift value %s: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[617] = " Error! Piece (%s) height is smaller. Height %s + overmaterial %s: %s is less than min piece height configured minus X shift value %s: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[618] = " Error! Piece (%s) width is bigger. Width %s + double overmaterial %s: %s is bigger than max piece width configured minus Y shift value %s: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[619] = " Error! Piece (%s) width is smaller. Width %s + double overmaterial %s: %s is less than min piece width configured minus Y shift value %s: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[620] = " Error! Piece (%s) thickness: %s is bigger than max piece thickness configured: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[621] = " Error! Piece (%s) thickness: %s is less than min piece thickness configured: %s (limit into CurrCamInfo file)." + EgtDoorsMsg[622] = " Door" + EgtDoorsMsg[623] = " Jamb" + EgtDoorsMsg[624] = " Parameter %s: %s is too big and 2nd mortise overflow from 1st mortise. Max value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[625] = " Parameter %s: %s is too small and 2nd mortise overflow into 1st mortise. Min value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[626] = " Parameter %s: %s is too big. Max value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[627] = " Parameter %s: %s is too small. Min value: %s\n Check the parameter into file: %s " + EgtDoorsMsg[628] = " Error! It is not possible manage Top arc door with full probe function" + EgtDoorsMsg[629] = " Error! Door dimensions probed H=%s W=%s T=%s exceded than tolerance DGC.Dh=%s DGC.Dw=%s DGC.Dt=%s from DDF dimensions H=%s W=%s T=%s. Check Door on machine" + EgtDoorsMsg[630] = " Error creating Door. Check Piece Dimension on machine" + EgtDoorsMsg[631] = " Error! By advanced probe mode, Dat file is missing: %s" + EgtDoorsMsg[632] = " Error! Trim of door sides is not compatible with total probe mode. Please disable the side trim." + EgtDoorsMsg[633] = " Error on bar disposition: The door is bigger or smaller than for table disposition. Check the door wide dimension" + EgtDoorsMsg[634] = " Impossible to apply Groove: %s. Groove geometry correspond or overlap to the applied side.\n Check ddf file and file %s" + EgtDoorsMsg[635] = " This DDF file has no Properties parameter" + EgtDoorsMsg[636] = " Error! Narrow stile property is compatible only with square profile" + EgtDoorsMsg[637] = " Error reading Profiles: profile code missing. Check ddf file near line: %s " + EgtDoorsMsg[638] = "whith name: " + EgtDoorsMsg[639] = " Warning! Wrong Ordered table(Mtable table) setting. Geometry name: %s is on group 0.\n" + EgtDoorsMsg[640] = " Error! Post processor file not defined. Check parameter CompoMachining into CurrCamInfo.lua file" + EgtDoorsMsg[641] = " Error! Machine name mismatch. Check used machine into CurrCamInfo.lua file and MTable" + EgtDoorsMsg[642] = " Prof #%s thickness: %s" + EgtDoorsMsg[643] = " Error! Door with profile %s on: %s and thickness: %s not match with the configured %s list: %s" + EgtDoorsMsg[644] = "Side Bottom" + EgtDoorsMsg[645] = " This door has no Face Decoration" + EgtDoorsMsg[646] = "Face Decoration" + EgtDoorsMsg[647] = " Error! The calculated length %s of vertical lines is bad\n Check the parameters into file: %s" + EgtDoorsMsg[648] = " Error! The calculated length %s of horizontal lines is bad\n Check the parameters into file: %s" + EgtDoorsMsg[649] = " Error! The offset parameter (%s): %s + tool radius %s is too big. Max value: %s\n Check the parameters into file: %s" + EgtDoorsMsg[650] = " Error! The side distance parameter (%s): %s + rectangle width (%s): %s + tool radius %s protrudes off some geometries than door width\n Check the parameters into file: %s" + EgtDoorsMsg[651] = " Error! The vertical distance parameter (%s): %s + rectangle length (%s): %s + tool radius %s protrude off some geometries than door height\n Check the parameters into file: %s" + EgtDoorsMsg[652] = " Error! The side distance parameter + lines step + tool diameter protrude off some geometries than door width\n Check the parameters into file: %s" + EgtDoorsMsg[653] = " Error! The vertical distance parameter + lines step + tool diameter protrude off some geometries than door height\n Check the parameters into file: %s" + EgtDoorsMsg[654] = " Warning! (%s) Into model: %s knuckle depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[655] = " Warning! (%s) Into model: %s body depth: %s is modified because it's bigger than tool max depth parameter: %s " + EgtDoorsMsg[656] = " Warning! (%s) into model: %s knuckle depth: %s is modified because it's bigger than anti splint tool max depth parameter: %s " + EgtDoorsMsg[657] = " Warning! (%s) into model: %s body depth: %s is modified because it's bigger than anti splint tool max depth parameter: %s " + EgtDoorsMsg[658] = " Impossible apply the Pivot: %s type %s subtype %s, on a Bevel hinge profile: %s " + EgtDoorsMsg[659] = " Error! By advanced probe mode, optional setting .Pms not match the parameter OPM into probe file: %s " + EgtDoorsMsg[660] = " Error reading Profiles: radius parameter and angle parameter cannot be together. Check ddf file near line: %s " + EgtDoorsMsg[661] = " Error reading Profiles: X pos. parameter missing. Check ddf file near line: %s " + EgtDoorsMsg[662] = " Error reading Profiles: X pos. parameter is bigger than door width. Check ddf file near line: %s " + EgtDoorsMsg[663] = " Error reading Profiles: Angle parameter is bigger than 45°. Check ddf file near line: %s " + EgtDoorsMsg[664] = " Error reading Profiles: Inclinated top side is bigger or equal than door height. Check ddf file near line: %s " + EgtDoorsMsg[665] = " Error! The side distance parameter (%s): %s - tool radius %s protrudes off some geometries than door width\n Check the parameters into file: %s" + EgtDoorsMsg[666] = " Error! The vertical distance parameter (%s): %s - tool radius %s protrude off some geometries than door height\n Check the parameters into file: %s" + EgtDoorsMsg[667] = " Error! found Door with EdgeBreak profile %s on: %s. But EdgeBreak profile data is not configured into CurrDoorsCustomData. Please send a feedback with this door to your assistance service" + EgtDoorsMsg[668] = " This DDF file has no Material parameter" + EgtDoorsMsg[669] = " Impossible to apply intermediate pivot: %s on Bullnose profile hinge edge: %s " + EgtDoorsMsg[670] = " Warning! (%s) Into model: %s its depth: %s is modified because it's bigger than tool max material parameter: %s " + EgtDoorsMsg[671] = " Insert a Roller (latch): %s on bullnose-convex profile lock edge: %s is not allowed. Check ddf file " + EgtDoorsMsg[672] = " Warning! (%s) Into model: %s machining: %s is disabled because lightcutout thickness: %s it's equal or bigger than tool max depth parameter: %s " + EgtDoorsMsg[673] = " Warning! (%s) Into model: %s machining: %s is disabled because one or both lightcutout dimension are smaller than min. blade cut " + EgtDoorsMsg[674] = " Warning! (%s) Into model: %s machining by blade is disabled because lightcutout thickness: %s it's bigger than lua max depth parameter: %s " + EgtDoorsMsg[675] = " Disposition for Multiax-C1016 :" + EgtDoorsMsg[676] = " Disposition for Multiax-NE :" + EgtDoorsMsg[677] = " Error! It's not possible make side surfaces. Check ddf file" + EgtDoorsMsg[678] = " Error! Top Arc tangent to right side but their profiles does not match: %s, %s Check ddf file " + EgtDoorsMsg[679] = " Error! Top Arc tangent to left side but their profiles does not match: %s, %s Check ddf file " + EgtDoorsMsg[680] = " Error reading Profiles: radius parameters of top side arc makes the length of one side null. Check Top Arc parameters (into ddf file)" + EgtDoorsMsg[681] = " Warning! (%s) Into model: %s of piece: %s the parameter %s value %s is modified to: %s because it's bigger or near than jamb thickness: %s " + EgtDoorsMsg[682] = " Error in table setting. Verify the parameters nNumTableOnMachine and nNumTableForOtherMaterial into CurrcamInfo.lua file" + EgtDoorsMsg[683] = " Error on vise disposition: the active vises are not enought. Check the hardware machinings near vises" + EgtDoorsMsg[684] = " Error on vise disposition: too many disabled vises on left side frame. Check the hardware machinings near vises" + EgtDoorsMsg[685] = " Error on vise disposition: too many disabled vises on right side frame. Check the hardware machinings near vises" + EgtDoorsMsg[686] = " Error starting simulation: %s" + EgtDoorsMsg[687] = " Head-part collision detected. Check it by simulation: %s" + EgtDoorsMsg[688] = " Axis outstroke: %s" + EgtDoorsMsg[689] = " General failure (contact supplier): %s" + EgtDoorsMsg[690] = " Error on simulation. The part program is not generated" + EgtDoorsMsg[691] = " Attention! This ddf %s is too old. Please open it into EgtDoorCreator and just save it" + EgtDoorsMsg[692] = " Error! Mtable piece info: %s not found into current EgtDoor configuration: %s. Maybe this ddf file was made with another EgtDoor configuration." + EgtDoorsMsg[693] = " Error! Mtable path into piece info: %s not correspond to current EgtDoor configuration: %s. Maybe this ddf file was made with another EgtDoor configuration." + EgtDoorsMsg[694] = " Error! No Piece or not saved Piece to process into current project" + EgtDoorsMsg[695] = " Error! Exist more cuts along door Heigth or along door width" + EgtDoorsMsg[696] = "Wide spinned Door, " + EgtDoorsMsg[697] = "Wide Door, " + EgtDoorsMsg[698] = " Warning! (%s) Into model: %s machining: %s is disabled because tool thickness: %s is equal or bigger than door thichness: %s" + EgtDoorsMsg[699] = " Parameter %s: %s must be smaller than door thickness: %s\n Check the parameters into file: %s " + EgtDoorsMsg[700] = " Error! Side Groove path is too close to corner %s than min distance %s. Set bigger the max distance to corner or reduce the groove length" + EgtDoorsMsg[701] = " Importing or Opening error dxf file: %s. Check dxf file if it exists and it is not damaged" + EgtDoorsMsg[702] = " Error! DDF file format not correspond to DDF version number: %s" + EgtDoorsMsg[703] = " Error (with DDF version: %s) reading Profiles: profile code missing. Check ddf file near line: %s " + EgtDoorsMsg[704] = "Residual elements: %s. Chaining failed" + EgtDoorsMsg[705] = "Chaining failed: %s" + EgtDoorsMsg[706] = " Error! File format does not correspond to dxf format" + EgtDoorsMsg[707] = " Impossible open the dxf file" + EgtDoorsMsg[708] = "%s path not rebuild" + EgtDoorsMsg[709] = "Side %s layer not found" + EgtDoorsMsg[710] = " Missing notes" + EgtDoorsMsg[711] = " Swing notes missing" + EgtDoorsMsg[712] = " Notes layer has not a path with neded info" + EgtDoorsMsg[713] = " Machinings error found: %s" + EgtDoorsMsg[714] = " Error on machining generations. The part program is not generated" +end + +return EgtDoorsMsg diff --git a/LuaLibs/FC_Rectangle.lua b/LuaLibs/FC_Rectangle.lua new file mode 100644 index 0000000..5face2e --- /dev/null +++ b/LuaLibs/FC_Rectangle.lua @@ -0,0 +1,913 @@ +-- +-- 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 +-- +-- fc_rectangle.lua by EgalWare s.r.l. 2019.05.07 +-- Autore: Filippo Monchi +-- fc_rectangle dati i valori 'Thickness' e 'face' e con nome attributo + +-- 2019.05.07 V1.000 FM Write Component +-- 2019.09.24 V1.001 FM Manage side distance parameters (top, bottom, lock, hinge) from ddf +-- 2019.09.25 V1.002 FM Fix some error on calculate lines and rectangle position when diameter tool used +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.18 V2.000 FM Manage to draw not premptive lines between premptive lines only if premptive lines are 2 and their start and stop +-- distances are defined and without or zero step value +-- 2022.07.27 V2.001 FM Modification to use compiled code +-- 2023.05.15 V2.002 FM fix errors (x/0) when exists only 1 horizontal line and/or only 1 vertical line and both distances ( from reference and opposite sides) are difined + +-- Tavola per definizione modulo (serve ma non usata) +local fc_rectangle = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 4. -- valore minimo lato + +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 + +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 DrawRectangleWithFillet ( Lg, L, H, dThickD, rf) + + local tHint = {} + local hint + local pIni, pEnd, pCen + + -- Costruzione della geometria principale + pIni = Point3d(((L/2)-rf),(H/2),dThickD) + pCen = Point3d(((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d((L/2),((H/2)-rf),dThickD) + 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 c'è spazio per una linea tra i due raccordi + pEnd = Point3d((L/2),-(H/2)+rf,dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(((L/2)-rf),-(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-((L/2)-rf),-(H/2),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(-(L/2),(-(H/2)+rf),dThickD) + 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 c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-(L/2),((H/2)-rf),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d(-((L/2)-rf),(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è spazio per una linea tra i due raccordi + pEnd = Point3d(((L/2)-rf),(H/2),dThickD) + 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 + EgtInvertCurve( hint) + end + end + + return hint +end + +local function MakeRectWithFillet( Lg, P1, P2, Rf, Ang) + + local hint_3 = EgtRectangle2P( Lg, P1, P2, GDB_RT.LOC) + + if hint_3 then + + local nNewId, nNumEnt = EgtExplodeCurveCompo( hint_3) + + if nNewId and nNumEnt and nNumEnt > 0 then + + local pStartIni + + -- se devo inserire i raccordi + if Rf > 0 then + + local tIdFil = {} + local nLine + for p = 1, (nNumEnt-1) do + nLine = EgtCurveFillet( Lg, ( nNewId + p - 1), EgtEP( nNewId + p - 1), ( nNewId + p), EgtSP( nNewId + p), Rf, true) + table.insert( tIdFil, nLine) + end + nLine = EgtCurveFillet( Lg, ( nNewId + nNumEnt - 1), EgtEP( nNewId + nNumEnt - 1), nNewId, EgtSP(nNewId), Rf, true) + table.insert( tIdFil, nLine) + + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, tIdFil[1], (nNewId+1), tIdFil[2], (nNewId+2), tIdFil[3], (nNewId+3), tIdFil[4]}, true) + else + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, (nNewId+1), (nNewId+2), (nNewId+3)}, true) + end + + if hint_3 then + EgtChangeClosedCurveStartPoint( hint_3, pStartIni, GDB_RT.LOC) -- cambio punto di inizio + if Ang ~= 0 then + EgtRotate( hint_3, EgtGP( hint_3), Z_AX(), Ang, GDB_RT.LOC) -- ruoto + end + end + end + end + + return hint_3 +end + +-- Funzione di sistemazione parametri +function fc_rectangle.AdjustParams( tMhPar) + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local nTempT3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local dMaxMat3 + local sMchngName3 + local sLGR + local nLGRi = 1 + + -- setto le variabili dimensioni porta + tMhPar.W = DGD.dW + tMhPar.L = DGD.dH + + tMhPar.type = 2 -- 1: lines, 2: rectangle + + -- variabile supporto calcolo offset + tMhPar.esfr = 0 + + -- nome geometria e diametri utensili delle associate lavorazioni + if tMhPar.LGR then + sLGR = tMhPar.LGR + if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLGR, nLGRi) 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.d3 and nTempT3 <= 0 then + dNumLog = -2795 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLGR, nLGRi, tMhPar.d3, dNumLog, sMchngName3) + elseif nTempT3 then + tMhPar.d3 = nTempT3 + end + end + + -- se il diametro non è stato definito (dal controllo lavorazione) + if not tMhPar.d3 then tMhPar.d3 = 0 end + + -- assegnamento valore a variabili di appoggio + if not tMhPar.ctr then -- se non devo considerare l'utensile + tMhPar.esfr = 0 + else -- considero l'utensile + tMhPar.esfr = tMhPar.d3/2 + end + + if not tMhPar.rf then + tMhPar.rf = 0 + else + tMhPar.rf = abs(tMhPar.rf) + end + + if tMhPar.rf > 0 then -- se c'è raccordo disattivo gli sbordi + tMhPar.pre = nil + end + + --------------------------------------- + -- setto parametri da ddf + --------------------------------------- + + -- profondità + if DGD.DEPTH then + if tMhPar.Dhr then + tMhPar.Dhr = EgtIf( DGD.DEPTH >= DGD.dT, 0, DGD.DEPTH) + end + end + + if DGD.DFT and DGD.DFT > 0 then -- se ho distanza top + tMhPar.tdr = DGD.DFT + end + + if DGD.DFB and DGD.DFB > 0 then -- se ho distanza bottom + tMhPar.bdr = DGD.DFB + end + + if DGD.DFL and DGD.DFL > 0 then -- se ho distanza lock + tMhPar.ldr = DGD.DFL + end + + if DGD.DFH and DGD.DFH > 0 then -- se ho distanza hinge + tMhPar.hdr = DGD.DFH + end + + if not tMhPar.clr then -- se non è definita la lunghezza di arresto + tMhPar.clr = -tMhPar.d3*0.75 + else + tMhPar.clr = abs(tMhPar.clr) + end + + if not tMhPar.cir then -- se non è definita la lunghezza di arresto alle intersezioni + tMhPar.cir = 0 + else + tMhPar.cir = abs(tMhPar.cir) + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + -- se la profondità delle linee verticali è maggiore della capacita utensile limito la profondità ed emetto un warning + if tMhPar.Dhr and dMaxMat3 and tMhPar.Dhr > dMaxMat3 then + dNumLog = -2794 + dNumMessage = 549 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.Dhr), EgtToUiUnits(dMaxMat3)) + tMhPar.Dhr = dMaxMat3 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function fc_rectangle.Draw( tFDecorPar, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le variabili per rettangolo + local Dhr = tFDecorPar.Dhr + local rty = tFDecorPar.rty + local ofr = tFDecorPar.ofr + local rer = tFDecorPar.rer + local tdr = tFDecorPar.tdr + local bdr = tFDecorPar.bdr + local ldr = tFDecorPar.ldr + local hdr = tFDecorPar.hdr + local rw = tFDecorPar.rw + local rl = tFDecorPar.rl + local rf = tFDecorPar.rf + local clr = tFDecorPar.clr + local cir = tFDecorPar.cir + local esfr = tFDecorPar.esfr + local d3 = tFDecorPar.d3 + -- Assegno variabili comuni + local pre = tFDecorPar.pre + local dtype = tFDecorPar.type + local L = tFDecorPar.L + local W = tFDecorPar.W + + -- Assegno i nomi geometrie + local LGR = tFDecorPar.LGR + local DM = 'DUMMY' + + -- variabili per messaggi e settaggi vari + local sCompoName = tFDecorPar.Nome + local nCompoNpar = tFDecorPar.Npar + local sCompoPath = tFDecorPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tFDecorPar.nCod + local sCodAdj = tFDecorPar.sCod + -- variabili per messaggi di errore + local sNamePar1 = 'rl' + local sNamePar2 = 'rw' + local sNamePar5 = 'Dhr' + local sNamePar6 = 'rf' + local sNamePar9 = 'ldr' + local sNamePar10 = 'tdr' + local sNamePar11 = 'ofr' + local sNamePar12 = 'hdr' + local sNamePar13 = 'bdr' + + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2700 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom3 = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + if not Dhr or Dhr < GEO.EPS_SMALL or ( rty and rty == 1 and ( rl < GEO.EPS_SMALL or rw < GEO.EPS_SMALL)) then -- se rettangolo con spessore o dimensioni a 0 + bMakeFaceGeom3 = false + end +-- if nForceMakeFace == 0 then -- se solo geometria disabilito il raggio fresa +-- esfr = 0 +-- end + if ldr then ldr = abs(ldr) end + if hdr then hdr = abs(hdr) end + if tdr then tdr = abs(tdr) end + if bdr then bdr = abs(bdr) end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + 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 + -- Layer + local Dm + + local Lg + local GId + local hint + local nRev + local pIni, pEnd + local dStartValX, dStopValX + local dStartValY, dStopValY + local dValXv1Ini, dValXv1End, dValYv1Ini, dValYv1End -- prima linea verticale + local dValXv2Ini, dValXv2End, dValYv2Ini, dValYv2End -- seconda linea verticale + local dValXh1Ini, dValXh1End, dValYh1Ini, dValYh1End -- prima linea orizzontale + local dValXh2Ini, dValXh2End, dValYh2Ini, dValYh2End -- seconda linea orizzontale + local dStart + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName(Dm,DM) + end + + if nForceMakeFace ~= 1 then -- se abilitata geometria esterna + + if bMakeFaceGeom3 then -- se posso fare rettangolo + if not rty or rty == 0 then -- se rettangolo con offset + -- messaggio di errore + if 2*(abs(ofr)+esfr) >= W or 2*(abs(ofr)+esfr) >= L then -- se offset troppo grande + EC = 26 + EM = string.format( EgtDoorsMsg[649], sNamePar11, EgtToUiUnits(ofr), EgtToUiUnits(esfr), EgtToUiUnits(min(((W/2)-esfr),((L/2)-esfr))-0.01), sCompoPath) + return (ErrorBase+EC), EM + end + + -- al valore dell'offset viene aggiunta al raggio utensile + -- il rettangolo può risultare quindi inferiore + GId = EgtRectangle2P( Lg, Point3d( -(W/2)+(abs(ofr)+esfr), -(L/2)+(abs(ofr)+esfr), 0), Point3d( (W/2)-(abs(ofr)+esfr), (L/2)-(abs(ofr)+esfr), 0), GDB_RT.GLOB) + if GId then + -- cambio il punto di inizio in centro al lato inferiore + EgtChangeClosedCurveStartPoint( GId, Point3d( 0, -(L/2)+(abs(ofr)+esfr), 0), GDB_RT.GLOB) + EgtMove( GId, Point3d(W/2,L/2,0) - ORIG()) + EgtModifyCurveThickness( GId, -Dhr) -- di default è sul lato keyway + EgtSetName( GId, LGR) + end + else -- rettangolo con geometria + + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze ricalcolo le dimensioni e il raccordo perché sono le distanze dai bordi a essere preservate + + rw = W - ldr - hdr - (esfr*4) + rl = L - tdr - bdr - (esfr*4) + -- forzo la geometria a un valore che poi viene calcolato comunque dalle distanze dai bordi. + -- con valore 0 si ottiene la centratura del rettangolo risultante con la porta + -- con valori 1, 2, 4 e 5 si rispettano le distanze dai bordi + -- con valori 3 e 6 si ottiene la centratura in X del rettangolo risultante, le distanze top e bottom rispettano i relativi parametri. + -- con valori 7 e 8 si ottiene la centratura in Y del rettangolo risultante, le distanze lock e hinge rispettano i relativi parametri. + rer = 1 + + -- se le dimensioni risultano negative do errore + if rw+(esfr*2) <= 0 then + EC = 27 + EM = string.format( EgtDoorsMsg[626], sNamePar9..'+'..sNamePar12, EgtToUiUnits(ldr+hdr), EgtToUiUnits(W-(esfr*2)-0.01), sCompoPath) + return (ErrorBase+EC), EM + elseif rl+(esfr*2) <= 0 then + EC = 28 + EM = string.format( EgtDoorsMsg[626], sNamePar10..'+'..sNamePar13, EgtToUiUnits(tdr+bdr), EgtToUiUnits(L-(esfr*2)-0.01), sCompoPath) + return (ErrorBase+EC), EM + end + + -- se ho il raccordo + if rf then + rf = rf - (esfr*2) + end + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if rl and rw and rf then + if 2*rf > min(rl,rw) then + rf = min(rl,rw)/2 + end + end + + if rf > 0 or not pre or pre == 0 then -- rettangolo con raccordo o non ho prelazione + + local dCompareRadius = rf + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + dCompareRadius = dCompareRadius + esfr + end + + if dCompareRadius > 0 then -- rettangolo con raccordo + -- alle dimensioni del rettangolo viene aggiunto il diametro utensile + -- il rettangolo può risultare quindi maggiorato + GId = DrawRectangleWithFillet ( Lg, rw+(2*esfr), rl+(2*esfr), 0, rf+esfr) + else -- senza raccordo + -- alle dimensioni del rettangolo viene aggiunto il diametro utensile + -- il rettangolo puo' risultare quindi maggiorato + GId = EgtRectangle2P( Lg, Point3d( -(rw/2)-esfr, -(rl/2)-esfr, 0), Point3d( (rw/2)+esfr, (rl/2)+esfr, 0), GDB_RT.GLOB) + end + + if GId then + -- cambio il punto di inizio in centro al lato inferiore + EgtChangeClosedCurveStartPoint( GId, Point3d( 0, -(rl/2)-esfr, 0), GDB_RT.GLOB) + if not rer or rer == 0 then -- se in centro + EgtMove( GId, Point3d(W/2,L/2,0) - ORIG()) + elseif rer == 1 then -- se riferito top-lock + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + EgtMove( GId, Point3d(((rw+(2*esfr))/2)+(ldr+esfr),L-((rl+(2*esfr))/2)-(tdr+esfr),0) - ORIG()) + else + EgtMove( GId, Point3d(((rw+(2*esfr))/2)+(ldr-esfr),L-((rl+(2*esfr))/2)-(tdr-esfr),0) - ORIG()) + end + elseif rer == 2 then -- se riferito top-hinge + EgtMove( GId, Point3d(W-((rw+(2*esfr))/2)-(hdr-esfr),L-((rl+(2*esfr))/2)-(tdr-esfr),0) - ORIG()) + elseif rer == 3 then -- se riferito top-center + EgtMove( GId, Point3d(W/2,L-((rl+(2*esfr))/2)-(tdr-esfr),0) - ORIG()) + elseif rer == 4 then -- se riferito bottom-lock + EgtMove( GId, Point3d(((rw+(2*esfr))/2)+(ldr-esfr),((rl+(2*esfr))/2)+(bdr-esfr),0) - ORIG()) + elseif rer == 5 then -- se riferito bottom-hinge + EgtMove( GId, Point3d(W-((rw+(2*esfr))/2)-(hdr-esfr),((rl+(2*esfr))/2)+(bdr-esfr),0) - ORIG()) + elseif rer == 6 then -- se riferito bottom-center + EgtMove( GId, Point3d(W/2,((rl+(2*esfr))/2)+(bdr-esfr),0) - ORIG()) + elseif rer == 7 then -- se riferito center-lock + EgtMove( GId, Point3d(((rw+(2*esfr))/2)+(ldr-esfr),L/2,0) - ORIG()) + elseif rer == 8 then -- se riferito center-hinge + EgtMove( GId, Point3d(W-((rw+(2*esfr))/2)-(hdr-esfr),L/2,0) - ORIG()) + end + EgtModifyCurveThickness( GId, -Dhr) -- di default è sul lato keyway + EgtSetName( GId, LGR) + end + else -- ho prelazione + + if pre == 1 then -- se prelazione su linee verticali + + -- prima linea verticale + if not rer or rer == 0 or rer == 3 or rer == 6 then -- se in centro in X + dValXv1Ini = (W-rw)/2 - esfr + elseif rer == 1 or rer == 4 or rer == 7 then -- se riferito a lock + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + dValXv1Ini = ldr + esfr + else + dValXv1Ini = ldr - esfr + end + else -- tutti gli altri casi (riferito a hinge) + dValXv1Ini = W - hdr + esfr + end + dValXv1End = dValXv1Ini + dValYv1Ini = L - clr -- posizione in alto + dValYv1End = clr + + -- disegno linea + pIni = Point3d( dValXv1Ini, dValYv1Ini, 0) + pEnd = Point3d( dValXv1End, dValYv1End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- seconda linea verticale + if rer and ( rer == 2 or rer == 5 or rer == 8) then -- se riferito a hinge + dValXv2Ini = dValXv1Ini - rw - 2*esfr + else -- tutti gli altri casi (riferito a lock) + dValXv2Ini = dValXv1Ini + rw + 2*esfr + end + dValXv2End = dValXv2Ini + dValYv2Ini = L - clr -- posizione in alto + dValYv2End = clr + + -- disegno linea + pIni = Point3d( dValXv2Ini, dValYv2Ini, 0) + pEnd = Point3d( dValXv2End, dValYv2End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- prima linea orizzontale + if not rer or rer == 0 or rer == 7 or rer == 8 then -- se in centro + dValYh1Ini = (L+rl)/2 + esfr + elseif rer >= 1 and rer <= 3 then -- se riferito top + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + dValYh1Ini = L - tdr - esfr + else + dValYh1Ini = L - tdr + esfr + end + else -- tutti gli altri casi (bottom) + dValYh1Ini = bdr - esfr + end + dValYh1End = dValYh1Ini + + if rer and ( rer == 2 or rer == 5 or rer == 8) then -- se riferito a hinge + dValXh1Ini = dValXv1Ini - cir + dValXh1End = dValXv2Ini + cir + else -- negli altri casi (riferito a lock) + dValXh1Ini = dValXv1Ini + cir + dValXh1End = dValXv2Ini - cir + end + + -- disegno linea + pIni = Point3d( dValXh1Ini, dValYh1Ini, 0) + pEnd = Point3d( dValXh1End, dValYh1End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- seconda linea orizzontale + if rer and ( rer >= 4 and rer <= 6) then -- se riferito a bottom + dValYh2Ini = dValYh1Ini + rl + 2*esfr + else -- in tutti gli altri casi (top) + dValYh2Ini = dValYh1Ini - rl - 2*esfr + end + dValYh2End = dValYh2Ini + + if rer and ( rer == 2 or rer == 5 or rer == 8) then + dValXh2Ini = dValXv1Ini - cir + dValXh2End = dValXv2Ini + cir + else -- negli altri casi + dValXh2Ini = dValXv1Ini + cir + dValXh2End = dValXv2Ini - cir + end + + -- disegno linea + pIni = Point3d( dValXh2Ini, dValYh2Ini, 0) + pEnd = Point3d( dValXh2End, dValYh2End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + else -- ho prelazione su linee orizzontali + + -- prima linea orizzontale + if not rer or rer == 0 or rer == 7 or rer == 8 then -- se in centro + dValYh1Ini = (L+rl)/2 + esfr + elseif rer >= 1 and rer <= 3 then -- se riferito top + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + dValYh1Ini = L - tdr - esfr + else + dValYh1Ini = L - tdr + esfr + end + else -- tutti gli altri casi (bottom) + dValYh1Ini = bdr - esfr + end + dValYh1End = dValYh1Ini + dValXh1Ini = clr -- posizione a sinistra + dValXh1End = W - clr + + -- disegno linea + pIni = Point3d( dValXh1Ini, dValYh1Ini, 0) + pEnd = Point3d( dValXh1End, dValYh1End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- seconda linea orizzontale + if rer and ( rer >= 4 and rer <= 6) then -- se riferito a bottom + dValYh2Ini = dValYh1Ini + rl + 2*esfr + else -- in tutti gli altri casi + dValYh2Ini = dValYh1Ini - rl - 2*esfr + end + dValYh2End = dValYh2Ini + dValXh2Ini = clr -- posizione a sinistra + dValXh2End = W - clr + + -- disegno linea + pIni = Point3d( dValXh2Ini, dValYh2Ini, 0) + pEnd = Point3d( dValXh2End, dValYh2End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- prima linea verticale + if not rer or rer == 0 or rer == 3 or rer == 6 then -- se in centro + dValXv1Ini = (W-rw)/2 - esfr + elseif rer == 1 or rer == 4 or rer == 7 then -- se riferito a lock + if rty and rty == 2 then -- se rettangolo ricavato dalle distanze + dValXv1Ini = ldr + esfr + else + dValXv1Ini = ldr - esfr + end + else -- tutti gli altri casi (riferito a hinge) + dValXv1Ini = W - hdr + esfr + end + dValXv1End = dValXv1Ini + + if rer and ( rer >= 4 and rer <= 6) then -- se riferito a bottom + dValYv1Ini = dValYh1Ini + cir + dValYv1End = dValYh2Ini - cir + else -- tutti gli altri casi (top) + dValYv1Ini = dValYh1Ini - cir + dValYv1End = dValYh2Ini + cir + end + + -- disegno linea + pIni = Point3d( dValXv1Ini, dValYv1Ini, 0) + pEnd = Point3d( dValXv1End, dValYv1End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + + -- seconda linea verticale + if rer and ( rer == 2 or rer == 5 or rer == 8) then -- se in centro + dValXv2Ini = dValXv1Ini - rw - 2*esfr + else -- tutti gli altri casi + dValXv2Ini = dValXv1Ini + rw + 2*esfr + end + dValXv2End = dValXv2Ini + + if rer and ( rer >= 4 and rer <= 6) then -- se riferito a bottom + dValYv2Ini = dValYh1Ini + cir + dValYv2End = dValYh2Ini - cir + else -- tutti gli altri casi (top) + dValYv2Ini = dValYh1Ini - cir + dValYv2End = dValYh2Ini + cir + end + + -- disegno linea + pIni = Point3d( dValXv2Ini, dValYv2Ini, 0) + pEnd = Point3d( dValXv2End, dValYv2End, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d3/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhr) -- di default è sul lato keyway + EgtSetName( hint, LGR) + end + end + end + + -- messaggi di errore (dopo aver fatto il disegno) + if rty and rty == 1 then -- se rettangolo con dimensioni definite + if not rer or rer == 0 then -- se in centro + if rw + (2*esfr) >= W then -- se larghezza rettangolo è più grande della larghezza porta + EC = 29 + EM = string.format( EgtDoorsMsg[626], sNamePar2, EgtToUiUnits(rw), EgtToUiUnits(W-(2*esfr)-0.001), sCompoPath) + return (ErrorBase+EC), EM + elseif rl + (2*esfr) >= L then -- se altezza rettangolo è più grande dell'altezza porta + EC = 30 + EM = string.format( EgtDoorsMsg[626], sNamePar1, EgtToUiUnits(rl), EgtToUiUnits(L-(2*esfr)-0.001), sCompoPath) + return (ErrorBase+EC), EM + end + else + if rw + (2*esfr) >= W then -- se larghezza rettangolo è più grande della larghezza porta + EC = 31 + EM = string.format( EgtDoorsMsg[626], sNamePar2, EgtToUiUnits(rw), EgtToUiUnits(W-(2*esfr)-0.001), sCompoPath) + return (ErrorBase+EC), EM + elseif rl + (2*esfr) >= L then -- se altezza rettangolo è più grande dell'altezza porta + EC = 32 + EM = string.format( EgtDoorsMsg[626], sNamePar1, EgtToUiUnits(rl), EgtToUiUnits(L-(2*esfr)-0.001), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer == 2 or rer == 5 or rer == 8) and ( hdr+esfr+rw >= W) then -- se riferito a hinge e sborda in X + EC = 33 + EM = string.format( EgtDoorsMsg[650], sNamePar12, EgtToUiUnits(hdr), sNamePar2, EgtToUiUnits(rw), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer == 2 or rer == 5 or rer == 8) and ( hdr-esfr <= 0) then -- se riferito a hinge e sborda in X + EC = 34 + EM = string.format( EgtDoorsMsg[665], sNamePar12, EgtToUiUnits(hdr), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and (rer == 1 or rer == 4 or rer == 7) and (ldr+esfr+rw >= W) then -- se riferito a lock e sborda in X + EC = 35 + EM = string.format( EgtDoorsMsg[650], sNamePar9, EgtToUiUnits(ldr), sNamePar2, EgtToUiUnits(rw), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and (rer == 1 or rer == 4 or rer == 7) and (ldr-esfr <= 0) then -- se riferito a lock e sborda in X + EC = 36 + EM = string.format( EgtDoorsMsg[665], sNamePar9, EgtToUiUnits(ldr), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer >= 4 and rer <= 6) and (bdr+esfr+rl >= L) then -- se riferito a bottom e sborda in Y + EC = 37 + EM = string.format( EgtDoorsMsg[651], sNamePar13, EgtToUiUnits(bdr), sNamePar1, EgtToUiUnits(rl), EgtToUiUnits(esfr*2), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer >= 4 and rer <= 6) and (bdr-esfr <= 0) then -- se riferito a bottom e sborda in Y + EC = 38 + EM = string.format( EgtDoorsMsg[666], sNamePar13, EgtToUiUnits(bdr), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer >= 1 and rer <= 3) and (tdr+esfr+rl >= L) then -- se riferito a top e rettangolo sborda in Y + EC = 39 + EM = string.format( EgtDoorsMsg[651], sNamePar10, EgtToUiUnits(tdr), sNamePar1, EgtToUiUnits(rl), EgtToUiUnits(esfr*2), sCompoPath) + return (ErrorBase+EC), EM + elseif rer and ( rer >= 1 and rer <= 3) and (tdr-esfr <= 0) then -- se riferito a top e rettangolo sborda in Y + EC = 40 + EM = string.format( EgtDoorsMsg[666], sNamePar10, EgtToUiUnits(tdr), EgtToUiUnits(esfr), sCompoPath) + return (ErrorBase+EC), EM + end + end + end + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + EgtSetColor( Lg or GDB_ID.NULL, AQUA()) + else + EgtSetColor( Lg or GDB_ID.NULL, ORANGE()) + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'fc_rectangle') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'W' ,W) + EgtSetInfo(Lg,'Dhr' ,Dhr) + EgtSetInfo(Lg,'rty' ,rty) + EgtSetInfo(Lg,'ofr' ,ofr) + EgtSetInfo(Lg,'rer' ,rer) + EgtSetInfo(Lg,'tdr' ,tdr) + EgtSetInfo(Lg,'bdr' ,bdr) + EgtSetInfo(Lg,'ldr' ,ldr) + EgtSetInfo(Lg,'hdr' ,hdr) + EgtSetInfo(Lg,'rw' ,rw) + EgtSetInfo(Lg,'rl' ,rl) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'clr' ,clr) + EgtSetInfo(Lg,'cir' ,cir) + EgtSetInfo(Lg,'esfr' ,esfr) + EgtSetInfo(Lg,'pre' ,pre) + EgtSetInfo(Lg,'dtype' ,dtype) + EgtSetInfo(Lg,'LGR' ,LGR) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return fc_rectangle diff --git a/LuaLibs/FaceDecoration.lua b/LuaLibs/FaceDecoration.lua new file mode 100644 index 0000000..63fc083 --- /dev/null +++ b/LuaLibs/FaceDecoration.lua @@ -0,0 +1,129 @@ +-- +-- 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 +-- +-- FaceDecoration.lua by EgalWare s.r.l. 2019.05.07 +-- Autore: Filippo Monchi +-- FaceDecoration dati i valori 'Thickness' e 'face' e con nome attributo + +-- 2019.05.07 V1.000 FM Write Component +-- 2019.09.24 V1.001 FM Manage side distance parameters (top, bottom, lock, hinge) from ddf +-- 2019.09.25 V1.002 FM Fix some error on calculate lines and rectangle position when diameter tool used +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.18 V2.000 FM Manage to draw not premptive lines between premptive lines only if premptive lines are 2 and their start and stop +-- distances are defined and without or zero step value +-- 2022.07.27 V2.001 FM Modification to use compiled code +-- 2023.05.15 V2.002 FM fix errors (x/0) when exists only 1 horizontal line and/or only 1 vertical line and both distances ( from reference and opposite sides) are difined +-- 2024.03.04 V2.100 FM Manage Custom lua decoration, managed by external file (defined into .templ file as .luc extension) + +-- Tavola per definizione modulo (serve ma non usata) +local FaceDecoration = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Funzione di sistemazione parametri +function FaceDecoration.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + + -- setto le variabili dimensioni porta + tMhPar.W = DGD.dW + tMhPar.L = DGD.dH + + if string.lower(DGD.TYPE) == 'lines' then + + tMhPar.type = 1 -- 1: lines, 2: rectangle, 3: custom + tMhPar.CGF = 'Fc_Lines.lua' + + -- percorso custom + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + end + elseif not tMhPar.CGP then + tMhPar.CGP = DGD.BASEDIR .. 'LuaLibs\\' + end + elseif string.lower(DGD.TYPE) == 'rectangle' then + + tMhPar.type = 2 -- 1: lines, 2: rectangle, 3: custom + tMhPar.CGF = 'FC_Rectangle.lua' + + -- percorso custom + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + end + elseif not tMhPar.CGP then + tMhPar.CGP = DGD.BASEDIR .. 'LuaLibs\\' + end + else + + tMhPar.type = 3 -- 1: lines, 2: rectangle, 3: custom + + if not tMhPar.CGP then + tMhPar.CGP = tMhPar.ITP + end + + -- percorso custom + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + end + end + end + + -- verifico esiste il file + local sFilePath,sFileName,sFileExt = EgtSplitPath( string.lower(tMhPar.CGP..tMhPar.CGF)) + + if not EgtExistsFile( string.lower(tMhPar.CGP..tMhPar.CGF)) then-- provo con lua + dNumLog = 2745 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[411], tMhPar.CGP..tMhPar.CGF, DGD.FILE) + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function FaceDecoration.Draw( tFDecorPar, bPreview, bRunByCompo, nDrawMach) + + -- verifico esiste il file + local sFilePath, sFileName, sFileExt = EgtSplitPath( string.lower(tFDecorPar.CGP..tFDecorPar.CGF)) + + -- se file custom aggiungo la path + if tFDecorPar.type == 3 then + EgtAddToPackagePath( tFDecorPar.CGP .. '?.luc') + end + -- Lancio il componente base + local VLOgen = require( sFileName) + tFaceDecorPar, nCod, sCod = VLOgen.AdjustParams( tFaceDecorPar) + if nCod > 0 then + return nCod, sCod + else + tFaceDecorPar.nCod = nCod + tFaceDecorPar.sCod = sCod + end + return VLOgen.Draw( tFaceDecorPar, false, false, DGD.MachEn) +end + +return FaceDecoration diff --git a/LuaLibs/Fc_Lines.lua b/LuaLibs/Fc_Lines.lua new file mode 100644 index 0000000..ba4d627 --- /dev/null +++ b/LuaLibs/Fc_Lines.lua @@ -0,0 +1,1009 @@ +-- +-- 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 +-- +-- fc_lines.lua by EgalWare s.r.l. 2019.05.07 +-- Autore: Filippo Monchi +-- fc_lines dati i valori 'Thickness' e 'face' e con nome attributo + +-- 2019.05.07 V1.000 FM Write Component +-- 2019.09.24 V1.001 FM Manage side distance parameters (top, bottom, lock, hinge) from ddf +-- 2019.09.25 V1.002 FM Fix some error on calculate lines and rectangle position when diameter tool used +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.18 V2.000 FM Manage to draw not premptive lines between premptive lines only if premptive lines are 2 and their start and stop +-- distances are defined and without or zero step value +-- 2022.07.27 V2.001 FM Modification to use compiled code +-- 2023.05.15 V2.002 FM fix errors (x/0) when exists only 1 horizontal line and/or only 1 vertical line and both distances ( from reference and opposite sides) are difined + +-- Tavola per definizione modulo (serve ma non usata) +local fc_lines = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 4. -- valore minimo lato + +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 + +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 sistemazione parametri +function fc_lines.AdjustParams( tMhPar) + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local nTempT1 + local nTempT2 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local dMaxMat1 + local dMaxMat2 + local sMchngName1 + local sMchngName2 + local sLGV + local nLGVi = 1 + local sLGH + local nLGHi = 1 + + -- setto le variabili dimensioni porta + tMhPar.W = DGD.dW + tMhPar.L = DGD.dH + + tMhPar.type = 1 -- 1: lines, 2: rectangle + + -- variabile supporto calcolo passi linee verticali + tMhPar.esfv = 0 -- eventuale raggio fresa + -- variabile supporto calcolo passi linee orizzontali + tMhPar.esfh = 0 -- eventuale raggio fresa + + -- nomi geometrie e diametri utensili delle associate lavorazioni + if tMhPar.LGV then + sLGV = tMhPar.LGV + if DGD.MachEn > 0 and tMhPar.d1 then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLGV, nLGVi) end + end + if tMhPar.LGH then + sLGH = tMhPar.LGH + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLGH, nLGHi) 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.d1 and nTempT1 <= 0 then + dNumLog = -2799 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLGV, nLGVi, tMhPar.d1, dNumLog, sMchngName1) + elseif nTempT1 then + tMhPar.d1 = nTempT1 + end + + if DGD.bProoduce and tMhPar.d2 and nTempT2 <= 0 then + dNumLog = -2798 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLGH, nLGHi, tMhPar.d2, dNumLog, sMchngName2) + elseif nTempT2 then + tMhPar.d2 = nTempT2 + end + end + + -- se i diametri non sono stati definiti (dal controllo lavorazione) + if not tMhPar.d1 then tMhPar.d1 = 0 end + if not tMhPar.d2 then tMhPar.d2 = 0 end + + -- assegnamento valore a variabili di appoggio + if not tMhPar.ctv then -- se non devo considerare l'utensile + tMhPar.esfv = 0 + else -- considero l'utensile + tMhPar.esfv = tMhPar.d1/2 + end + + if not tMhPar.cth then -- se non devo considerare l'utensile + tMhPar.esfh = 0 + else -- considero l'utensile + tMhPar.esfh = tMhPar.d2/2 + end + + --------------------------------------- + -- setto parametri da ddf + --------------------------------------- + + -- profondità + if DGD.DEPTH then + if tMhPar.Dvl then + tMhPar.Dvl = EgtIf( DGD.DEPTH >= DGD.dT, 0, DGD.DEPTH) + end + if tMhPar.Dhl then + tMhPar.Dhl = EgtIf( DGD.DEPTH >= DGD.dT, 0, DGD.DEPTH) + end + end + + -- se c'è distanza da top + if DGD.DFT and DGD.DFT > 0 then + tMhPar.reh = false -- setto per partire da top + else -- non c'è la distanza da top + -- se la distanza da bottom è valida + if DGD.DFB and DGD.DFB > 0 then + tMhPar.reh = true -- setto per partire da bottom +-- else -- altrimenti la distanza da bottom non è valida +-- tMhPar.reh = false -- setto per partire da top + end + end + + if not tMhPar.reh then -- se devo partire da top + + if DGD.DFT and DGD.DFT > 0 then -- se ho distanza top + tMhPar.dsh = DGD.DFT + tMhPar.esfh -- aggiungo il raggio + else + if not tMhPar.dsh then -- se non è definito lo setto a 0 + tMhPar.dsh = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dsh <= GEO.EPS_SMALL then + tMhPar.dsh = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dsh = abs(tMhPar.dsh) + tMhPar.esfh + end + end + + if DGD.DFB and DGD.DFB > 0 then -- se ho distanza bottom + tMhPar.doh = DGD.DFB + tMhPar.esfh -- aggiungo il raggio + else + if not tMhPar.doh then -- se non è definito lo setto a 0 + tMhPar.doh = 0 -- setto distanza dal bordo della linea + elseif tMhPar.doh <= GEO.EPS_SMALL then + tMhPar.doh = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.doh = abs(tMhPar.doh) + tMhPar.esfh + end + end + else -- altrimenti partire da bottom + + if DGD.DFB and DGD.DFB > 0 then -- se ho distanza bottom + tMhPar.dsh = DGD.DFB + tMhPar.esfh -- aggiungo il raggio + else + if not tMhPar.dsh then -- se non è definito lo setto a 0 + tMhPar.dsh = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dsh <= GEO.EPS_SMALL then + tMhPar.dsh = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dsh = abs(tMhPar.dsh) + tMhPar.esfh + end + end + + if DGD.DFT and DGD.DFT > 0 then -- se ho distanza top + tMhPar.doh = DGD.DFT + tMhPar.esfh -- aggiungo il raggio + else + if not tMhPar.doh then -- se non è definito lo setto a 0 + tMhPar.doh = 0 -- setto distanza dal bordo della linea + elseif tMhPar.doh <= GEO.EPS_SMALL then + tMhPar.doh = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.doh = abs(tMhPar.doh) + tMhPar.esfh + end + end + end + + -- se c'è distanza da lock + if DGD.DFL and DGD.DFL > 0 then + tMhPar.rev = false -- setto per partire da lock + else -- non c'è la distanza da lock + -- se la distanza da hinge è valida + if DGD.DFH and DGD.DFH > 0 then + tMhPar.rev = true -- setto per partire da hinge +-- else -- altrimenti la distanza da hinge non è valida +-- tMhPar.rev = false -- setto per partire da lock + end + end + + if not tMhPar.rev then -- se devo partire da lock + + if DGD.DFL and DGD.DFL > 0 then -- se ho distanza lock + tMhPar.dsv = DGD.DFL + tMhPar.esfv -- aggiungo il raggio + else + if not tMhPar.dsv then -- se non è definito lo setto a 0 + tMhPar.dsv = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dsv <= GEO.EPS_SMALL then + tMhPar.dsv = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dsv = abs(tMhPar.dsv) + tMhPar.esfv + end + end + + if DGD.DFH and DGD.DFH > 0 then -- se ho distanza hinge + tMhPar.dov = DGD.DFH + tMhPar.esfv -- aggiungo il raggio + else + if not tMhPar.dov then -- se non è definito lo setto a 0 + tMhPar.dov = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dov <= GEO.EPS_SMALL then + tMhPar.dov = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dov = abs(tMhPar.dov) + tMhPar.esfv + end + end + else -- altrimenti partire da hinge + + if DGD.DFH and DGD.DFH > 0 then -- se ho distanza hinge + tMhPar.dsv = DGD.DFH + tMhPar.esfv -- aggiungo il raggio + else + if not tMhPar.dsv then -- se non è definito lo setto a 0 + tMhPar.dsv = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dsv <= GEO.EPS_SMALL then + tMhPar.dsv = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dsv = abs(tMhPar.dsv) + tMhPar.esfv + end + end + + if DGD.DFL and DGD.DFL > 0 then -- se ho distanza lock + tMhPar.dov = DGD.DFL + tMhPar.esfv -- aggiungo il raggio + else + if not tMhPar.dov then -- se non è definito lo setto a 0 + tMhPar.dov = 0 -- setto distanza dal bordo della linea + elseif tMhPar.dov <= GEO.EPS_SMALL then + tMhPar.dov = 0 -- setto distanza dal bordo della linea + else -- altrimenti gli sommo eventuale raggio utensile + tMhPar.dov = abs(tMhPar.dov) + tMhPar.esfv + end + end + end + + -- se ci sono linee verticali + if tMhPar.LGV and tMhPar.nvl and tMhPar.nvl > 0 then + + if not tMhPar.clv then -- se non è definita la lunghezza di arresto + tMhPar.clv = -tMhPar.d1*0.75 -- calcolo l'uscita pari a 3/4 del diametro + else -- la distanza è definita + -- setto l'arretramento con il valore assoluto + tMhPar.clv = abs(tMhPar.clv) + end + + if not tMhPar.civ then -- se non è definita la lunghezza di arresto alle intersezioni + tMhPar.civ = EgtIf( tMhPar.d1 > tMhPar.d2, ((tMhPar.d1-tMhPar.d2)/2), 0) -- setto al differenza tra raggio utensili se ha diametro maggiore + else + tMhPar.civ = abs(tMhPar.civ) + end + + -- setto una variabile di appoggio con il valore nullo del passo + tMhPar.estv = tMhPar.stv + + if not tMhPar.stv then -- se passo non specificato per linee verticali, lo calcolo + -- se non devo considerare l'utensile + if not tMhPar.ctv then + local nNumAreaTot + if (tMhPar.dsv > 0) and (tMhPar.dov > 0) then -- se entrambe gli estremi definiti + -- se ho una sola linea prendo il lato di riferimento + if tMhPar.nvl <= 1 then + tMhPar.dov = 0 + nNumAreaTot = tMhPar.nvl + else + nNumAreaTot = tMhPar.nvl - 1 + end + elseif (tMhPar.dsv > 0) or (tMhPar.dov > 0) then -- se solo un estremo definito + nNumAreaTot = tMhPar.nvl + else -- nessun estremo definito + nNumAreaTot = tMhPar.nvl + 1 + end + + tMhPar.stv = ( tMhPar.W - tMhPar.dsv - tMhPar.dov) / nNumAreaTot +-- tMhPar.stv = ( tMhPar.W - tMhPar.dsv - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) / ( tMhPar.nvl + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 0, 1)) + else -- considero l'utensile + + local nNumAreaTot + local nNumLineToCount + local nCaseDist = 0 + + if (tMhPar.dsv > 0) and (tMhPar.dov > 0) then -- se entrambe gli estremi definiti + -- se ho una sola linea prendo il lato di riferimento + if tMhPar.nvl <= 1 then + tMhPar.dov = 0 + nNumAreaTot = tMhPar.nvl + nCaseDist = 1 + else + nNumAreaTot = tMhPar.nvl - 1 + nCaseDist = 2 + end + nNumLineToCount = nNumAreaTot - 1 + elseif (tMhPar.dsv > 0) or (tMhPar.dov > 0) then -- se solo un estremo definito + nNumAreaTot = tMhPar.nvl + nNumLineToCount = nNumAreaTot - 1 + nCaseDist = 1 + else -- nessun estremo definito + nNumAreaTot = tMhPar.nvl + 1 + nNumLineToCount = nNumAreaTot - 1 + end + + -- calcolo la distanza netta che intercorre tra un taglio e l'altro tranne gli estremi + tMhPar.stv = ((( tMhPar.W - ( tMhPar.dsv + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) - ( tMhPar.dov + EgtIf( tMhPar.dov > GEO.EPS_SMALL, tMhPar.esfv, 0))) - ( nNumLineToCount * tMhPar.esfv * 2) ) / nNumAreaTot) + + -- se non ho nessun estremo lo ricalcolo + if nCaseDist == 0 then + tMhPar.dsv = tMhPar.stv + tMhPar.esfv + end + + -- calcolo il passo: dalla distanza netta aggiungo il diametro utensile + tMhPar.stv = tMhPar.stv + ( tMhPar.esfv * 2) +-- tMhPar.stv = (( tMhPar.W - tMhPar.dsv - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, tMhPar.esfv, 0)) - ( ( tMhPar.nvl - EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 1, 0)) * tMhPar.esfv * 2)) / ( tMhPar.nvl + EgtIf( tMhPar.dsv > GEO.EPS_SMALL, 0, 1)) + end + else -- se passo specificato + -- se devo considerare l'utensile + if tMhPar.ctv then + tMhPar.stv = tMhPar.stv + (tMhPar.esfv*2) + end + + -- se non ho una distanza fissa dal lato di riferimento lo setto con il valore del passo - raggio utensile + if tMhPar.dsv <= GEO.EPS_SMALL then + tMhPar.dsv = abs(tMhPar.stv) - tMhPar.esfv + end + end + end + + -- se ci sono linee orizzontali + if tMhPar.LGH and tMhPar.nhl and tMhPar.nhl > 0 then + + if not tMhPar.clh then -- se non è definita la lunghezza di arresto + tMhPar.clh = -tMhPar.d2*0.75 -- calcolo l'uscita pari a 3/4 del diametro + else -- la distanza è definita + -- setto l'arretramento con il valore assoluto + tMhPar.clh = abs(tMhPar.clh) + end + + if not tMhPar.cih then -- se non è definita la lunghezza di arresto alle intersezioni + tMhPar.cih = EgtIf( tMhPar.d2 > tMhPar.d1, ((tMhPar.d2-tMhPar.d1)/2), 0) -- setto al differenza tra raggio utensili se ha diametro maggiore + else + tMhPar.cih = abs(tMhPar.cih) + end + + -- setto una variabile di appoggio con il valore nullo del passo + tMhPar.esth = tMhPar.sth + + if not tMhPar.sth then -- se passo non specificato per linee orizzontali, lo calcolo + -- se non devo considerare l'utensile + if not tMhPar.cth then + local nNumAreaTot + if (tMhPar.dsh > 0) and (tMhPar.doh > 0) then -- se entrambe gli estremi definiti + -- se ho una sola linea prendo il lato di riferimento + if tMhPar.nhl <= 1 then + tMhPar.doh = 0 + nNumAreaTot = tMhPar.nhl + else + nNumAreaTot = tMhPar.nhl - 1 + end + elseif (tMhPar.dsh > 0) or (tMhPar.doh > 0) then -- se solo un estremo definito + nNumAreaTot = tMhPar.nhl + else -- nessun estremo definito + nNumAreaTot = tMhPar.nhl + 1 + end + + tMhPar.sth = ( tMhPar.L - tMhPar.dsh - tMhPar.doh) / nNumAreaTot + else -- considero l'utensile + + local nNumAreaTot + local nNumLineToCount + local nCaseDist = 0 + + if (tMhPar.dsh > 0) and (tMhPar.doh > 0) then -- se entrambe gli estremi definiti + -- se ho una sola linea prendo il lato di riferimento + if tMhPar.nhl <= 1 then + tMhPar.doh = 0 + nNumAreaTot = tMhPar.nhl + nCaseDist = 1 + else + nNumAreaTot = tMhPar.nhl - 1 + nCaseDist = 2 + end + nNumLineToCount = nNumAreaTot - 1 + elseif (tMhPar.dsh > 0) or (tMhPar.doh > 0) then -- se solo un estremo definito + nNumAreaTot = tMhPar.nhl + nNumLineToCount = nNumAreaTot - 1 + nCaseDist = 1 + else -- nessun estremo definito + nNumAreaTot = tMhPar.nhl + 1 + nNumLineToCount = nNumAreaTot - 1 + end + + -- calcolo la distanza netta che intercorre tra un taglio e l'altro tranne gli estremi + tMhPar.sth = ((( tMhPar.L - ( tMhPar.dsh + EgtIf( tMhPar.dsh > GEO.EPS_SMALL, tMhPar.esfh, 0)) - ( tMhPar.doh + EgtIf( tMhPar.doh > GEO.EPS_SMALL, tMhPar.esfh, 0))) - ( nNumLineToCount * tMhPar.esfh * 2) ) / nNumAreaTot) + + -- se non ho nessun estremo lo ricalcolo + if nCaseDist == 0 then + tMhPar.dsh = tMhPar.sth + tMhPar.esfh + end + + -- calcolo il passo: dalla distanza netta aggiungo il diametro utensile + tMhPar.sth = tMhPar.sth + ( tMhPar.esfh * 2) + end + else -- se passo specificato + -- se devo considerare l'utensile + if tMhPar.cth then + tMhPar.sth = tMhPar.sth + (tMhPar.esfh*2) + end + + -- se non ho una distanza fissa dal lato di riferimento lo setto con il valore del passo - raggio utensile + if tMhPar.dsh <= GEO.EPS_SMALL then + tMhPar.dsh = abs(tMhPar.sth) - tMhPar.esfh + end + end + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + -- se la profondità delle linee verticali è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.Dvl and dMaxMat1 and tMhPar.Dvl > dMaxMat1 then + dNumLog = -2797 + dNumMessage = 549 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.Dvl), EgtToUiUnits(dMaxMat1)) + tMhPar.Dvl = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + -- se la profondità delle linee orizzontali è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.Dhl and dMaxMat2 and tMhPar.Dhl > dMaxMat2 then + dNumLog = -2796 + dNumMessage = 549 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.Dhl), EgtToUiUnits(dMaxMat2)) + tMhPar.Dhl = dMaxMat2 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function fc_lines.Draw( tFDecorPar, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le variabili per linee + local nvl = tFDecorPar.nvl + local dev = tFDecorPar.dev + local Dvl = tFDecorPar.Dvl + local rev = tFDecorPar.rev + local dsv = tFDecorPar.dsv + local dov = tFDecorPar.dov + local stv = tFDecorPar.stv + local estv = tFDecorPar.estv + local clv = tFDecorPar.clv + local civ = tFDecorPar.civ + local esfv = tFDecorPar.esfv + local nhl = tFDecorPar.nhl + local deh = tFDecorPar.deh + local Dhl = tFDecorPar.Dhl + local reh = tFDecorPar.reh + local dsh = tFDecorPar.dsh + local doh = tFDecorPar.doh + local sth = tFDecorPar.sth + local esth = tFDecorPar.esth + local clh = tFDecorPar.clh + local cih = tFDecorPar.cih + local esfh = tFDecorPar.esfh + local d1 = tFDecorPar.d1 + local d2 = tFDecorPar.d2 + -- Assegno variabili comuni + local pre = tFDecorPar.pre + local dtype = tFDecorPar.type + local L = tFDecorPar.L + local W = tFDecorPar.W + + -- Assegno i nomi geometrie + local LGV = tFDecorPar.LGV + local LGH = tFDecorPar.LGH + local DM = 'DUMMY' + + -- variabili per messaggi e settaggi vari + local sCompoName = tFDecorPar.Nome + local nCompoNpar = tFDecorPar.Npar + local sCompoPath = tFDecorPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tFDecorPar.nCod + local sCodAdj = tFDecorPar.sCod + -- variabili per messaggi di errore + local sNamePar3 = 'Dvl' + local sNamePar4 = 'Dhl' + local sNamePar7 = 'clv' + local sNamePar8 = 'clh' + + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2700 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom1 = true + local bMakeFaceGeom2 = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + if not Dvl or Dvl < GEO.EPS_SMALL or not nvl or nvl == 0 then -- se spessore 0 o no linee + bMakeFaceGeom1 = false + end + if not Dhl or Dhl < GEO.EPS_SMALL or not nhl or nhl == 0 then -- se spessore 0 o no linee + bMakeFaceGeom2 = false + end + if nForceMakeFace == 0 then -- se solo geometria disabilito il raggio fresa + esfv = 0 + esfh = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeFaceGeom1 and clv and clv*2 >= L then + EC = 1 + EM = string.format( EgtDoorsMsg[626], sNamePar7, EgtToUiUnits(clv), EgtToUiUnits((L/2)-0.1), sCompoPath) -- il parametro 'clv' deve essere < L/2 + clv = 0 + elseif bMakeFaceGeom2 and clh and clh*2 >= W then + EC = 2 + EM = string.format( EgtDoorsMsg[626], sNamePar8, EgtToUiUnits(clh), EgtToUiUnits((W/2)-0.1), sCompoPath) -- il parametro 'clh' deve essere < W/2 + clh = 0 + 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 + -- Layer + local Dm + + local Lg + local GId + local hint + local nRev + local pIni, pEnd + local dStartValX, dStopValX + local dStartValY, dStopValY + local dValXv1Ini, dValXv1End, dValYv1Ini, dValYv1End -- prima linea verticale + local dValXv2Ini, dValXv2End, dValYv2Ini, dValYv2End -- seconda linea verticale + local dValXh1Ini, dValXh1End, dValYh1Ini, dValYh1End -- prima linea orizzontale + local dValXh2Ini, dValXh2End, dValYh2Ini, dValYh2End -- seconda linea orizzontale + local dStart + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName(Dm,DM) + end + + if nForceMakeFace ~= 1 then -- se abilitata geometria esterna + + -- se linee verticali + if bMakeFaceGeom1 then -- se posso fare linee verticali + + -- definisco i punti iniziali e finali + if not rev then -- se riferite a lock + + if dsv > 0 then -- se ho posizione + dStartValX = dsv + dStopValX = dsv + else -- non ho posizione + dStartValX = stv+esfv + dStopValX = stv+esfv + end + + nRev = 1 + else -- riferite a hinge + + if dsv > 0 then -- se ho posizione + dStartValX = W-dsv + dStopValX = W-dsv + else -- non ho posizione + dStartValX = W-stv-esfv + dStopValX = W-stv-esfv + end + + nRev = -1 + end + + if not pre or pre <= 1 then -- se non ci sono prelazioni o prelazione sulle linee verticali + dStartValY = L - clv -- posizione in alto + dStopValY = clv + else -- ci sono prelazioni su linee orizzontali + + -- se ci sono linee orizzontali + -- in base al loro riferimento definisco la posizione di partenza in Y + if bMakeFaceGeom2 then + -- se ho solo due linee e sono specificate le distanze e senza un passo definito + if nhl == 2 and dsh and doh and dsh > 0 and doh > 0 and ( not esth or esth < 0) then + if not reh then -- se riferite a top + dStartValY = L - dsh - civ -- posizione in alto + dStopValY = doh + civ + else -- partono da sotto + dStartValY = L - doh - civ -- posizione in alto + dStopValY = dsh + civ + end + else + if not reh then -- se riferite a top + dStartValY = L - dsh - ( ( sth + (esfh*2)) * EgtIf( dsh > GEO.EPS_SMALL, nhl-1, nhl)) - civ -- posizione in alto + dStopValY = clv + else -- partono da sotto + dStartValY = L - clv -- posizione in alto + dStopValY = dsh + ( ( sth + (esfh*2)) * EgtIf( dsh > GEO.EPS_SMALL, nhl-1, nhl)) + civ + end + end + else -- altrimenti come per il primo caso + dStartValY = L - clv -- posizione in alto + dStopValY = clv + end + end + + if dStopValY >= dStartValY then -- se punti definiscono linea nulla o incongruente + EC = 20 + EM = string.format( EgtDoorsMsg[647], ( dStartValY - dStopValY), sCompoPath) -- mancano i parametri delle dimensioni + return (ErrorBase+EC), EM + end + + -- prendo la partenza iniziale + dStart = dStartValX + + -- disegno geometria + for k = 1, nvl do + + pIni = Point3d( dStartValX, dStartValY, 0) + pEnd = Point3d( dStopValX, dStopValY, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d1/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dvl) -- di default è sul lato keyway + EgtSetName( hint, LGV) + end + + -- se ho il check di cancellazione linea esterna + if dev then + if nRev > 0 then -- se riferita a bottom + -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee + if dStartValX >= W then + nvl = k - 1 + EgtErase(hint) + break + end + else -- riferita a top + -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee + if dStartValX < 0 then -- se ultima linea arriva oltre + nvl = k - 1 + EgtErase(hint) + break + end + end + end + + -- aggiorno il passo + dStartValX = dStartValX + ( ( stv + (2*esfv)) * nRev) + dStopValX = dStopValX + ( ( stv + (2*esfv)) * nRev) + end + + if not dev then -- se non devo cancellare linee esterne verifico se sbordano + if nRev > 0 then -- se riferita a lock + if ( dStart + (( stv + (2*esfv)) * (nvl-1) * nRev)) >= W then -- se ultima linea arriva oltre + EC = 21 + EM = string.format( EgtDoorsMsg[652], sCompoPath) -- geometria sborda in larghezza + return (ErrorBase+EC), EM + end + else -- riferita a hinge + if ( dStart + (( stv + (2*esfv)) * (nvl-1) * nRev)) < 0 then -- se ultima linea arriva oltre + EC = 22 + EM = string.format( EgtDoorsMsg[652], sCompoPath) -- geometria sborda in larghezza + return (ErrorBase+EC), EM + end + end + end + end + + -- se linee orizzontali + if bMakeFaceGeom2 then -- se posso fare linee orizzontali + + -- definisco i punti iniziali e finali + if not reh then -- se riferite a top + + if dsh > 0 then -- se ho posizione + dStartValY = L-dsh + dStopValY = L-dsh + else -- non ho posizione + dStartValY = L-sth-esfh + dStopValY = L-sth-esfh + end + + nRev = -1 + else -- riferite a bottom + + if dsh > 0 then -- se ho posizione + dStartValY = dsh + dStopValY = dsh + else -- non ho posizione + dStartValY = sth+esfh + dStopValY = sth+esfh + end + + nRev = 1 + end + + if not pre or pre == 0 or pre == 2 then -- se non ci sono prelazioni o prelazione sulle linee orizzontali + dStartValX = clh -- posizione a sinistra + dStopValX = W - clh + else -- ci sono prelazioni su linee verticali + + -- se ci sono linee verticali + -- in base al loro riferimento definisco la posizione di partenza in X + if bMakeFaceGeom1 then + -- se ho solo due linee e sono specificate le distanze e senza un passo definito + if nvl == 2 and dsv and dov and dsv > 0 and dov > 0 and ( not estv or estv < 0) then + if not rev then -- se partono da lock + dStartValX = dsv + cih -- posizione a sinistra + dStopValX = W - dov - cih + else -- partono da hinge + dStartValX = dov + cih -- posizione a sinistra + dStopValX = W - dsv - cih + end + else + if not rev then -- se partono da lock + dStartValX = dsv + ( ( stv + (esfv*2)) * EgtIf( dsv > GEO.EPS_SMALL, nvl-1, nvl)) + cih -- posizione a sinistra + dStopValX = W - clh -- posizione a destra + else -- partono da hinge + dStartValX = clh -- posizione a sinistra + dStopValX = W - dsv - ( ( stv + (esfv*2)) * EgtIf( dsv > GEO.EPS_SMALL, nvl-1, nvl)) - cih -- posizione a destra + end + end + else -- altrimenti come per il primo caso + dStartValX = clh -- posizione a sinistra + dStopValX = W - clh + end + end + + if dStartValX >= dStopValX then -- se punti definiscono linea nulla o incongruente + EC = 23 + EM = string.format( EgtDoorsMsg[648], ( dStopValX - dStartValX), sCompoPath) + return (ErrorBase+EC), EM + end + + -- prendo la partenza iniziale + dStart = dStartValY + + -- disegno geometria + for k = 1, nhl do + + pIni = Point3d( dStartValX, dStartValY, 0) + pEnd = Point3d( dStopValX, dStopValY, 0) + hint = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, (d2/2), true, true, RED(), RED()) + if hint then + EgtModifyCurveThickness( hint, -Dhl) -- di default è sul lato keyway + EgtSetName( hint, LGH) + end + + -- se ho il check di cancellazione linea esterna + if deh then + if nRev > 0 then -- se riferita a bottom + -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee + if dStartValY >= L then + nhl = k - 1 + EgtErase(hint) + break + end + else -- riferita a top + -- se ultima linea inserita è esterna cancello ultima linea e aggiorno il numero linee + if dStartValY < 0 then -- se ultima linea arriva oltre + nhl = k - 1 + EgtErase(hint) + break + end + end + end + + -- aggiorno il passo + dStartValY = dStartValY + ( ( sth + (2*esfh)) * nRev) + dStopValY = dStopValY + ( ( sth + (2*esfh)) * nRev) + end + + if not deh then -- se non devo cancellare linee esterne verifico se sbordano + if nRev > 0 then -- se riferita a bottom + if ( dStart + (( sth + (2*esfh)) * (nhl-1) * nRev)) >= L then -- se ultima linea arriva oltre + EC = 24 + EM = string.format( EgtDoorsMsg[653], sCompoPath) -- geometria sborda in larghezza + return (ErrorBase+EC), EM + end + else -- riferita a top + if ( dStart + (( sth + (2*esfh)) * (nhl-1) * nRev)) < 0 then -- se ultima linea arriva oltre + EC = 25 + EM = string.format( EgtDoorsMsg[653], sCompoPath) -- geometria sborda in larghezza + return (ErrorBase+EC), EM + end + end + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + EgtSetColor( Lg or GDB_ID.NULL, AQUA()) + else + EgtSetColor( Lg or GDB_ID.NULL, ORANGE()) + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'fc_lines') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'W' ,W) + EgtSetInfo(Lg,'nvl' ,nvl) + EgtSetInfo(Lg,'Dvl' ,Dvl) + EgtSetInfo(Lg,'rev' ,rev) + EgtSetInfo(Lg,'dsv' ,dsv) + EgtSetInfo(Lg,'dov' ,dov) + EgtSetInfo(Lg,'stv' ,stv) + EgtSetInfo(Lg,'clv' ,clv) + EgtSetInfo(Lg,'civ' ,civ) + EgtSetInfo(Lg,'esfv' ,esfv) + EgtSetInfo(Lg,'nhl' ,nhl) + EgtSetInfo(Lg,'Dhl' ,Dhl) + EgtSetInfo(Lg,'reh' ,reh) + EgtSetInfo(Lg,'dsh' ,dsh) + EgtSetInfo(Lg,'doh' ,doh) + EgtSetInfo(Lg,'sth' ,sth) + EgtSetInfo(Lg,'clh' ,clh) + EgtSetInfo(Lg,'cih' ,cih) + EgtSetInfo(Lg,'esfh' ,esfh) + EgtSetInfo(Lg,'pre' ,pre) + EgtSetInfo(Lg,'dtype' ,dtype) + EgtSetInfo(Lg,'LGV' ,LGV) + EgtSetInfo(Lg,'LGH' ,LGH) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return fc_lines diff --git a/LuaLibs/FlushBolt.lua b/LuaLibs/FlushBolt.lua new file mode 100644 index 0000000..3ebc446 --- /dev/null +++ b/LuaLibs/FlushBolt.lua @@ -0,0 +1,3325 @@ +-- +-- 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 +-- +-- FlushBolt.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Flush-Bolt corner or extension type + +-- 2016.09.21 V1.0a1 FM Add warning messages +-- 2017.09.05 V1.0a2 FM Not rotate face on bevel profile +-- 2018.01.16 V1.0a5 FM Manage new head mortise on extension type +-- 2018.04.05 V1.0a6 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.05.15 V1.0a7 FM Manage info for maxfeed on connection entities +-- 2018.10.17 V1.0a8 FM Add parameter to show into message 402 +-- 2018.10.22 V1.0a9 FM Manage better the big radius fillet parameter +-- 2018.10.25 V1.0aa FM Manage extra geometries on keyway and secure side +-- 2018.12.06 V1.0ab FM Disable width alignment from head face and side face +-- 2019.05.23 V1.0ac FM Manage anti-splint path on strike extra rectangle geometry +-- 2019.09.30 V1.0ad FM Manage anti-splint path on anti-splint path +-- 2019.10.11 V1.0ae FM Manage steel option (disable to generate pocket paths, mortise) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.29 V2.001 FM Add clean corner geometries +-- 2019.12.18 V2.002 FM Fix error when DGD.TYPE is not initialized (it happen when flush bolt template is used as EdgePull) +-- 2019.12.18 V2.003 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.004 FM fix a bug on clean corner direction path in case main paths turn reverse +-- 2020.04.29 V2.005 FM Update for aluminum material +-- 2020.05.12 V2.006 FM Add back_set parameter and manage reference (back_set or side door) to extra geometries +-- 2020.05.27 V2.007 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.07.01 V2.008 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2020.10.20 V2.009 FM Manage 10 side extra bore groups and 5 head extra bore groups on extension type +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.01.22 V3.001 FM Fix error on assign tool diameter to a wrong variable (.d7) instead of (.d4) with aluminum material +-- 2021.03.12 V3.002 FM Check and adjust the angle parameter on ebtra rectangle and extra lines +-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.004 FM Modification to use compiled code +-- 2023.03.01 V3.005 FM Manage 10 side extra bore groups and 5 head extra bore groups on corner type too +-- 2024.07.19 V3.003 FM Set note 'NotCheckDir' to pocketing and antisplint paths +-- 2024.10.07 V3.004 FM Manage probe geometry and their offset position when template is disposed +-- 2024.10.29 V3.005 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local FlushBolt = {} + +-- 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.25 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nLine = EgtLine(nGroup, pInitial, pFinal, nReference) + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , nReference) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + + +-- Funzione creazione foro o asola o rampa per asola +local function MakeBore( Lg, EB10, PX10, Int10, D10, + PY10, T10, kbs, HB10, dws, + nBI, D_XE, bRotate, dPosition, pbs) + + local pIni, pEnd, pCen + local hint3 + local tPath = {} + local tPathPok = {} + + if EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10+D_XE),PY10, (dPosition or 0)), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + if bRotate then + EgtRotate( hint3, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint3, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto per mantenere il centro dello spessore + EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + end + + if bRotate then + EgtSetInfo( hint3, 'SideDoor', 'Lock') + EgtSetInfo( hint3, 'HeadSide', 'head') + else + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'Lock') + else + EgtSetInfo (hint3, 'SideDoor', 'Side') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + return nBI + 1 +end + +local function MakeRectWithFillet( Lg, P1, P2, Rf, Ang) + + local hint_3 = EgtRectangle2P( Lg, P1, P2, GDB_RT.LOC) + + if hint_3 then + + local nNewId, nNumEnt = EgtExplodeCurveCompo( hint_3) + + if nNewId and nNumEnt and nNumEnt > 0 then + + local pStartIni + + -- se devo inserire i raccordi + if Rf > 0 then + + local tIdFil = {} + local nLine + for p = 1, (nNumEnt-1) do + nLine = EgtCurveFillet( Lg, ( nNewId + p - 1), EgtEP( nNewId + p - 1), ( nNewId + p), EgtSP( nNewId + p), Rf, true) + table.insert( tIdFil, nLine) + end + nLine = EgtCurveFillet( Lg, ( nNewId + nNumEnt - 1), EgtEP( nNewId + nNumEnt - 1), nNewId, EgtSP(nNewId), Rf, true) + table.insert( tIdFil, nLine) + + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, tIdFil[1], (nNewId+1), tIdFil[2], (nNewId+2), tIdFil[3], (nNewId+3), tIdFil[4]}, true) + else + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, (nNewId+1), (nNewId+2), (nNewId+3)}, true) + end + + if hint_3 then + EgtChangeClosedCurveStartPoint( hint_3, pStartIni, GDB_RT.LOC) -- cambio punto di inizio + if Ang ~= 0 then + EgtRotate( hint_3, EgtGP( hint_3), Z_AX(), Ang, GDB_RT.LOC) -- ruoto + end + end + end + end + + return hint_3 +end + +local function MakeAspOnStrikeRect( Lg, nHint, dX, dY, dThick, + dDoorTh, dShiftX, dShiftY, bRefSide, dBack_set, + dDiam, bOpposite, dZedPos, dDiam2, sSideLock, + Fc) + + local nLine + local ptIni, ptEnd, pInt1, pInt1, ptIni2, ptEnd2 + local tPath = {} + local nPath1, nPath2, nPath3, nPath4 + local nInv = 1 + + if not dBack_set then dBack_set = 0 end + + -- creo la linea + ptIni = Point3d( (dShiftX - max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + ptEnd = Point3d( (dShiftX + max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + nLine = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE()) + + if nLine then + + -- verifico se ci sono intersezioni + pInt1 = EgtIP( nLine, nHint, ptIni) + pInt2 = EgtIP( nLine, nHint, ptEnd) + + -- se ci sono entrambe i punti e la loro distanza è maggiore del diametro fresa + if pInt1 and pInt2 then + + local dDist = dist( pInt1, pInt2) + + if dDist>= dDiam then -- se larghezza maggiore dell'utensile + + -- imposto la griglia + if bOpposite then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + nInv = -1 + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + end + + ptIni = Point3d( (pInt1:getX() + (dDiam/2) - dExtraH)*nInv, dDiam*3/4, -pInt1:getY()) + if dDiam2 then + ptIni2 = Point3d( (pInt1:getX() + (dDiam2/2) - dExtraH)*nInv, dDiam2*3/4, -pInt1:getY()) + end + + if dDoorTh - dThick > GEO.EPS_SMALL then -- se spessore non passante + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick + (dDiam/2) - dExtraH, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick + (dDiam2/2) - dExtraH, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- se spessore passante + + if (dDist - dDiam) < 2*dDiam then -- se larghezza minore del doppio diametro utensile + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- larghezza maggiore del doppio diametro, creao due linee distinte + + -- creo 2 persorsi composti da una linea ciascuno + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + nPath1 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptEnd:getY(), -pInt2:getY()) + ptEnd = Point3d( ptIni:getX(), (dDiam*3/4), ptIni:getZ()) + nPath2 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + if dDiam2 then + -- creo 2 persorsi composti da una linea ciascuno + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + nPath3 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptEnd2:getY(), -pInt2:getY()) + ptEnd2 = Point3d( ptIni2:getX(), (dDiam2*3/4), ptIni2:getZ()) + nPath4 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + end + end + end + end + + -- se esistono gli eventuali percorso setto spessore 0 + if nPath1 then + EgtModifyCurveThickness(nPath1, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + end + if nPath2 then + EgtModifyCurveThickness(nPath2, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + end + if nPath3 then + EgtModifyCurveThickness(nPath3, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + end + if nPath4 then + EgtModifyCurveThickness(nPath4, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + end + + -- re-imposto la griglia da sopra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + -- elimino la linea + EgtErase(nLine) + end + + return nPath1, nPath2, nPath3, nPath4 +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function FlushBolt.AdjustParams( tMhPar) + + tMhPar.invG = 1 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat00 + local dMaxMat1 + local dMaxMat2 + local dMaxMat4 + local dMaxMat5 + local dMaxMat6 + local dMaxMat7 + local dMaxMat8 + local dMaxMat9 + local dMaxMat10 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT00 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local nTempT5 + local nTempT6 + local nTempT7 + local nTempT8 + local nTempT9 + local nTempT10 + local sMchngName0 + local sMchngName00 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local sMchngName5 + local sMchngName6 + local sMchngName7 + local sMchngName8 + local sMchngName9 + local sMchngName10 + local dOffset = DGD.OFFSET or 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 il tipo flushbolt non è adatto per il tipo di porta ( inactive) + if not( DGD.sSwing == 'LHI' or DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI' or DGD.sSwing == 'LHRI') and not DGC.Eif then + return tMhPar, 1798, string.format(EgtDoorsMsg[458], tMhPar.Nome, DGD.sSwing) + end + + -- do errore se profilo tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or + DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') then + return tMhPar, 1799, string.format(EgtDoorsMsg[430], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se profilo bevel disabilito la giunzione tra face e mortise + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + tMhPar.jnb = false + -- setto il flag che indica profilo bevel + tMhPar.bev = true + else + tMhPar.jnb = true + end + + -- overcast del parametro di distanza foro in testa (che è il riferimento anche per la cava in testa) + if DGD.BACK_SET and DGD.BACK_SET > 0 then + tMhPar.DB_X = DGD.BACK_SET + end + + -- se frame annullo il parametro position + if DGD.sFrame and ( DGD.sFrame == 'T' or DGD.sFrame == 'TE' or DGD.sFrame == 'B' or DGD.sFrame == 'BE') then + DGD.POSITION = 0 + end + + -- se serratura su lato destro setto il flag per invertire i percorsi + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + + tMhPar.SL = DGD.Lock + + if tMhPar.dl and tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.jnb then + -- se non ruoto face risetto il flag che impedisce il chain tra face e mortise + tMhPar.jnb = true + -- ricalcolo la profondità per avere spessore minomo = al valore di .T + tMhPar.T = tMhPar.T + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + else + tMhPar.dl = false + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech4 then + tMhPar.ech4 = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se non ho il parametro D_XE lo setto a 0 + if not tMhPar.D_XE then + tMhPar.D_XE = 0 + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template non è sui lati top e bottom + if DGD.SDF and DGD.SDF > 1 then + + -- calcolo la posizione del centro foro sullo spessore porta + if dOffset > 0 then + if ( DGD.SIDE == 'top' and DGD.Push) or ( DGD.SIDE ~= 'top' and not DGD.Push) then + tMhPar.posh = (DGD.dT/2) - dOffset + else + tMhPar.posh = -(DGD.dT/2) + dOffset + end + else + tMhPar.posh = 0 + end + + if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + tMhPar.SD = DGD.SIDE + + -- se viene utilizzato il flush bolt come EdgePull, il parametro type non viene passato + -- e setto di default come extensione + if not DGD.TYPE then DGD.TYPE = 'extension' end + + -- se corner, disattivo alcuni parametri dell'extension e viceversa + if string.lower(DGD.TYPE) == 'corner' then + tMhPar.mc = true -- abilito il flag che indica il corner + if tMhPar.mh then -- se ho attivo il foro sul fianco +-- tMhPar.L2 = nil -- azzero + tMhPar.H2 = nil -- azzero side bore depth + tMhPar.T2 = nil -- azzero side bore depth + end + tMhPar.mh = false -- disabilito il foro laterale + tMhPar.H3 = nil -- azzero top/bottom bore diameter + tMhPar.T3 = nil -- azzero top/bottom bore depth + tMhPar.LG3 = nil -- azzero label top/bottom bore depth + tMhPar.H6 = nil -- azzero top/bottom mortise width + tMhPar.T6 = nil -- azzero top/bottom mortise depth + tMhPar.LG6 = nil -- azzero label top/bottom bore depth + tMhPar.D_X = 0 -- azzero il decentramento foro/mortasa sul lato + tMhPar.DB_X = 0 -- distaza dal corner per top/bottom bore + tMhPar.DF_X = 0 -- distaza dal corner per top/bottom face + tMhPar.D_XE = 0 -- distanza dal corner per geometrie sul fianco + +-- if tMhPar.H then +-- tMhPar.H4 = tMhPar.H -- setto top/bottom face alta come la face +-- end + if tMhPar.rf then --(prelazione del face corner) + tMhPar.rf4 = tMhPar.rf -- setto top/bottom radius face cone il radius face + end + -- prima assegno al cl del face di testa il valore del cl del fianco + if tMhPar.cl then --(prelazione del face corner) + tMhPar.cl4 = tMhPar.cl -- setto arrotondamento preso dal face principale + end + + -- prima assegno ai parametri clean corner del face di testa i parametri del clean corner del face di fianco + -- uso il .L per essere sicuro che ci siano i parametri del face di sianco + if tMhPar.CLC and tMhPar.L then --(prelazione del face corner) + tMhPar.CLC4 = tMhPar.CLC -- setto nome geometria preso dal face principale + end + if tMhPar.clc and tMhPar.L then --(prelazione del face corner) + tMhPar.clc4 = tMhPar.clc -- setto nome geometria preso dal face principale + end + if tMhPar.ccr and tMhPar.L then --(prelazione del face corner) + tMhPar.ccr4 = tMhPar.ccr -- setto nome geometria preso dal face principale + end + + -- se ho il raccordo sulla head face disabilito il chisel e il clean corner + if tMhPar.cl4 and ( tMhPar.cl4 == 1 or tMhPar.cl4 == 3) then + tMhPar.ech4 = false + tMhPar.clc4 = nil + tMhPar.CLC4 = nil + end + if not tMhPar.cl then + tMhPar.cl = 0 + end + -- se arrotondo entrambe le estremità disabilito il chisel e il clean corner + if tMhPar.cl and tMhPar.cl >= 2 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + else -- altrimenti tipo extension + tMhPar.mc = false -- disabilito il flag che indica il corner + if not tMhPar.cl4 then + tMhPar.cl4 = 0 + end + -- se arrotondo entrambe le estremità disabilito il chisel e il clean corner + if tMhPar.cl4 == 3 then + tMhPar.ech4 = false + tMhPar.clc4 = nil + tMhPar.CLC4 = nil + end + if not tMhPar.cl then + tMhPar.cl = 0 + end + -- se arrotondo entrambe le estremità disabilito il chisel + if tMhPar.cl and tMhPar.cl == 3 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.cl > 0 and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + if not tMhPar.rf4 then + tMhPar.rf4 = 0 + if tMhPar.cl4 and tMhPar.cl4 > 0 and tMhPar.H4 then + tMhPar.rf4 = tMhPar.H4/2 + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLGH + local nLGHi = 1 + local sLG3 + local nLG3i = 1 + local sLM4 + local nLM4i = 1 + local sLM5 + local nLM5i = 1 + local sLM6 + local nLM6i = 1 + local sLM7 + local nLM7i = 1 + local sLG + local nLGi = 1 + local sLG4 + local nLG4i = 1 + local sASG -- anti-splint on rectangle + local nASGi = 1 + local sASGR -- anti-splint on antisplint + local nASGRi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.LM4 = nil + tMhPar.LM5 = nil + tMhPar.LM6 = nil + tMhPar.LM7 = nil + tMhPar.ech = false + tMhPar.ech4 = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d5 = nil + tMhPar.d7 = nil + tMhPar.ASG = 0 + tMhPar.EAR = nil + tMhPar.das = nil + else + tMhPar.est = nil + end + + -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- profilo serrratura bevel up + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 3 + nLM7i = 3 + nLGi = 3 + else + nLMi = 2 + nLM7i = 2 + nLGi = 2 + end + elseif DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB' then -- profilo serrratura bevel dn + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 2 + nLM7i = 2 + nLGi = 2 + else + nLMi = 3 + nLM7i = 3 + nLGi = 3 + end + end + + if tMhPar.est and tMhPar.LG then -- se altro materiale + sLG = tMhPar.LG + if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.est and tMhPar.LG4 then -- se altro materiale + sLG4 = tMhPar.LG4 + if DGD.MachEn > 0 and tMhPar.d4 then nTempT00, dMaxMat00, sMchngName00 = MB.GetToolDataFromAttrib( sLG4, nLG4i) 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.LM7 then + sLM7 = tMhPar.LM7 + if DGD.MachEn > 0 and tMhPar.d7 then nTempT8, dMaxMat8, sMchngName8 = MB.GetToolDataFromAttrib( sLM7, nLM7i) end + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.ech4 and tMhPar.LG4 then -- se chisel abilitato + sLG4 = tMhPar.LG4 .. tMhPar.CH + tMhPar.d00 = 0 + if DGD.MachEn > 0 and tMhPar.d00 then nTempT00, dMaxMat00, sMchngName00 = MB.GetToolDataFromAttrib( sLG4, nLG4i) 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 + + if tMhPar.mh and tMhPar.LGH then + sLGH = tMhPar.LGH + if DGD.MachEn > 0 then nTempT3, dMaxMat2, sMchngName3 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end -- nel foro non ha importanza il diametro utensile + end + + if tMhPar.LG3 then + sLG3 = tMhPar.LG3 + if DGD.MachEn > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLG3, nLG3i) end -- nel foro non ha importanza il diametro utensile + end + + if tMhPar.LM4 then + sLM4 = tMhPar.LM4 + if DGD.MachEn > 0 and tMhPar.d4 then nTempT5, dMaxMat5, sMchngName5 = MB.GetToolDataFromAttrib( sLM4, nLM4i) end + end + + if tMhPar.LM5 then + sLM5 = tMhPar.LM5 + if DGD.MachEn > 0 and tMhPar.d5 then nTempT6, dMaxMat6, sMchngName6 = MB.GetToolDataFromAttrib( sLM5, nLM5i) end + end + + if tMhPar.LM6 then + sLM6 = tMhPar.LM6 + if DGD.MachEn > 0 and tMhPar.d6 then nTempT7, dMaxMat7, sMchngName7 = MB.GetToolDataFromAttrib( sLM6, nLM6i) end + end + + -- extra bores + if tMhPar.T10 then + if tMhPar.T10 == -0.5 then + tMhPar.T10 = DGD.dT / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > DGD.dT then + tMhPar.T10 = DGD.dT + end + end + + if tMhPar.T11 then + if tMhPar.T11 == -0.5 then + tMhPar.T11 = DGD.dT / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > DGD.dT then + tMhPar.T11 = DGD.dT + end + end + + if tMhPar.T12 then + if tMhPar.T12 == -0.5 then + tMhPar.T12 = DGD.dT / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > DGD.dT then + tMhPar.T12 = DGD.dT + end + end + + if tMhPar.T13 then + if tMhPar.T13 == -0.5 then + tMhPar.T13 = DGD.dT / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > DGD.dT then + tMhPar.T13 = DGD.dT + end + end + + if tMhPar.T14 then + if tMhPar.T14 == -0.5 then + tMhPar.T14 = DGD.dT / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > DGD.dT then + tMhPar.T14 = DGD.dT + end + end + + if tMhPar.T15 then + if tMhPar.T15 == -0.5 then + tMhPar.T15 = DGD.dT / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > DGD.dT then + tMhPar.T15 = DGD.dT + end + end + + if tMhPar.T16 then + if tMhPar.T16 == -0.5 then + tMhPar.T16 = DGD.dT / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > DGD.dT then + tMhPar.T16 = DGD.dT + end + end + + if tMhPar.T17 then + if tMhPar.T17 == -0.5 then + tMhPar.T17 = DGD.dT / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > DGD.dT then + tMhPar.T17 = DGD.dT + end + end + + if tMhPar.T18 then + if tMhPar.T18 == -0.5 then + tMhPar.T18 = DGD.dT / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > DGD.dT then + tMhPar.T18 = DGD.dT + end + end + + if tMhPar.T19 then + if tMhPar.T19 == -0.5 then + tMhPar.T19 = DGD.dT / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > DGD.dT then + tMhPar.T19 = DGD.dT + end + end + + if tMhPar.T20 then + if tMhPar.T20 == -0.5 then + tMhPar.T20 = DGD.dT / 2 + elseif tMhPar.T20 == -1 or tMhPar.T20 > DGD.dT then + tMhPar.T20 = DGD.dT + end + end + + if tMhPar.T21 then + if tMhPar.T21 == -0.5 then + tMhPar.T21 = DGD.dT / 2 + elseif tMhPar.T21 == -1 or tMhPar.T21 > DGD.dT then + tMhPar.T21 = DGD.dT + end + end + + if tMhPar.T22 then + if tMhPar.T22 == -0.5 then + tMhPar.T22 = DGD.dT / 2 + elseif tMhPar.T22 == -1 or tMhPar.T22 > DGD.dT then + tMhPar.T22 = DGD.dT + end + end + + if tMhPar.T23 then + if tMhPar.T23 == -0.5 then + tMhPar.T23 = DGD.dT / 2 + elseif tMhPar.T23 == -1 or tMhPar.T23 > DGD.dT then + tMhPar.T23 = DGD.dT + end + end + + if tMhPar.T24 then + if tMhPar.T24 == -0.5 then + tMhPar.T24 = DGD.dT / 2 + elseif tMhPar.T24 == -1 or tMhPar.T24 > DGD.dT then + tMhPar.T24 = DGD.dT + end + end + + if tMhPar.T25 then + if tMhPar.T25 == -0.5 then + tMhPar.T25 = DGD.dT / 2 + elseif tMhPar.T25 == -1 or tMhPar.T25 > DGD.dT then + tMhPar.T25 = DGD.dT + end + end + + if tMhPar.T26 then + if tMhPar.T26 == -0.5 then + tMhPar.T26 = DGD.dT / 2 + elseif tMhPar.T26 == -1 or tMhPar.T26 > DGD.dT then + tMhPar.T26 = DGD.dT + end + end + + if tMhPar.T27 then + if tMhPar.T27 == -0.5 then + tMhPar.T27 = DGD.dT / 2 + elseif tMhPar.T27 == -1 or tMhPar.T27 > DGD.dT then + tMhPar.T27 = DGD.dT + end + end + + if tMhPar.T28 then + if tMhPar.T28 == -0.5 then + tMhPar.T28 = DGD.dT / 2 + elseif tMhPar.T28 == -1 or tMhPar.T28 > DGD.dT then + tMhPar.T28 = DGD.dT + end + end + + if tMhPar.T29 then + if tMhPar.T29 == -0.5 then + tMhPar.T29 = DGD.dT / 2 + elseif tMhPar.T29 == -1 or tMhPar.T29 > DGD.dT then + tMhPar.T29 = DGD.dT + end + end + + -- extra rectangles + if tMhPar.TR10 then + if tMhPar.TR10 == -0.5 then + tMhPar.TR10 = DGD.dT / 2 + elseif tMhPar.TR10 == -1 or tMhPar.TR10 > DGD.dT then + tMhPar.TR10 = DGD.dT + end + end + + if tMhPar.TR11 then + if tMhPar.TR11 == -0.5 then + tMhPar.TR11 = DGD.dT / 2 + elseif tMhPar.TR11 == -1 or tMhPar.TR11 > DGD.dT then + tMhPar.TR11 = DGD.dT + end + end + + if tMhPar.TR12 then + if tMhPar.TR12 == -0.5 then + tMhPar.TR12 = DGD.dT / 2 + elseif tMhPar.TR12 == -1 or tMhPar.TR12 > DGD.dT then + tMhPar.TR12 = DGD.dT + end + end + + if tMhPar.TR13 then + if tMhPar.TR13 == -0.5 then + tMhPar.TR13 = DGD.dT / 2 + elseif tMhPar.TR13 == -1 or tMhPar.TR13 > DGD.dT then + tMhPar.TR13 = DGD.dT + end + end + + if tMhPar.TR14 then + if tMhPar.TR14 == -0.5 then + tMhPar.TR14 = DGD.dT / 2 + elseif tMhPar.TR14 == -1 or tMhPar.TR14 > DGD.dT then + tMhPar.TR14 = DGD.dT + end + end + + if tMhPar.TR20 then + if tMhPar.TR20 == -0.5 then + tMhPar.TR20 = DGD.dT / 2 + elseif tMhPar.TR20 == -1 or tMhPar.TR20 > DGD.dT then + tMhPar.TR20 = DGD.dT + end + end + + if tMhPar.TR21 then + if tMhPar.TR21 == -0.5 then + tMhPar.TR21 = DGD.dT / 2 + elseif tMhPar.TR21 == -1 or tMhPar.TR21 > DGD.dT then + tMhPar.TR21 = DGD.dT + end + end + + if tMhPar.TR22 then + if tMhPar.TR22 == -0.5 then + tMhPar.TR22 = DGD.dT / 2 + elseif tMhPar.TR22 == -1 or tMhPar.TR22 > DGD.dT then + tMhPar.TR22 = DGD.dT + end + end + + if tMhPar.TR23 then + if tMhPar.TR23 == -0.5 then + tMhPar.TR23 = DGD.dT / 2 + elseif tMhPar.TR23 == -1 or tMhPar.TR23 > DGD.dT then + tMhPar.TR23 = DGD.dT + end + end + + if tMhPar.TR24 then + if tMhPar.TR24 == -0.5 then + tMhPar.TR24 = DGD.dT / 2 + elseif tMhPar.TR24 == -1 or tMhPar.TR24 > DGD.dT then + tMhPar.TR24 = DGD.dT + end + end + + -- Anti-splint su extra rettangoli + if DGD.MachEn > 0 and tMhPar.ASG and tMhPar.EAR and + ( ( tMhPar.TR10 and tMhPar.TR10 > GEO.EPS_SMALL) or ( tMhPar.TR11 and tMhPar.TR11 > GEO.EPS_SMALL) or ( tMhPar.TR12 and tMhPar.TR12 > GEO.EPS_SMALL) or + ( tMhPar.TR13 and tMhPar.TR13 > GEO.EPS_SMALL) or ( tMhPar.TR14 and tMhPar.TR14 > GEO.EPS_SMALL) or ( tMhPar.TR20 and tMhPar.TR20 > GEO.EPS_SMALL) or + ( tMhPar.TR21 and tMhPar.TR21 > GEO.EPS_SMALL) or ( tMhPar.TR22 and tMhPar.TR22 > GEO.EPS_SMALL) or ( tMhPar.TR23 and tMhPar.TR23 > GEO.EPS_SMALL) or + ( tMhPar.TR24 and tMhPar.TR24 > GEO.EPS_SMALL)) then + sASG = tMhPar.ASG + nTempT9, dMaxMat9, sMchngName9 = MB.GetToolDataFromAttrib( sASG, nASGi) + end + + -- Anti-splint su Anti-splint + if DGD.MachEn > 0 and tMhPar.EAR and tMhPar.EAR == 2 and sASG then + sASGR = tMhPar.ASG..'_R' + tMhPar.ASGR = sASGR + tMhPar.das2 = tMhPar.das + nTempT10, dMaxMat10, sMchngName10 = MB.GetToolDataFromAttrib( sASGR, nASGRi) + end + + -- extra lines + if tMhPar.TL10 then + if tMhPar.TL10 == -0.5 then + tMhPar.TL10 = DGD.dT / 2 + elseif tMhPar.TL10 == -1 or tMhPar.TL10 > DGD.dT then + tMhPar.TL10 = DGD.dT + end + end + + if tMhPar.TL11 then + if tMhPar.TL11 == -0.5 then + tMhPar.TL11 = DGD.dT / 2 + elseif tMhPar.TL11 == -1 or tMhPar.TL11 > DGD.dT then + tMhPar.TL11 = DGD.dT + end + end + + if tMhPar.TL12 then + if tMhPar.TL12 == -0.5 then + tMhPar.TL12 = DGD.dT / 2 + elseif tMhPar.TL12 == -1 or tMhPar.TL12 > DGD.dT then + tMhPar.TL12 = DGD.dT + end + end + + if tMhPar.TL13 then + if tMhPar.TL13 == -0.5 then + tMhPar.TL13 = DGD.dT / 2 + elseif tMhPar.TL13 == -1 or tMhPar.TL13 > DGD.dT then + tMhPar.TL13 = DGD.dT + end + end + + if tMhPar.TL14 then + if tMhPar.TL14 == -0.5 then + tMhPar.TL14 = DGD.dT / 2 + elseif tMhPar.TL14 == -1 or tMhPar.TL14 > DGD.dT then + tMhPar.TL14 = DGD.dT + end + end + + if tMhPar.TL20 then + if tMhPar.TL20 == -0.5 then + tMhPar.TL20 = DGD.dT / 2 + elseif tMhPar.TL20 == -1 or tMhPar.TL20 > DGD.dT then + tMhPar.TL20 = DGD.dT + end + end + + if tMhPar.TL21 then + if tMhPar.TL21 == -0.5 then + tMhPar.TL21 = DGD.dT / 2 + elseif tMhPar.TL21 == -1 or tMhPar.TL21 > DGD.dT then + tMhPar.TL21 = DGD.dT + end + end + + if tMhPar.TL22 then + if tMhPar.TL22 == -0.5 then + tMhPar.TL22 = DGD.dT / 2 + elseif tMhPar.TL22 == -1 or tMhPar.TL22 > DGD.dT then + tMhPar.TL22 = DGD.dT + end + end + + if tMhPar.TL23 then + if tMhPar.TL23 == -0.5 then + tMhPar.TL23 = DGD.dT / 2 + elseif tMhPar.TL23 == -1 or tMhPar.TL23 > DGD.dT then + tMhPar.TL23 = DGD.dT + end + end + + if tMhPar.TL24 then + if tMhPar.TL24 == -0.5 then + tMhPar.TL24 = DGD.dT / 2 + elseif tMhPar.TL24 == -1 or tMhPar.TL24 > DGD.dT then + tMhPar.TL24 = DGD.dT + 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 = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLG, nLGi, tMhPar.d, dNumLog, sMchngName0) + elseif tMhPar.est and nTempT0 then + tMhPar.d = nTempT0 + end + + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and tMhPar.est and tMhPar.d4 and nTempT00 and nTempT00 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT00, sLG4, nLG4i, tMhPar.d4, dNumLog, sMchngName00) + elseif tMhPar.est and nTempT00 then + tMhPar.d4 = nTempT00 + end + + -------------------------------------------------------------------------------- + -- se c'è materiale steel faccio in modo che non assegni il diametro utensile + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + end + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + -- gestisco il risultato della lettura utensili per antischeggia su extra rettangoli + if DGD.bProoduce and not tMhPar.est and tMhPar.das and nTempT9 and nTempT9 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT9, sASG, nASGi, tMhPar.das, dNumLog, sMchngName9) + elseif not tMhPar.est and nTempT9 then + tMhPar.das = nTempT9 + end + + -- gestisco il risultato della lettura utensili per antischeggia su antischeggia + if DGD.bProoduce and not tMhPar.est and tMhPar.das2 and nTempT10 and nTempT10 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT10, sASGR, nASGRi, tMhPar.das2, dNumLog, sMchngName10) + elseif not tMhPar.est and nTempT10 then + tMhPar.das2 = nTempT10 + end + + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat2 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLGH, nLGHi, nil, dNumLog, sMchngName3) + end + + if DGD.bProoduce and tMhPar.LG3 and not dMaxMat4 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLG3, nLG3i, nil, dNumLog, sMchngName4) + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d4 and nTempT5 and nTempT5 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT5, sLM4, nLM4i, tMhPar.d4, dNumLog, sMchngName5) + elseif not tMhPar.est and nTempT5 then + tMhPar.d4 = nTempT5 + end + + if not tMhPar.est and tMhPar.d6 and nTempT7 and nTempT7 <= 0 then + if DGD.bProoduce and not tMhPar.jn6 then -- se non si concatenano i due percorsi + dNumLog = -1789 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT7, sLM6, nLM6i, tMhPar.d6, dNumLog, sMchngName7) + end + elseif not tMhPar.est and nTempT7 then + tMhPar.d6 = nTempT7 + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + end + + -- chiseling su head face + if tMhPar.ech4 and tMhPar.d00 and nTempT00 > 0 then + tMhPar.d00 = nTempT00 + 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 = -1785 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) + tMhPar.T = dMaxMat0 + end + + if tMhPar.est and tMhPar.T4 and dMaxMat00 and tMhPar.T4 > dMaxMat00 then + dNumLog = -1784 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T4), EgtToUiUnits(dMaxMat00)) + tMhPar.T4 = dMaxMat00 + 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 = -1797 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità della face è maggiore della capacità utensile anti-splint limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat8 and tMhPar.T > dMaxMat8 then + dNumLog = -1786 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat8)) + tMhPar.T = dMaxMat8 + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and not tMhPar.mh and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1796 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if ( not tMhPar.jn or tMhPar.mh or not tMhPar.jnb) and + tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1795 + if tMhPar.mh then + dNumMessage = 463 + else + dNumMessage = 461 + end + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + + -- se profondità foro di testa è maggiore della capacità utensile + if tMhPar.T3 and dMaxMat4 and tMhPar.T3 > dMaxMat4 then + dNumLog = -1792 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat4)) + tMhPar.T3 = dMaxMat4 + end + + -- se la profondità della face è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T4 and dMaxMat5 and tMhPar.T4 > dMaxMat5 then + dNumLog = -1791 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T4), EgtToUiUnits(dMaxMat5)) + tMhPar.T4 = dMaxMat5 + end + + -- se la profondità della face è maggiore della capacità utensile antisplint limito la profondità ed emetto un warning + if tMhPar.T4 and dMaxMat6 and tMhPar.T4 > dMaxMat6 then + dNumLog = -1790 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T4), EgtToUiUnits(dMaxMat6)) + tMhPar.T4 = dMaxMat6 + end + + -- se head mortise concatenata a head face e la profondità della head mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn6 and tMhPar.T6 and dMaxMat5 and tMhPar.T6 > dMaxMat5 then + dNumLog = -1788 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T6), EgtToUiUnits(dMaxMat5)) + tMhPar.T6 = dMaxMat5 + end + + -- se head mortise concatenata a head face e la profondità della head mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn6 and tMhPar.T6 and dMaxMat7 and tMhPar.T6 > dMaxMat7 then + dNumLog = -1787 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T6), EgtToUiUnits(dMaxMat7)) + tMhPar.T6 = dMaxMat7 + end + + -- se raggio minore del diametro utensile lo annullo + if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + + -- se raggio minore del diametro utensile lo annullo + if tMhPar.est and tMhPar.rf4 and tMhPar.rf4 > 0 and tMhPar.cl4 > 0 and tMhPar.d4 and tMhPar.rf4 < ((tMhPar.d4/2)+0.02) then + tMhPar.rf4 = 0 + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + end + + if tMhPar.CLC4 and tMhPar.clc4 and tMhPar.clc4 > 0 and ( tMhPar.clc4 >= tMhPar.H4 or tMhPar.clc4 >= tMhPar.L4) then + tMhPar.clc4 = nil + elseif not tMhPar.CLC4 then + tMhPar.clc4 = nil + 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 = -1783 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -1783 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T3 and abs(tMhPar.T3) > tMhPar.TTP then + dNumLog = -1783 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T3', EgtToUiUnits(tMhPar.T3), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T3 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T4 and abs(tMhPar.T4) > tMhPar.TTP then + dNumLog = -1783 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T4', EgtToUiUnits(tMhPar.T4), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T4 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T6 and abs(tMhPar.T6) > tMhPar.TTP then + dNumLog = -1783 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T6', EgtToUiUnits(tMhPar.T6), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T6 = tMhPar.TTP + end + end + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then + tMhPar.sf = tMhPar.T + end + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.sf4 or abs(tMhPar.sf4) < GEO.EPS_SMALL then + tMhPar.sf4 = tMhPar.T4 + end + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s6 or abs(tMhPar.s6) < GEO.EPS_SMALL then + tMhPar.s6 = tMhPar.T6 + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function FlushBolt.Draw( tLckP, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni geometrie di fianco e di testa + local L = tLckP.L + local H = tLckP.H + local T = tLckP.T + local d = tLckP.d + local d7 = tLckP.d7 + local p = tLckP.p + local d6 = tLckP.d6 + local cl = tLckP.cl + local rf = tLckP.rf + local clc = tLckP.clc + local ccr = tLckP.ccr + local sf = tLckP.sf + local dl = tLckP.dl + local mh = tLckP.mh + local L2 = tLckP.L2 + local H2 = tLckP.H2 + local T2 = tLckP.T2 + local d2 = tLckP.d2 + local p2 = tLckP.p2 + local s = tLckP.s + local H3 = tLckP.H3 + local T3 = tLckP.T3 + local DB_X = tLckP.DB_X -- posizionamento centro foro rispetto angolo porta + local L4 = tLckP.L4 + local H4 = tLckP.H4 + local T4 = tLckP.T4 + local d4 = tLckP.d4 + local p4 = tLckP.p4 + local sf4 = tLckP.sf4 + local cl4 = tLckP.cl4 + local rf4 = tLckP.rf4 + local clc4 = tLckP.clc4 + local ccr4 = tLckP.ccr4 + local mc = tLckP.mc + local d5 = tLckP.d5 + local ech = tLckP.ech + local ech4 = tLckP.ech4 + local est = tLckP.est -- altro materiale trovato + local kbs = tLckP.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tLckP.pbs + local SL = tLckP.SL + local SD = tLckP.SD + local L6 = tLckP.L6 + local H6 = tLckP.H6 + local T6 = tLckP.T6 + local d6 = tLckP.d6 + local p6 = tLckP.p6 + local s6 = tLckP.s6 + local dws = tLckP.Dws + local dthd = tLckP.dThD + local ttp = tLckP.TTP + -- gestione inversione percorsi + local invG = tLckP.invG -- flag per invertire il senso dei percorsi di lavorazione + -- Assegno i flag + local jn = tLckP.jn -- flag per giunzione face con mortasa + local jnb = tLckP.jnb -- flag che indica se profilo tipo bevel o meno + local jn6 = tLckP.jn6 -- flag per giunzione head face con head mortasa + -- Inserimento geometrie probe + local posh = tLckP.posh -- posizione in Y del foro di tastatura + local posp = tLckP.posp -- posizione in X del foro di tastatura + -- Disassamento della mortise rispetto alla face + local D_X = tLckP.D_X -- disassamento cava (mortasa o foro) da centro lunghezza face + local DF_X = tLckP.DF_X -- disassamento cava di testa rispetto a foro di testa + local DM_X = tLckP.DM_X -- disassamento cava (head mortise) da centro lunghezza head face + local D_XE = tLckP.D_XE -- disassamento geometrie sul fianco + -- Assegno le label degli attributi fianco porta + local LG = tLckP.LG + local LG2 = tLckP.LG2 + local LM = tLckP.LM + local LA = tLckP.LA + local CLC = tLckP.CLC -- nome geometria clean corner + -- Assegno le label alla geometria foro profondo di lato + local LGH = tLckP.LGH + -- Assegno le label alla geometria foro profondo di testa + local LG3 = tLckP.LG3 + -- Assegno le label degli attributi testa porta + local LG4 = tLckP.LG4 + local LM4 = tLckP.LM4 + local LM5 = tLckP.LM5 + local LG6 = tLckP.LG6 + local LM6 = tLckP.LM6 + local LM7 = tLckP.LM7 + local CLC4 = tLckP.CLC4 -- nome geometria clean corner + + local CH = tLckP.CH -- nome suffisso lavorazione chisel + local DM = 'DUMMY' -- usato per i cerchi di anteprima + local LH = 'Shuttle_Probe' -- variabile nome geometrie probe + -- Anti-splint su extra rectangle geometry + local EAR = tLckP.EAR + local das = tLckP.das + local ASG = tLckP.ASG + -- Second anti-splint on extra rectangle geometry + local das2 = tLckP.das2 + local ASGR = tLckP.ASGR + -- tabelle per i fori, rettangoli e linee opzionali + local tExtraBore = {} + local tExtraRect = {} + local tExtraLine = {} + local tExtraSHBore = {} + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D10, tLckP.T10, tLckP.PX10, tLckP.PY10, tLckP.EB10, tLckP.RBS10}) + table.insert( tExtraBore, { tLckP.D11, tLckP.T11, tLckP.PX11, tLckP.PY11, tLckP.EB11, tLckP.RBS11}) + table.insert( tExtraBore, { tLckP.D12, tLckP.T12, tLckP.PX12, tLckP.PY12, tLckP.EB12, tLckP.RBS12}) + table.insert( tExtraBore, { tLckP.D13, tLckP.T13, tLckP.PX13, tLckP.PY13, tLckP.EB13, tLckP.RBS13}) + table.insert( tExtraBore, { tLckP.D14, tLckP.T14, tLckP.PX14, tLckP.PY14, tLckP.EB14, tLckP.RBS14}) + table.insert( tExtraBore, { tLckP.D15, tLckP.T15, tLckP.PX15, tLckP.PY15, tLckP.EB15, tLckP.RBS15}) + table.insert( tExtraBore, { tLckP.D16, tLckP.T16, tLckP.PX16, tLckP.PY16, tLckP.EB16, tLckP.RBS16}) + table.insert( tExtraBore, { tLckP.D17, tLckP.T17, tLckP.PX17, tLckP.PY17, tLckP.EB17, tLckP.RBS17}) + table.insert( tExtraBore, { tLckP.D18, tLckP.T18, tLckP.PX18, tLckP.PY18, tLckP.EB18, tLckP.RBS18}) + table.insert( tExtraBore, { tLckP.D19, tLckP.T19, tLckP.PX19, tLckP.PY19, tLckP.EB19, tLckP.RBS19}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR10, tLckP.WR10, tLckP.RR10, tLckP.TR10, tLckP.PRX10, tLckP.PRY10, tLckP.AR10, tLckP.ER10, tLckP.RRS10}) + table.insert( tExtraRect, { tLckP.LR11, tLckP.WR11, tLckP.RR11, tLckP.TR11, tLckP.PRX11, tLckP.PRY11, tLckP.AR11, tLckP.ER11, tLckP.RRS11}) + table.insert( tExtraRect, { tLckP.LR12, tLckP.WR12, tLckP.RR12, tLckP.TR12, tLckP.PRX12, tLckP.PRY12, tLckP.AR12, tLckP.ER12, tLckP.RRS12}) + table.insert( tExtraRect, { tLckP.LR13, tLckP.WR13, tLckP.RR13, tLckP.TR13, tLckP.PRX13, tLckP.PRY13, tLckP.AR13, tLckP.ER13, tLckP.RRS13}) + table.insert( tExtraRect, { tLckP.LR14, tLckP.WR14, tLckP.RR14, tLckP.TR14, tLckP.PRX14, tLckP.PRY14, tLckP.AR14, tLckP.ER14, tLckP.RRS14}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL10, tLckP.TL10, tLckP.PLX10, tLckP.PLY10, tLckP.AL10, tLckP.EL10, tLckP.RLS10}) + table.insert( tExtraLine, { tLckP.LL11, tLckP.TL11, tLckP.PLX11, tLckP.PLY11, tLckP.AL11, tLckP.EL11, tLckP.RLS11}) + table.insert( tExtraLine, { tLckP.LL12, tLckP.TL12, tLckP.PLX12, tLckP.PLY12, tLckP.AL12, tLckP.EL12, tLckP.RLS12}) + table.insert( tExtraLine, { tLckP.LL13, tLckP.TL13, tLckP.PLX13, tLckP.PLY13, tLckP.AL13, tLckP.EL13, tLckP.RLS13}) + table.insert( tExtraLine, { tLckP.LL14, tLckP.TL14, tLckP.PLX14, tLckP.PLY14, tLckP.AL14, tLckP.EL14, tLckP.RLS14}) + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D20, tLckP.T20, tLckP.PX20, tLckP.PY20, tLckP.EB20, tLckP.RBS20}) + table.insert( tExtraBore, { tLckP.D21, tLckP.T21, tLckP.PX21, tLckP.PY21, tLckP.EB21, tLckP.RBS21}) + table.insert( tExtraBore, { tLckP.D22, tLckP.T22, tLckP.PX22, tLckP.PY22, tLckP.EB22, tLckP.RBS22}) + table.insert( tExtraBore, { tLckP.D23, tLckP.T23, tLckP.PX23, tLckP.PY23, tLckP.EB23, tLckP.RBS23}) + table.insert( tExtraBore, { tLckP.D24, tLckP.T24, tLckP.PX24, tLckP.PY24, tLckP.EB24, tLckP.RBS24}) + table.insert( tExtraBore, { tLckP.D25, tLckP.T25, tLckP.PX25, tLckP.PY25, tLckP.EB25, tLckP.RBS25}) + table.insert( tExtraBore, { tLckP.D26, tLckP.T26, tLckP.PX26, tLckP.PY26, tLckP.EB26, tLckP.RBS26}) + table.insert( tExtraBore, { tLckP.D27, tLckP.T27, tLckP.PX27, tLckP.PY27, tLckP.EB27, tLckP.RBS27}) + table.insert( tExtraBore, { tLckP.D28, tLckP.T28, tLckP.PX28, tLckP.PY28, tLckP.EB28, tLckP.RBS28}) + table.insert( tExtraBore, { tLckP.D29, tLckP.T29, tLckP.PX29, tLckP.PY29, tLckP.EB29, tLckP.RBS29}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR20, tLckP.WR20, tLckP.RR20, tLckP.TR20, tLckP.PRX20, tLckP.PRY20, tLckP.AR20, tLckP.ER20, tLckP.RRS20}) + table.insert( tExtraRect, { tLckP.LR21, tLckP.WR21, tLckP.RR21, tLckP.TR21, tLckP.PRX21, tLckP.PRY21, tLckP.AR21, tLckP.ER21, tLckP.RRS21}) + table.insert( tExtraRect, { tLckP.LR22, tLckP.WR22, tLckP.RR22, tLckP.TR22, tLckP.PRX22, tLckP.PRY22, tLckP.AR22, tLckP.ER22, tLckP.RRS22}) + table.insert( tExtraRect, { tLckP.LR23, tLckP.WR23, tLckP.RR23, tLckP.TR23, tLckP.PRX23, tLckP.PRY23, tLckP.AR23, tLckP.ER23, tLckP.RRS23}) + table.insert( tExtraRect, { tLckP.LR24, tLckP.WR24, tLckP.RR24, tLckP.TR24, tLckP.PRX24, tLckP.PRY24, tLckP.AR24, tLckP.ER24, tLckP.RRS24}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL20, tLckP.TL20, tLckP.PLX20, tLckP.PLY20, tLckP.AL20, tLckP.EL20, tLckP.RLS20}) + table.insert( tExtraLine, { tLckP.LL21, tLckP.TL21, tLckP.PLX21, tLckP.PLY21, tLckP.AL21, tLckP.EL21, tLckP.RLS21}) + table.insert( tExtraLine, { tLckP.LL22, tLckP.TL22, tLckP.PLX22, tLckP.PLY22, tLckP.AL22, tLckP.EL22, tLckP.RLS22}) + table.insert( tExtraLine, { tLckP.LL23, tLckP.TL23, tLckP.PLX23, tLckP.PLY23, tLckP.AL23, tLckP.EL23, tLckP.RLS23}) + table.insert( tExtraLine, { tLckP.LL24, tLckP.TL24, tLckP.PLX24, tLckP.PLY24, tLckP.AL24, tLckP.EL24, tLckP.RLS24}) + -- inserimento dati nella tabella fori di lato + table.insert( tExtraSHBore, { tLckP.D30, tLckP.T30, tLckP.I30, tLckP.PX30, tLckP.PY30, tLckP.EB30, tLckP.HB30}) + table.insert( tExtraSHBore, { tLckP.D31, tLckP.T31, tLckP.I31, tLckP.PX31, tLckP.PY31, tLckP.EB31, tLckP.HB31}) + table.insert( tExtraSHBore, { tLckP.D32, tLckP.T32, tLckP.I32, tLckP.PX32, tLckP.PY32, tLckP.EB32, tLckP.HB32}) + table.insert( tExtraSHBore, { tLckP.D33, tLckP.T33, tLckP.I33, tLckP.PX33, tLckP.PY33, tLckP.EB33, tLckP.HB33}) + table.insert( tExtraSHBore, { tLckP.D34, tLckP.T34, tLckP.I34, tLckP.PX34, tLckP.PY34, tLckP.EB34, tLckP.HB34}) + table.insert( tExtraSHBore, { tLckP.D35, tLckP.T35, tLckP.I35, tLckP.PX35, tLckP.PY35, tLckP.EB35, tLckP.HB35}) + table.insert( tExtraSHBore, { tLckP.D36, tLckP.T36, tLckP.I36, tLckP.PX36, tLckP.PY36, tLckP.EB36, tLckP.HB36}) + table.insert( tExtraSHBore, { tLckP.D37, tLckP.T37, tLckP.I37, tLckP.PX37, tLckP.PY37, tLckP.EB37, tLckP.HB37}) + table.insert( tExtraSHBore, { tLckP.D38, tLckP.T38, tLckP.I38, tLckP.PX38, tLckP.PY38, tLckP.EB38, tLckP.HB38}) + table.insert( tExtraSHBore, { tLckP.D39, tLckP.T39, tLckP.I39, tLckP.PX39, tLckP.PY39, tLckP.EB39, tLckP.HB39}) + -- inserimento dati nella tabella fori di testa + table.insert( tExtraSHBore, { tLckP.D40, tLckP.T40, tLckP.I40, tLckP.PX40, tLckP.PY40, tLckP.EB40}) + table.insert( tExtraSHBore, { tLckP.D41, tLckP.T41, tLckP.I41, tLckP.PX41, tLckP.PY41, tLckP.EB41}) + table.insert( tExtraSHBore, { tLckP.D42, tLckP.T42, tLckP.I42, tLckP.PX42, tLckP.PY42, tLckP.EB42}) + table.insert( tExtraSHBore, { tLckP.D43, tLckP.T43, tLckP.I43, tLckP.PX43, tLckP.PY43, tLckP.EB43}) + table.insert( tExtraSHBore, { tLckP.D44, tLckP.T44, tLckP.I44, tLckP.PX44, tLckP.PY44, tLckP.EB44}) + + -- variabili per messaggi e settaggi vari + local sCompoName = tLckP.Nome + local nCompoNpar = tLckP.Npar + local sCompoPath = tLckP.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLckP.nCod + local sCodAdj = tLckP.sCod + -- variabili per messaggi di errore + local sNamePar1 = tLckP.NPL or 'L' + local sNamePar2 = tLckP.NPH or 'H' + local sNamePar3 = tLckP.NPT or 'T' + local sNamePar4 = tLckP.NPd or 'd' + local sNamePar5 = tLckP.NPp or 'p' + local sNamePar7 = tLckP.NL2 or 'L2' + local sNamePar8 = tLckP.NT2 or 'T2' + local sNamePar9 = tLckP.NPd2 or 'd2' + local sNamePar10 = tLckP.NPp2 or 'p2' + local sNamePar11 = tLckP.NPS or 's' + local sNamePar47 = tLckP.NPH2 or 'H2' + local sNamePar48 = tLckP.NPSF or 'sf' + local sNamePar49 = tLckP.NPSF4 or 'sf4' + local sNamePar12 = tLckP.NPH3 or 'H3' + local sNamePar13 = tLckP.NPT3 or 'T3' + local sNamePar14 = tLckP.NPDBX or 'DB_X' + local sNamePar15 = tLckP.NPL4 or 'L4' + local sNamePar16 = tLckP.NPH4 or 'H4' + local sNamePar17 = tLckP.NPT4 or 'T4' + local sNamePar18 = tLckP.NPd4 or 'd4' + local sNamePar19 = tLckP.NPp4 or 'p4' + local sNamePar20 = tLckP.NPDFX or 'DF_X' + local sNamePar21 = tLckP.NPd5 or 'd5' + local sNamePar22 = tLckP.NPrf or 'rf' + local sNamePar23 = tLckP.NPrf4 or 'rf4' + local sNamePar24 = tLckP.NPL6 or 'L6' + local sNamePar25 = tLckP.NPH6 or 'H6' + local sNamePar26 = tLckP.NPT6 or 'T6' + local sNamePar27 = tLckP.NPd6 or 'd6' + local sNamePar28 = tLckP.NPp6 or 'p6' + local sNamePar29 = tLckP.NPS6 or 's6' + local sNamePar30 = tLckP.NPDX or 'D_X' + local sNamePar31 = tLckP.NPDMX or 'DM_X' + local sNamePar32 = tLckP.NPd7 or 'd7' + local sNamePar33 = tLckP.N33 or 'clc' + local sNamePar34 = tLckP.N34 or 'ccr' + local sNamePar35 = tLckP.N35 or 'clc4' + local sNamePar36 = tLckP.N36 or 'ccr4' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1700 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeBoreGeom = true + local bMake2ndFaceGeom = true + local bMakeASFaceGeom = true + local bMakeAS2ndFaceGeom = true + local bMake2ndMortGeom = true + local bStrike2ndFaceGeom + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + clc = nil + CLC = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom then + if L >= H then + if rf > (H/2) then + rf = (H/2) + end + else + if rf > (L/2) then + rf = (L/2) + end + end + end + + -- se tipo extension disattivo l'antisplint fu side face + if not mc or not bMakeFaceGeom then + bMakeASFaceGeom = false + end + + if not bRunByCompo then RC = false end + if not T then T = 0 end + if not T2 then T2 = 0 end + if not D_X then D_X = 0 end + if not DB_X then DB_X = 0 end + if not DF_X then DF_X = 0 end + if not DM_X then DM_X = 0 end + + -- se rilevato profilo bevel disattivo il join tra face e mortasa + if not jnb then jn = false end + + -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione + if not nDrawMach then nDrawMach = 0 end + + -- se rilevato tipo corner disattivo il foro + if mc or not H3 or not T3 or not LG3 then bMakeBoreGeom = false end + + -- se parametri face di testa mancanti + if not L4 or not H4 or not T4 then + bMake2ndFaceGeom = false + jn6 = false -- disattivo il join tra face e mortasa + clc4 = nil + CLC4 = nil + end + -- se parametri mortise di testa mancanti + if not L6 or not H6 or not T6 then + bMake2ndMortGeom = false + jn6 = false -- disattivo il join tra face e mortasa + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMake2ndFaceGeom then + if L4 >= H4 then + if rf4 > (H4/2) then + rf4 = (H4/2) + end + else + if rf4 > (L4/2) then + rf4 = (L4/2) + end + end + end + + -- se tipo extension con cava top/bottom e cava non sconfinante disattivo la creazione dell'antischeggia + if not mc and bMake2ndFaceGeom and ( DB_X + DF_X - (L4/2)) > 0 then bMakeAS2ndFaceGeom = false end + + -- se tipo extension con cava top/bottom e cava sconfinante risistemo la lunghezza cava e gli eventuali arrotondamenti + if not mc and bMake2ndFaceGeom and ( DB_X + DF_X - (L4/2)) < 0 then + L4 = L4/2 + DB_X + DF_X + if cl4 > 1 then -- se arrotondamento a destra o entrambe + cl4 = cl4 - 2 -- se 2 ( solo destra) diventa 0 (nessuno), se 3 (entrambe) diventa 1 ( solo sinistra) + end + bStrike2ndFaceGeom = true + end + + if mh then -- se foro orizzontale + if not H2 then + bMakeMortGeom = false + end + -- disattivo il join + jn = false + else + if not L2 or not H2 then + bMakeMortGeom = false + -- disattivo il join + jn = false + end + end + + if est then + bMakeMortGeom = false + bMakeASFaceGeom = false + bMakeAS2ndFaceGeom = false + bMake2ndMortGeom = false + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + end + + if not ASGR then + das2 = nil + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not mh and d2 < DgMin then + EC = 2 + EM = string.format(EgtDoorsMsg[400],sNamePar9, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EC = 3 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 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 bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 5 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and ( p2 < PtMin or p2 > PtMax) then + EC = 6 + EM = string.format(EgtDoorsMsg[403],sNamePar10,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + p2 = 0.8 + elseif bMakeFaceGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeFaceGeom and L <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d*2 + elseif bMakeFaceGeom and bMakeMortGeom and not mh and L2 and L and L2 >= L then + EC = 9 + EM = string.format(EgtDoorsMsg[406],sNamePar7,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + L2 = L - 0.1 + elseif jn and D_X > ((L-L2)/2) then + EC = 10 + EM = string.format(EgtDoorsMsg[423],sNamePar30,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EC = 11 + EM = string.format(EgtDoorsMsg[456],sNamePar47,EgtToUiUnits(H2),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H2' deve essere <= 'H' + H2 = H + elseif bMakeMortGeom and T2 <= 0 then + EC = 12 + EM = string.format(EgtDoorsMsg[401],sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + T2 = 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 <= T then + EC = 13 + EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + T2 = T + 0.1 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and s and s <= 0 then + EC = 14 + EM = string.format(EgtDoorsMsg[401],sNamePar11,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d2 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and L2 and L2 <= d2 then + if DGD.bProoduce then + EC = 15 + EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L2 = d + 0.002 + else + d = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not mh and H2 and H2 < d2 then + if DGD.bProoduce then + EC = 16 + EM = string.format(EgtDoorsMsg[405],sNamePar47,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeFaceGeom and H <= 0 then + EC = 17 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d + elseif bMakeMortGeom and H2 <= 0 then + EC = 18 + EM = string.format(EgtDoorsMsg[401],sNamePar47,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 + H2 = d2 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 19 + EM = string.format(EgtDoorsMsg[401],sNamePar48,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMake2ndFaceGeom and nDrawMach > 0 and d4 < DgMin then + EC = 20 + EM = string.format(EgtDoorsMsg[400],sNamePar18, EgtToUiUnits(d4),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d4 = DgMin + elseif bMake2ndFaceGeom and bMakeAS2ndFaceGeom and nDrawMach > 0 and d5 and d5 < DgMin then + EC = 21 + EM = string.format(EgtDoorsMsg[400],sNamePar21, EgtToUiUnits(d5),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d5 = DgMin + elseif bMake2ndFaceGeom and nDrawMach > 0 and H4 < d4 then + if DGD.bProoduce then + EC = 22 + EM = string.format(EgtDoorsMsg[405],sNamePar16,EgtToUiUnits(H4),EgtToUiUnits(d4), sCompoPath) -- il parametro 'H4' deve essere >= del diametro utensile + H4 = d4 + else + d4 = H4 - 0.002 + end + elseif bMake2ndFaceGeom and nDrawMach > 0 and L4 <= d4 then + if DGD.bProoduce then + EC = 23 + EM = string.format(EgtDoorsMsg[402],sNamePar15,EgtToUiUnits(L4),sNamePar18,EgtToUiUnits(d4), sCompoPath) -- il parametro 'L4' deve essere maggiore al diametro utensile + L4 = d4 + 0.002 + else + d4 = L4 - 0.002 + end + elseif bMake2ndFaceGeom and nDrawMach > 0 and ( p4 < PtMin or p4 > PtMax) then + EC = 24 + EM = string.format(EgtDoorsMsg[403],sNamePar19,p4,PtMin,PtMax, sCompoPath) -- il parametro 'p4' deve essere compreso tra + p4 = 0.8 + elseif bMake2ndFaceGeom and T4 < 0 then + EC = 25 + EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(T4), sCompoPath) -- il parametro 'T4' deve essere >= 0 + T4 = 0 + elseif bMake2ndFaceGeom and L4 <= 0 then + EC = 26 + EM = string.format(EgtDoorsMsg[401],sNamePar15,EgtToUiUnits(L4), sCompoPath) -- il parametro 'L4' deve essere > 0 + L4 = d*2 +-- elseif bMake2ndFaceGeom and bMakeBoreGeom and H3 > H4 then +-- EC = 27 +-- EM = string.format(EgtDoorsMsg[456],sNamePar12,EgtToUiUnits(H3),sNamePar16,EgtToUiUnits(H4), sCompoPath) -- il parametro 'H3' deve essere <= 'H4' +-- H3 = H4 + elseif bMake2ndFaceGeom and bMakeAS2ndFaceGeom and nDrawMach > 0 and d5 and H4 < d5 then + if DGD.bProoduce then + EC = 28 + EM = string.format(EgtDoorsMsg[405],sNamePar16,EgtToUiUnits(H4),EgtToUiUnits(d5), sCompoPath) -- il parametro 'H4' deve essere >= del diametro utensile + H4 = d5 + else + d5 = H4 - 0.002 + end +-- elseif bMakeBoreGeom and DB_X <= H3/2 then +-- EC = 29 +-- EM = string.format(EgtDoorsMsg[407],sNamePar14,EgtToUiUnits(DB_X),sNamePar12..'/2',EgtToUiUnits(H3/2), sCompoPath) -- il parametro 'DB_X' deve essere > 'H3/2' +-- DB_X = H3/2 + 0.1 + elseif bMake2ndFaceGeom and nDrawMach > 0 and sf4 and sf4 <= 0 then + EC = 30 + EM = string.format(EgtDoorsMsg[401],sNamePar49,EgtToUiUnits(sf4), sCompoPath) -- il parametro 'sf4' deve essere > 0 + sf4 = d + elseif bMakeFaceGeom and cl and cl > 0 and rf < 0 then + EC = 31 + EM = string.format(EgtDoorsMsg[404],sNamePar22,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + rf = H/2 + elseif bMake2ndFaceGeom and cl4 and cl4 > 0 and rf4 < 0 then + EC = 32 + EM = string.format(EgtDoorsMsg[404],sNamePar23,EgtToUiUnits(rf4), sCompoPath) -- il parametro 'rf4' deve essere >= 0 + rf4 = H4/2 + elseif bMake2ndMortGeom and nDrawMach > 0 and not jn6 and d6 < DgMin then + EC = 33 + EM = string.format(EgtDoorsMsg[400],sNamePar27, EgtToUiUnits(d6),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d6 = DgMin + elseif bMake2ndMortGeom and nDrawMach > 0 and not jn6 and H6 < d6 then + if DGD.bProoduce then + EC = 34 + EM = string.format(EgtDoorsMsg[405],sNamePar25,EgtToUiUnits(H6),EgtToUiUnits(d6), sCompoPath) -- il parametro 'H6' deve essere >= del diametro utensile + H6 = d6 + else + d6 = H6 - 0.002 + end + elseif nDrawMach > 0 and jn6 and H6 < d4 then + if DGD.bProoduce then + EC = 35 + EM = string.format(EgtDoorsMsg[405],sNamePar25,EgtToUiUnits(H6),EgtToUiUnits(d4), sCompoPath) -- il parametro 'H6' deve essere >= del diametro utensile + H6 = d4 + else + d4 = H6 - 0.002 + end + elseif bMake2ndMortGeom and nDrawMach > 0 and not jn6 and L6 <= d6 then + if DGD.bProoduce then + EC = 36 + EM = string.format(EgtDoorsMsg[402],sNamePar24,EgtToUiUnits(L6),sNamePar27,EgtToUiUnits(d6), sCompoPath) -- il parametro 'L6' deve essere maggiore al diametro utensile + L6 = d6 + 0.002 + else + d6 = L6 - 0.002 + end + elseif nDrawMach > 0 and jn6 and L6 <= d4 then + if DGD.bProoduce then + EC = 37 + EM = string.format(EgtDoorsMsg[402],sNamePar24,EgtToUiUnits(L6),sNamePar18,EgtToUiUnits(d4), sCompoPath) -- il parametro 'L6' deve essere maggiore al diametro utensile + L6 = d4 + 0.002 + else + d4 = L6 - 0.002 + end + elseif bMake2ndMortGeom and nDrawMach > 0 and not jn6 and ( p6 < PtMin or p6 > PtMax) then + EC = 38 + EM = string.format(EgtDoorsMsg[403],sNamePar28,p6,PtMin,PtMax, sCompoPath) -- il parametro 'p6' deve essere compreso tra + p6 = 0.8 + elseif nDrawMach > 0 and jn6 and L6 >= L4 then + EC = 39 + EM = string.format(EgtDoorsMsg[406],sNamePar24,EgtToUiUnits(L6),sNamePar15,EgtToUiUnits(L4), sCompoPath) -- il parametro 'L6' deve essere < 'L4' + L6 = L4 - 0.1 + elseif nDrawMach > 0 and jn6 and DM_X > ((L4-L6)/2) then + EC = 40 + EM = string.format(EgtDoorsMsg[423],sNamePar31,EgtToUiUnits(DM_X),EgtToUiUnits((L4-L6)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif nDrawMach > 0 and jn6 and H6 > H4 then + EC = 41 + EM = string.format(EgtDoorsMsg[456],sNamePar25,EgtToUiUnits(H6),sNamePar16,EgtToUiUnits(H4), sCompoPath) -- il parametro 'H6' deve essere <= 'H4' + H6 = H4 + elseif nDrawMach > 0 and jn6 and T6 <= T4 then + EC = 42 + EM = string.format(EgtDoorsMsg[407],sNamePar26,EgtToUiUnits(T6),sNamePar17,EgtToUiUnits(T4), sCompoPath) -- il parametro 'T6' deve essere > 'T4' + T2 = T + 0.1 + elseif bMake2ndMortGeom and nDrawMach > 0 and not jn6 and s6 and s6 <= 0 then + EC = 43 + EM = string.format(EgtDoorsMsg[401],sNamePar29,EgtToUiUnits(s6), sCompoPath) -- il parametro 's6' deve essere > 0 + s6 = d6 + elseif bMake2ndMortGeom and T6 < 0 then + EC = 44 + EM = string.format(EgtDoorsMsg[404],sNamePar26,EgtToUiUnits(T6), sCompoPath) -- il parametro 'T6' deve essere >= 0 + T6 = 0 + elseif bMake2ndMortGeom and L6 <= 0 then + EC = 45 + EM = string.format(EgtDoorsMsg[401],sNamePar24,EgtToUiUnits(L6), sCompoPath) -- il parametro 'L6' deve essere > 0 + L6 = d*2 + elseif bMakeFaceGeom and bMakeASFaceGeom and nDrawMach > 0 and d7 and d7 < DgMin then + EC = 46 + EM = string.format(EgtDoorsMsg[400],sNamePar32, EgtToUiUnits(d7),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d5 = DgMin + elseif bMakeFaceGeom and bMakeASFaceGeom and nDrawMach > 0 and d7 and H < d7 then + if DGD.bProoduce then + EC = 47 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d7), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + H4 = d5 + else + d5 = H4 - 0.002 + end + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 48 + EM = string.format(EgtDoorsMsg[407],sNamePar33,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + elseif bMake2ndFaceGeom and CLC4 and clc4 and ccr4 and clc4 > 0 and ccr4 > 0 and (2*(ccr4*sin(45))) >= clc4 then + EC = 49 + EM = string.format(EgtDoorsMsg[407],sNamePar35,EgtToUiUnits(clc4),'',EgtToUiUnits(2*(ccr4*sin(45))), sCompoPath) -- il parametro 'clc4' deve essere > 'crc' + clc4 = (2*(ccr4*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 principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + local nPos1st = 0 + local nPos2nd = 0 + local hint, hint_2, hint_3, hint_4, hint_6 -- variabili percorsi principali su fianco + local hint_10, hint_11, hint_13, hint_14, hint_15 -- variabili percorsi su secure o keyway + local hintAs, hintAs_4 + local nClc1, nClc2, nClc3, nClc4, nClc1h, nClc2h, nClc3h, nClc4h + local hintPk, hintPk2, hintPk4, hintPk6 -- variabili percorsi di lavorazione + local nPkJoin + local dFirstface = {} + local dSecondface = {} + local dFirstMortise = {} + local dSecondMortise = {} + local nForceMakeFace = nDrawMach + + if bMakeFaceGeom then -- se face su fianco abilitata + + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPos1st = rf/2 + elseif cl == 2 then -- se arrotondamento a destra + nPos1st = -(rf/2) + else + nPos1st = 0 + end + + -- prima cava face completa + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = L + dFirstface.H = H + dFirstface.T = T + dFirstface.d = d + dFirstface.p = p + dFirstface.sf = sf + dFirstface.jn = jn + dFirstface.L2 = L2 + dFirstface.H2 = H2 + dFirstface.cl = cl + dFirstface.rf = rf + dFirstface.est = est + dFirstface.invG = invG + if ech then + dFirstface.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 + else + dFirstface.LG = LG + end + dFirstface.LM = LM + dFirstface.Nome = sCompoName + -- lancio il componente base per disegnare la face completa + if mc then -- se tipo corner + dFirstface.D_X = D_X + if bMakeASFaceGeom then + dFirstface.d2 = d7 + dFirstface.LA = LM7 + else + dFirstface.d2 = nil -- resetto il parametro per antischeggia + dFirstface.LA = nil -- resetto la label per antischeggia + end + MHgen = require( '_LatchCorner') + else + dFirstface.D_X = D_X - nPos1st + MHgen = require( '_Latch') + end + dFirstface.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + hint, hintPk, hintAs = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- setto le note che indicareno su che lato della porta devono essere messe le geometrie + local sSide = EgtIf( dl, 'Lock', 'Side') + + if hint then + EgtSetInfo(hint,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint, 'ProbeSide', '1') + end + end + if hintPk then + EgtSetInfo(hintPk,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPk, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk, 'ProbeSide', '1') + end + end + if hintAs then + EgtSetInfo(hintAs,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintAs, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + end + + -- Clean corner on side + if nDrawMach >= 0 then -- se abilitata geometria + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo + if CLC and clc and clc > 0 and clc < H and clc < L then + + nClc1 = MakeClcPath( clc, ccr, CLC, Lg, -T, (invG == -1)) + if nClc1 then + -- se mantiene backset + if kbs and kbs > 0 then + EgtSetInfo( nClc1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nClc1, 'ProbeSide', '1') + end + EgtSetInfo( nClc1,'SideDoor',sSide) + if cl <= 1 or cl == 3 then + -- angolo x+y+ + nClc2 = EgtCopyGlob( nClc1, Lg) + EgtRotate( nClc2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( nClc2, Point3d( EgtIf( mc, L, (L/2)),(H/2),0) - ORIG()) + -- angolo x+y- + nClc3 = EgtCopyGlob( nClc1, Lg) + EgtRotate( nClc3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( nClc3, Point3d(EgtIf( mc, L, (L/2)),-(H/2),0) - ORIG()) + if cl == 1 or mc then + EgtErase(nClc1) + end + end + if not mc and ( cl == 0 or cl >= 2) then + -- angolo x-y- + nClc4 = EgtCopyGlob( nClc1, Lg) + EgtRotate( nClc4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( nClc4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( nClc1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + end + end + + if bMakeMortGeom then -- se mortise su fianco abilitata + + if mh then -- se devo fare il foro + + hint_2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_2, -T2) + EgtSetName(hint_2,LGH) + -- se mantiene centro spessore su mortise + if kbs and kbs > 1 then + EgtSetInfo( hint_2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + else + -- assegno i valori coerenti con la tabella del componente + dFirstMortise.T = T + dFirstMortise.L2 = L2 + dFirstMortise.H2 = H2 + dFirstMortise.T2 = T2 + dFirstMortise.s = s + dFirstMortise.d = d + dFirstMortise.p = p + dFirstMortise.jn = jn + dFirstMortise.d3 = d2 + dFirstMortise.p3 = p2 + dFirstMortise.invG = invG + dFirstMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dFirstMortise.L3 = L2 + dFirstMortise.H3 = H2 + dFirstMortise.LGM = LG2 + dFirstMortise.LMM = LA + dFirstMortise.Nome = sCompoName + dFirstMortise.jne = false + dFirstMortise.D_X = D_X + + -- lancio il secondo componente base + if mc then -- se tipo corner + MHgen = require('_MortiseCorner') + else + MHgen = require('_Mortise') + end + hint_2, hintPk2 = MHgen.Draw( EC, EM, dFirstMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, 0) + end + + -- setto le note che indicareno su che lato della porta devono essere messe le geometrie + if hint_2 then EgtSetInfo( hint_2, 'SideDoor', 'Lock') end + if hintPk2 then EgtSetInfo( hintPk2, 'SideDoor', 'Lock') end + end + + if bMakeBoreGeom then -- se foro di testa abilitato + + hint_3 = EgtCircle( Lg, Point3d(0,0,0), H3/2 , GDB_RT.LOC) + if hint_3 then + EgtModifyCurveThickness( hint_3, -T3) + EgtSetName( hint_3, LG3) + EgtSetInfo( hint_3, 'SideDoor', 'Lock') + EgtSetInfo( hint_3, 'HeadSide', 'head') + -- se mantiene centro spessore su mortise + if kbs and kbs > 1 then + EgtSetInfo( hint_3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_3, 'ProbeSide', '1') + end + end + end + + if bMake2ndFaceGeom then -- se cava di testa abilitata + + -- in base agli arrotondamenti della seconda faccia, calcolo lo spostamento per posizionare la cava in centro + if cl4 == 1 then -- se arrotondamento a sinistra + nPos2nd = -(rf4/2) + elseif cl4 == 2 then -- se arrotondamento a destra + nPos2nd = rf4/2 + else + nPos2nd = 0 + end + + local clTemp + + -- riassegno il valore impostazione originario + nForceMakeFace = nDrawMach + + -- prima cava face completa + -- assegno i valori coerenti con la tabella del componente + dSecondface.L = L4 + dSecondface.H = H4 + dSecondface.T = T4 + dSecondface.d = d4 + dSecondface.p = p4 + dSecondface.rf = rf4 + dSecondface.sf = sf4 + dSecondface.jn = jn6 + dSecondface.L2 = L6 + dSecondface.H2 = H6 + dSecondface.est = est + dSecondface.invG = invG + if ech4 then + dSecondface.LG = LG4 .. 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 + else + dSecondface.LG = LG4 + end + dSecondface.LM = LM4 + dSecondface.Nome = sCompoName + + -- inverto la raggiatura e l'applicazione dei clean corner + -- perché poi viene fatta una rotazione di 180 gradi + if mc then -- se tipo corner + if cl4 == 1 then + dSecondface.cl = 2 + clTemp = 2 + elseif cl4 == 2 then + dSecondface.cl = 1 + clTemp = 1 + else + dSecondface.cl = cl4 + clTemp = cl4 + end + else -- altrimenti tipo extension + if cl4 == 1 then + dSecondface.cl = 2 + clTemp = 2 + elseif cl4 == 2 then + dSecondface.cl = 1 + clTemp = 1 + else + dSecondface.cl = cl4 + clTemp = cl4 + end + end + + -- lancio il componente base per disegnare la face completa + if mc or bStrike2ndFaceGeom then -- se tipo corner o tipo extension ma sconfinante dal bordo + dSecondface.D_X = 0 + dSecondface.d2 = d5 + dSecondface.LA = LM5 + MHgen = require( '_LatchCorner') + else + dSecondface.D_X = - nPos2nd + DM_X + dSecondface.d2 = nil -- resetto il parametro per antischeggia + dSecondface.LA = nil -- resetto la label per antischeggia + MHgen = require( '_Latch') + end + dSecondface.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + hint_4, hintPk4, hintAs_4 = MHgen.Draw( EC, EM, dSecondface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if hint_4 then + EgtSetInfo( hint_4, 'SideDoor', 'Lock') + EgtSetInfo( hint_4, 'HeadSide', 'head') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint_4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_4, 'ProbeSide', '1') + end + end + if hintPk4 then + EgtSetInfo( hintPk4, 'SideDoor', 'Lock') + EgtSetInfo( hintPk4, 'HeadSide', 'head') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPk4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk4, 'ProbeSide', '1') + end + end + if hintAs_4 then + EgtSetInfo( hintAs_4, 'SideDoor', 'Lock') + EgtSetInfo( hintAs_4, 'HeadSide', 'head') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintAs_4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs_4, 'ProbeSide', '1') + end + end + + -- Clean corner on head + if nDrawMach >= 0 then -- se abilitata geometria + if clTemp ~= 3 or ( clTemp == 3 and rf4 > 0) then -- se c'è almeno un lato senza raccordo + if CLC4 and clc4 and clc4 > 0 and clc4 < H4 and clc4 < L4 then + + nClc1h = MakeClcPath( clc4, ccr4, CLC4, Lg, -T4, (invG == -1)) + if nClc1h then + -- se mantiene backset + if kbs and kbs > 0 then + EgtSetInfo( nClc1h, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nClc1h, 'ProbeSide', '1') + end + EgtSetInfo( nClc1h, 'SideDoor', 'Lock') + EgtSetInfo( nClc1h, 'HeadSide', 'head') + if clTemp <= 1 or clTemp == 3 then + -- angolo x+y+ + nClc2h = EgtCopyGlob( nClc1h, Lg) + EgtRotate( nClc2h, Point3d(0,0,0), Z_AX(), -90) + EgtMove( nClc2h, Point3d( EgtIf( mc or bStrike2ndFaceGeom, L4, (L4/2)-nPos2nd),(H4/2),0) - ORIG()) + -- angolo x+y- + nClc3h = EgtCopyGlob( nClc1h, Lg) + EgtRotate( nClc3h, Point3d(0,0,0), Z_AX(), 180) + EgtMove( nClc3h, Point3d( EgtIf( mc or bStrike2ndFaceGeom, L4, (L4/2)-nPos2nd),-(H4/2),0) - ORIG()) + if clTemp == 1 or mc or bStrike2ndFaceGeom then + EgtErase(nClc1h) + end + end + if not mc and not bStrike2ndFaceGeom and ( clTemp == 0 or clTemp >= 2) then + -- angolo x-y- + nClc4h = EgtCopyGlob( nClc1h, Lg) + EgtRotate( nClc4h, Point3d(0,0,0), Z_AX(), 90) + EgtMove( nClc4h, Point3d(-(L4/2)-nPos2nd,-(H4/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( nClc1h, Point3d(-(L4/2)-nPos2nd,(H4/2),0) - ORIG()) + elseif not mc and bStrike2ndFaceGeom then + EgtErase(nClc1h) + end + end + end + end + end + end + + if bMake2ndMortGeom then -- se mortise di testa abilitata + + -- assegno i valori coerenti con la tabella del componente + dSecondMortise.T = T4 + dSecondMortise.L2 = L6 + dSecondMortise.H2 = H6 + dSecondMortise.T2 = T6 + dSecondMortise.s = s6 + dSecondMortise.d = d4 + dSecondMortise.p = p4 + dSecondMortise.jn = jn6 + dSecondMortise.d3 = d6 + dSecondMortise.p3 = p6 + dSecondMortise.invG = invG + dSecondMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dSecondMortise.L3 = L6 + dSecondMortise.H3 = H6 + dSecondMortise.LGM = LG6 + dSecondMortise.LMM = LM6 + dSecondMortise.Nome = sCompoName + dSecondMortise.jne = false + dSecondMortise.D_X = DM_X + + MHgen = require('_Mortise') + hint_6, hintPk6 = MHgen.Draw( EC, EM, dSecondMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, 0) + + -- setto le note che indicareno su che lato della porta devono essere messe le geometrie + if hint_6 then + EgtSetInfo(hint_6,'SideDoor','Lock') + EgtSetInfo(hint_6,'HeadSide','head') + end + if hintPk6 then + EgtSetInfo(hintPk6,'SideDoor','Lock') + EgtSetInfo(hintPk6,'HeadSide','head') + end + end + + if EC == 0 and not mc and (hint or hintPk) and abs(nPos1st) > GEO.EPS_SMALL then -- se esiste la prima face + if hint then + EgtMove( hint, Point3d(nPos1st,0,0) - ORIG()) + end + if hintPk then + EgtMove( hintPk, Point3d(nPos1st,0,0) - ORIG()) + end + end + + if EC == 0 and mh and hint_2 and abs(D_X) > GEO.EPS_SMALL then -- se esiste il secondo foro + EgtMove( hint_2, Point3d(D_X,0,0) - ORIG()) + end + + if EC == 0 and not mh and (hint_2 or hintPk2) and abs(D_X) > GEO.EPS_SMALL then -- se esiste la seconda cava + if hint_2 then + EgtMove( hint_2, Point3d(D_X,0,0) - ORIG()) + end + if hintPk2 then + EgtMove( hintPk2, Point3d(D_X,0,0) - ORIG()) + end + end + + if jn and EC == 0 and hintPk and hintPk2 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( hintPk, 'MVar') + nPkJoin = EgtCurveCompo( Lg, {hintPk,hintPk2}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM) + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + if sVarNote then EgtSetInfo( nPkJoin, 'MVar', sVarNote) end + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo(nPkJoin,'SideDoor','Lock') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin, 'ProbeSide', '1') + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 50 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and hintPk2 then + -- se mantiene centro spessore su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintPk2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2, 'ProbeSide', '1') + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + end + + if EC == 0 then + + -- Costruzione della geometria side + -- Extra side bores + for k = 1, 10 do + + local D10 = tExtraSHBore[k][1] + local T10 = tExtraSHBore[k][2] + local I10 = tExtraSHBore[k][3] + local PX10 = tExtraSHBore[k][4] + local PY10 = tExtraSHBore[k][5] + local EB10 = tExtraSHBore[k][6] + local HB10 = tExtraSHBore[k][7] + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + -- se dimensioni foro sono idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 = PX10 + local nBI = 0 + -- creo foro o asola con eventuale svuotatura a rampa + nBI = MakeBore( Lg, EB10, dPosX10, dInt10, D10, PY10, T10, kbs, HB10, dws, nBI, D_XE, nil, nil, pbs) + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + nBI = MakeBore( Lg, EB10, dPosX10, -dInt10, D10, PY10, T10, kbs, HB10, dws, nBI, D_XE, nil, nil, pbs) + end + end + end + end + + -- se tipo extension muovo le geometrie del delta impostato + if not mc then + + if D_XE and D_XE ~= 0 then + + if nPkJoin then + EgtMove( nPkJoin, Point3d(D_XE,0,0) - ORIG()) + end + if hint_2 then + EgtMove( hint_2, Point3d(D_XE,0,0) - ORIG()) + end + if hintPk2 then + EgtMove( hintPk2, Point3d(D_XE,0,0) - ORIG()) + end + if hintPk then + EgtMove( hintPk, Point3d(D_XE,0,0) - ORIG()) + end + if hint then + EgtMove( hint, Point3d(D_XE,0,0) - ORIG()) + end + if hintAs then + EgtMove( hintAs, Point3d(D_XE,0,0) - ORIG()) + end + if nClc1 then + EgtMove( nClc1, Point3d(D_XE,0,0) - ORIG()) + end + if nClc2 then + EgtMove( nClc2, Point3d(D_XE,0,0) - ORIG()) + end + if nClc3 then + EgtMove( nClc3, Point3d(D_XE,0,0) - ORIG()) + end + if nClc4 then + EgtMove( nClc4, Point3d(D_XE,0,0) - ORIG()) + end + end + end + end + + if EC == 0 then + + local dValX = (DB_X+DF_X+nPos2nd) + local dShiftZed = DGD.POSITION + + if bStrike2ndFaceGeom then dValX = 0 end + + -- Costruzione Extra head bores + for k = 11, 15 do + + local D10 = tExtraSHBore[k][1] + local T10 = tExtraSHBore[k][2] + local I10 = tExtraSHBore[k][3] + local PX10 = tExtraSHBore[k][4] + local PY10 = tExtraSHBore[k][5] + local EB10 = tExtraSHBore[k][6] + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + -- se dimensioni foro sono idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + -- azzero il parametro position e dValX + if mc then + dShiftZed = 0 + dValX=0 + end + + local dInt10 = (I10/2) + local dPosX10 = PX10 + local nBI = 0 + -- creo foro o asola con eventuale svuotatura a rampa + nBI = MakeBore( Lg, EB10, dPosX10, dInt10, D10, -PY10, T10, kbs, false, false, nBI, dValX, true, dShiftZed, pbs) + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + nBI = MakeBore( Lg, EB10, dPosX10, -dInt10, D10, -PY10, T10, kbs, false, false, nBI, dValX, true, dShiftZed, pbs) + end + end + end + end + + -- se tipo extension le sposto e la ruoto + if not mc then + if hint_4 then + EgtMove( hint_4, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( hint_4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint_4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintPk4 then + EgtMove( hintPk4, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( hintPk4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintPk4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintAs_4 then + EgtMove( hintAs_4, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( hintAs_4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintAs_4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hint_6 then + EgtMove( hint_6, Point3d(dValX+DM_X,0,DGD.POSITION) - ORIG()) + EgtRotate( hint_6, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint_6, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintPk6 then + EgtMove( hintPk6, Point3d(dValX+DM_X,0,DGD.POSITION) - ORIG()) + EgtRotate( hintPk6, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintPk6, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc1h then + EgtMove( nClc1h, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( nClc1h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc1h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc2h then + EgtMove( nClc2h, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( nClc2h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc2h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc3h then + EgtMove( nClc3h, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( nClc3h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc3h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc4h then + EgtMove( nClc4h, Point3d(dValX,0,DGD.POSITION) - ORIG()) + EgtRotate( nClc4h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc4h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + end + end + + -- se tipo extension ed esiste il foro di testa lo sposto e lo ruoto + if EC == 0 and not mc and hint_3 then + EgtMove( hint_3, Point3d(DB_X,0,DGD.POSITION) - ORIG()) + EgtRotate( hint_3, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint_3, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + + -- se tipo corner ed esiste almeno una geometria le sposto e la ruoto + if EC == 0 and mc then + if hint_4 then + EgtRotate( hint_4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint_4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintPk4 then + EgtRotate( hintPk4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintPk4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintAs_4 then + EgtRotate( hintAs_4, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintAs_4, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hint_6 then + EgtRotate( hint_6, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hint_6, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if hintPk6 then + EgtRotate( hintPk6, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( hintPk6, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc1h then + EgtRotate( nClc1h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc1h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc2h then + EgtRotate( nClc2h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc2h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc3h then + EgtRotate( nClc3h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc3h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + if nClc4h then + EgtRotate( nClc4h, ORIG(), Z_AX(), 180 ) -- ribalto in Z + EgtRotate( nClc4h, ORIG(), Y_AX(), -90 ) -- ruoto in Y per posizionarlo in testa ( con swing RH/RHR) + end + end + + if jn6 and EC == 0 and hintPk4 and hintPk6 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( hintPk4, 'MVar') + nPkJoin = EgtCurveCompo( Lg, {hintPk4,hintPk6}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM6) + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + if sVarNote then EgtSetInfo( nPkJoin, 'MVar', sVarNote) end + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin, 'HeadSide', 'head') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_6, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin, 'ProbeSide', '1') + EgtSetInfo( hint_6, 'ProbeSide', '1') + end + else + EC = ErrorBase + 51 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn6 and EC == 0 and hintPk6 then + -- se mantiene centro spessore su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintPk6, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_6, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk6, 'ProbeSide', '1') + EgtSetInfo( hint_6, 'ProbeSide', '1') + end + end + + if EC == 0 and nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + if mc then + dPosProbe = L + posp + else + dPosProbe = (L/2) + posp + if SD == 'top' then + if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + else + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + else + if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + else + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + end + end + end + elseif mc then + dPosProbe = (L/2) + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo + if DGC.Fpd then + sSideDoorInfo = 'Lock' + else + sSideDoorInfo = EgtIf( dl, 'Lock', 'Side') + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + if dPosProbe > 0 and not mc then + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + + -- inserisco geometria extra Keyway + if EC == 0 then -- se nessun errore + + -- Costruzione della geometria KEYWAY + -- Extra bores Keyway + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + -- se dimensioni foro idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup( Pz, GDB_RT.LOC) + EgtSetName( Lg, sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,PY10,0), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -T10) + EgtSetName( hint_13, EB10) + EgtSetInfo( hint_13, 'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13, 'ReferHw',RBS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- Extra rectangles Keyway + for k = 1, 5 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + + -- se parametri esistenti e dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(PRY10+(WR10/2)),0), RR10, AR10) + EgtModifyCurveThickness( hint_13, -TR10) + EgtSetName( hint_13,ER10) + EgtSetInfo( hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13,'ReferHw',RRS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and EAR and (( das and das > 0) or ( das2 and das2 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, nil, + das, nil, nil, das2, SL, + 'keyway') + + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TR10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TR10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Extra lines Keyway + for k = 1, 5 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -TL10) + EgtSetName( hint_13,EL10) + EgtSetInfo( hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13,'ReferHw',RLS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TL10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TL10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Costruzione della geometria SECURE + -- Extra bores Secure + for k = 11, 20 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,-PY10,0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -T10) + EgtSetName( hint_13,EB10) + EgtSetInfo( hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13,'ReferHw',RBS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Extra rectangles Secure + for k = 6, 10 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + + -- se dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(-PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(-PRY10+(WR10/2)),0), RR10, AR10) + EgtModifyCurveThickness( hint_13, -TR10) + EgtSetName( hint_13, ER10) + EgtSetInfo( hint_13, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13, 'ReferHw', RRS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and EAR and (( das and das > 0) or ( das2 and das2 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, nil, + das, true, nil, das2, SL, + 'secure') + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TR10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TR10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Extra lines Secure + for k = 6, 10 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,-PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -TL10) + EgtSetName( hint_13,EL10) + EgtSetInfo( hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13,'ReferHw',RLS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TL10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TL10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_2 then + nIdSideBoxUp = EgtCopyGlob( hint_2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_3 then + nIdSideBoxUp = EgtCopyGlob( hint_3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_4 then + nIdSideBoxUp = EgtCopyGlob( hint_4, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_6 then + nIdSideBoxUp = EgtCopyGlob( hint_6, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer del flush bolt + EgtSetInfo( Lg, 'Type' ,'FlushBolt') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'cl' ,cl) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'dl' ,dl) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'mh' ,mh) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'p2' ,p2) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'jn' ,jn) + EgtSetInfo( Lg, 'jnb' ,jnb) + EgtSetInfo( Lg, 'D_X' ,D_X) + EgtSetInfo( Lg, 'H3' ,H3) + EgtSetInfo( Lg, 'T3' ,T3) + EgtSetInfo( Lg, 'DB_X' ,DB_X) + EgtSetInfo( Lg, 'L4' ,L4) + EgtSetInfo( Lg, 'H4' ,H4) + EgtSetInfo( Lg, 'T4' ,T4) + EgtSetInfo( Lg, 'd4' ,d4) + EgtSetInfo( Lg, 'p4' ,p4) + EgtSetInfo( Lg, 'sf4' ,sf4) + EgtSetInfo( Lg, 'cl4' ,cl4) + EgtSetInfo( Lg, 'rf4' ,rf4) + EgtSetInfo( Lg, 'clc4' ,clc4) + EgtSetInfo( Lg, 'ccr4' ,ccr4) + EgtSetInfo( Lg, 'DF_X' ,DF_X) + EgtSetInfo( Lg, 'mc' ,mc) + EgtSetInfo( Lg, 'd5' ,d5) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'ech4' ,ech4) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'SL' ,SL) + EgtSetInfo( Lg, 'L6' ,L6) + EgtSetInfo( Lg, 'H6' ,H6) + EgtSetInfo( Lg, 'T6' ,T6) + EgtSetInfo( Lg, 'd6' ,d6) + EgtSetInfo( Lg, 'p6' ,p6) + EgtSetInfo( Lg, 's6' ,s6) + EgtSetInfo( Lg, 'jn6' ,jn6) + EgtSetInfo( Lg, 'DM_X' ,DM_X) + EgtSetInfo( Lg, 'D_XE' ,D_XE) + EgtSetInfo( Lg, 'dws' ,dws) + EgtSetInfo( Lg, 'dthd' ,dthd) + EgtSetInfo( Lg, 'ttp' ,ttp) + EgtSetInfo( Lg, 'LG' ,LG) + EgtSetInfo( Lg, 'LG2' ,LG2) + EgtSetInfo( Lg, 'LM' ,LM) + EgtSetInfo( Lg, 'LA' ,LA) + EgtSetInfo( Lg, 'LGH' ,LGH) + EgtSetInfo( Lg, 'LG3' ,LG3) + EgtSetInfo( Lg, 'LG4' ,LG4) + EgtSetInfo( Lg, 'LM4' ,LM4) + EgtSetInfo( Lg, 'LM5' ,LM5) + EgtSetInfo( Lg, 'LG6' ,LG6) + EgtSetInfo( Lg, 'LM6' ,LM6) + EgtSetInfo( Lg, 'CH' ,CH) + EgtSetInfo( Lg, 'CLC' ,CLC) + EgtSetInfo( Lg, 'CLC4' ,CLC4) + EgtSetInfo( Lg, 'EAR' ,EAR) + EgtSetInfo( Lg, 'das' ,das) + EgtSetInfo( Lg, 'ASG' ,ASG) + EgtSetInfo( Lg, 'das2' ,das2) + EgtSetInfo( Lg, 'ASGR' ,ASGR) + EgtSetInfo( Lg, 'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return FlushBolt diff --git a/LuaLibs/FlushPull.lua b/LuaLibs/FlushPull.lua new file mode 100644 index 0000000..9a25300 --- /dev/null +++ b/LuaLibs/FlushPull.lua @@ -0,0 +1,1349 @@ +-- +-- 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 +-- +-- FlushPull.lua by EgalWare s.r.l. 2016.07.05 +-- Autore: Filippo Monchi +-- FlushPull dati i valori 'L' e 'H' e con nome attributo + +-- 2016.09.21 V1.0a0 FM aggiunta messaggi di wanrning +-- 2018.04.09 V1.0a1 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.22 V1.0a2 FM Manage better the big radius fillet parameter +-- 2019.04.24 V1.0a3 FM Manage extra bores, extra rectangles, extra lines +-- 2019.04.29 V1.0a4 FM Disable AddSurfTmByExtrusion +-- 2019.05.22 V1.0a5 FM Manage anti-splint path on strike extra rectangle geometry +-- 2019.09.30 V1.0a6 FM Manage anti-splint path on anti-splint path +-- 2019.10.10 V1.0a7 FM Manage steel option +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.28 V2.001 FM Add clean corner geometries +-- 2020.01.07 V2.002 FM Manage start point on shortest side with steel material (also for extra rectangles) +-- 2020.04.29 V2.003 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.03.12 V3.001 FM Check and adjust the angle parameter on ebtra rectangle and extra lines +-- 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 + +-- Tavola per definizione modulo (serve ma non usata) +local FlushPull = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 4. -- valore minimo lato +local dExtraH = 0.25 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nLine = EgtLine(nGroup, pInitial, pFinal, nReference) + 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 , nReference) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , nReference) + 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, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, nReference) + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , nReference) + EgtSetColor( nCircle2, cColor2) + end + end + + return nCircle, nNumCircle, sMVar +end + +local function DrawRectangleWithFillet ( Lg, L, H, dThickD, rf) + + local tHint = {} + local hint + local pIni, pEnd, pCen + + -- Costruzione della geometria principale + pIni = Point3d(((L/2)-rf),(H/2),dThickD) + pCen = Point3d(((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d((L/2),((H/2)-rf),dThickD) + 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 c'è stazio per una linea tra i due raccordi + pEnd = Point3d((L/2),-(H/2)+rf,dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(((L/2)-rf),-(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-((L/2)-rf),-(H/2),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(-(L/2),(-(H/2)+rf),dThickD) + 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 c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-(L/2),((H/2)-rf),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d(-((L/2)-rf),(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è stazio per una linea tra i due raccordi + pEnd = Point3d(((L/2)-rf),(H/2),dThickD) + 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 + EgtInvertCurve( hint) + end + end + + return hint +end + +local function MakeRectWithFillet( Lg, P1, P2, Rf, Ang, bBigLength, est) + + local hint_3 = EgtRectangle2P( Lg, P1, P2, GDB_RT.LOC) + + if hint_3 then + -- with this way to makes rectangle, after explode the fisrt entity is the bottom one, + -- the 2nd is the left one + local nNewId, nNumEnt = EgtExplodeCurveCompo( hint_3) + + if nNewId and nNumEnt and nNumEnt > 0 then + + local pStartIni + + -- se devo inserire i raccordi + if Rf > 0 then + + local tIdFil = {} + local nLine + for p = 1, (nNumEnt-1) do + nLine = EgtCurveFillet( Lg, ( nNewId + p - 1), EgtEP( nNewId + p - 1), ( nNewId + p), EgtSP( nNewId + p), Rf, true) + table.insert( tIdFil, nLine) + end + nLine = EgtCurveFillet( Lg, ( nNewId + nNumEnt - 1), EgtEP( nNewId + nNumEnt - 1), nNewId, EgtSP(nNewId), Rf, true) + table.insert( tIdFil, nLine) + + if est then -- se materiale steel inizio sul lato più corto + if bBigLength then -- se lunghezza maggiore (in X) di altezza (in Y) + pStartIni = EgtMP( nNewId+1) + else -- lunghezza (in X) minore o uguale a altezza (in Y) + pStartIni = EgtMP( nNewId) + end + else -- altrimenti come fatto prima (sulla prima entità) + pStartIni = EgtMP( nNewId) + end + -- creo curvecompo + hint_3 = EgtCurveCompo( Lg, { nNewId, tIdFil[1], (nNewId+1), tIdFil[2], (nNewId+2), tIdFil[3], (nNewId+3), tIdFil[4]}, true) + else + if est then -- se materiale steel inizio sul lato più corto + if bBigLength then -- se lunghezza maggiore (in X) di altezza (in Y) + pStartIni = EgtMP( nNewId+1) + else -- lunghezza (in X) minore o uguale a altezza (in Y) + pStartIni = EgtMP( nNewId) + end + else -- altrimenti come fatto prima (sulla prima entità) + pStartIni = EgtMP( nNewId) + end + -- creo curvecompo + hint_3 = EgtCurveCompo( Lg, { nNewId, (nNewId+1), (nNewId+2), (nNewId+3)}, true) + end + + if hint_3 then + EgtChangeClosedCurveStartPoint( hint_3, pStartIni, GDB_RT.LOC) -- cambio punto di inizio + if Ang ~= 0 then + EgtRotate( hint_3, EgtGP( hint_3), Z_AX(), Ang, GDB_RT.LOC) -- ruoto + end + end + end + end + + return hint_3 +end + +local function MakeAspOnStrikeRect( Lg, nHint, dX, dY, dThick, + dDoorTh, dShiftX, dShiftY, bRefSide, dBack_set, + dDiam, bOpposite, dZedPos, dDiam2, sSideLock, + Fc) + + local nLine + local ptIni, ptEnd, pInt1, pInt1, ptIni2, ptEnd2 + local tPath = {} + local nPath1, nPath2, nPath3, nPath4 + local nInv = 1 + + if not dBack_set then dBack_set = 0 end + + -- creo la linea + ptIni = Point3d( EgtIf( bRefSide, 0, -dBack_set), (dShiftY + max(dX, dY)), dZedPos) + ptEnd = Point3d( EgtIf( bRefSide, 0, -dBack_set), (dShiftY - max(dX, dY)), dZedPos) + nLine = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE()) + + if nLine then + + -- verifico se ci sono intersezioni + pInt1 = EgtIP( nLine, nHint, ptIni) + pInt2 = EgtIP( nLine, nHint, ptEnd) + + -- se ci sono entrambe i punti e la loro distanza è maggiore del diametro fresa + if pInt1 and pInt2 then + + local dDist = dist( pInt1, pInt2) + + if dDist>= dDiam then -- se larghezza maggiore dell'utensile + + -- imposto la griglia + if bOpposite then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + nInv = 1 + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + nInv = -1 + end + + ptIni = Point3d( (pInt1:getY() - (dDiam/2) + dExtraH)*nInv, pInt1:getZ() + (dDiam*3/4), -pInt1:getX()) + if dDiam2 then + ptIni2 = Point3d( (pInt1:getY() - (dDiam2/2) + dExtraH)*nInv, pInt1:getZ() + (dDiam2*3/4), -pInt1:getX()) + end + + if dDoorTh - dThick > GEO.EPS_SMALL then -- se spessore non passante + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), pInt1:getZ() - dThick + (dDiam/2) - dExtraH, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getY() + (dDiam/2) - dExtraH)*nInv, ptIni:getY(), -pInt2:getX()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), pInt2:getZ() + (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), pInt1:getZ() - dThick + (dDiam2/2) - dExtraH, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getY() + (dDiam2/2) - dExtraH)*nInv, ptIni2:getY(), -pInt2:getX()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), pInt2:getZ() + (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- se spessore passante + + if (dDist - dDiam) < 2*dDiam then -- se larghezza minore del doppio diametro utensile + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), pInt1:getZ() - dThick - (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getY() + (dDiam/2) - dExtraH)*nInv, ptIni:getY(), -pInt2:getX()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), pInt2:getZ() + (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), pInt1:getZ() - dThick - (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getY() + (dDiam2/2) - dExtraH)*nInv, ptIni2:getY(), -pInt2:getX()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), pInt2:getZ() + (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- larghezza maggiore del doppio diametro, creo due linee distinte + + -- creo 2 persorsi composti da una linea ciascuno + ptEnd = Point3d( ptIni:getX(), pInt1:getZ() - dThick - (dDiam*3/4), ptIni:getZ()) + nPath1 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni = Point3d( (pInt2:getY() + (dDiam/2) - dExtraH)*nInv, ptEnd:getY(), -pInt2:getX()) + ptEnd = Point3d( ptIni:getX(), pInt2:getZ() + (dDiam*3/4), ptIni:getZ()) + nPath2 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + if dDiam2 then + -- creo 2 persorsi composti da una linea ciascuno + ptEnd2 = Point3d( ptIni2:getX(), pInt1:getZ() - dThick - (dDiam2*3/4), ptIni2:getZ()) + nPath3 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni2 = Point3d( (pInt2:getY() + (dDiam2/2) - dExtraH)*nInv, ptEnd2:getY(), -pInt2:getX()) + ptEnd2 = Point3d( ptIni2:getX(), pInt2:getZ() + (dDiam2*3/4), ptIni2:getZ()) + nPath4 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + end + end + end + end + --debug +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- se esistono gli eventuali percorso setto spessore 0 + if nPath1 then + EgtModifyCurveThickness(nPath1, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + end + if nPath2 then + EgtModifyCurveThickness(nPath2, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + end + if nPath3 then + EgtModifyCurveThickness(nPath3, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + end + if nPath4 then + EgtModifyCurveThickness(nPath4, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + end + + -- re-imposto la griglia da sopra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + -- elimino la linea + EgtErase(nLine) + end + + return nPath1, nPath2, nPath3, nPath4 +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function FlushPull.AdjustParams( tMhPar) + + -- per antisplint su extra-rettangolo + local dMaxMat0 + local dMaxMat8 + local dMaxMat9 + local nTempT0 + local nTempT8 + local nTempT9 + local sMchngName0 + local sMchngName8 + local sMchngName9 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + + -- se non ho il parametro chiseling lo setto disabilitato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se chisel abilitato ma non c'è la variabile suffisso + if tMhPar.ech and not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se porta steel o aluminum + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.ASG = 0 + tMhPar.EAR = nil + tMhPar.das = nil + else + tMhPar.est = nil + end + + -- setto parametri da ddf + if DGD.DEPTH then + tMhPar.T = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + + if DGD.FACE then + tMhPar.Fc = DGD.FACE + else + if DGD.Push then -- se porta a spingere la geometria va dietro + tMhPar.Fc = 'secure' + else -- altrimenti + tMhPar.Fc = 'keyway' + end + end + + if not tMhPar.rf then + tMhPar.rf = 0 + end + + if tMhPar.T == -0.5 then + tMhPar.T = DGD.dT / 2 + elseif tMhPar.T == -1 then + tMhPar.T = DGD.dT + end + + -- 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.CL = nil + else -- se non è definito o già nullo lo azzero + tMhPar.rf = 0 + end + + -- passo lo spessore porta + tMhPar.DT = DGD.dT + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLG + local nLGi = 1 + local sASG -- anti-splint on extra rectangle + local nASGi = 1 + local sASGR -- anti-splint on antisplint + local nASGRi = 1 + +-- disabilito perché nel flushpull non è gestito il diametro utensile .d perché non viene creato nessun percorso di lavorazione +-- 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.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + -- extra bores + if tMhPar.T10 then + if tMhPar.RTB10 and DGD.DEPTH then + tMhPar.T10 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T10 == -0.5 then + tMhPar.T10 = DGD.dT / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > DGD.dT then + tMhPar.T10 = DGD.dT + end + end + + if tMhPar.T11 then + if tMhPar.RTB11 and DGD.DEPTH then + tMhPar.T11 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T11 == -0.5 then + tMhPar.T11 = DGD.dT / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > DGD.dT then + tMhPar.T11 = DGD.dT + end + end + + if tMhPar.T12 then + if tMhPar.RTB12 and DGD.DEPTH then + tMhPar.T12 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T12 == -0.5 then + tMhPar.T12 = DGD.dT / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > DGD.dT then + tMhPar.T12 = DGD.dT + end + end + + if tMhPar.T13 then + if tMhPar.RTB13 and DGD.DEPTH then + tMhPar.T13 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T13 == -0.5 then + tMhPar.T13 = DGD.dT / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > DGD.dT then + tMhPar.T13 = DGD.dT + end + end + + if tMhPar.T14 then + if tMhPar.RTB14 and DGD.DEPTH then + tMhPar.T14 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T14 == -0.5 then + tMhPar.T14 = DGD.dT / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > DGD.dT then + tMhPar.T14 = DGD.dT + end + end + + if tMhPar.T15 then + if tMhPar.RTB15 and DGD.DEPTH then + tMhPar.T15 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T15 == -0.5 then + tMhPar.T15 = DGD.dT / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > DGD.dT then + tMhPar.T15 = DGD.dT + end + end + + if tMhPar.T16 then + if tMhPar.RTB16 and DGD.DEPTH then + tMhPar.T16 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T16 == -0.5 then + tMhPar.T16 = DGD.dT / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > DGD.dT then + tMhPar.T16 = DGD.dT + end + end + + if tMhPar.T17 then + if tMhPar.RTB17 and DGD.DEPTH then + tMhPar.T17 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T17 == -0.5 then + tMhPar.T17 = DGD.dT / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > DGD.dT then + tMhPar.T17 = DGD.dT + end + end + + if tMhPar.T18 then + if tMhPar.RTB18 and DGD.DEPTH then + tMhPar.T18 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T18 == -0.5 then + tMhPar.T18 = DGD.dT / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > DGD.dT then + tMhPar.T18 = DGD.dT + end + end + + if tMhPar.T19 then + if tMhPar.RTB19 and DGD.DEPTH then + tMhPar.T19 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.T19 == -0.5 then + tMhPar.T19 = DGD.dT / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > DGD.dT then + tMhPar.T19 = DGD.dT + end + end + + -- extra rectangles + if tMhPar.TR10 then + if tMhPar.RTR10 and DGD.DEPTH then + tMhPar.TR10 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TR10 == -0.5 then + tMhPar.TR10 = DGD.dT / 2 + elseif tMhPar.TR10 == -1 or tMhPar.TR10 > DGD.dT then + tMhPar.TR10 = DGD.dT + end + end + + if tMhPar.TR11 then + if tMhPar.RTR11 and DGD.DEPTH then + tMhPar.TR11 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TR11 == -0.5 then + tMhPar.TR11 = DGD.dT / 2 + elseif tMhPar.TR11 == -1 or tMhPar.TR11 > DGD.dT then + tMhPar.TR11 = DGD.dT + end + end + + if tMhPar.TR12 then + if tMhPar.RTR12 and DGD.DEPTH then + tMhPar.TR12 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TR12 == -0.5 then + tMhPar.TR12 = DGD.dT / 2 + elseif tMhPar.TR12 == -1 or tMhPar.TR12 > DGD.dT then + tMhPar.TR12 = DGD.dT + end + end + + if tMhPar.TR13 then + if tMhPar.RTR13 and DGD.DEPTH then + tMhPar.TR13 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TR13 == -0.5 then + tMhPar.TR13 = DGD.dT / 2 + elseif tMhPar.TR13 == -1 or tMhPar.TR13 > DGD.dT then + tMhPar.TR13 = DGD.dT + end + end + + if tMhPar.TR14 then + if tMhPar.RTR14 and DGD.DEPTH then + tMhPar.TR14 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TR14 == -0.5 then + tMhPar.TR14 = DGD.dT / 2 + elseif tMhPar.TR14 == -1 or tMhPar.TR14 > DGD.dT then + tMhPar.TR14 = DGD.dT + end + end + + -- Anti-splint su rettangoli + if DGD.MachEn > 0 and tMhPar.ASG and tMhPar.EAR and + ( ( tMhPar.TR10 and tMhPar.TR10 > GEO.EPS_SMALL) or ( tMhPar.TR11 and tMhPar.TR11 > GEO.EPS_SMALL) or ( tMhPar.TR12 and tMhPar.TR12 > GEO.EPS_SMALL) or + ( tMhPar.TR13 and tMhPar.TR13 > GEO.EPS_SMALL) or ( tMhPar.TR14 and tMhPar.TR14 > GEO.EPS_SMALL)) then + sASG = tMhPar.ASG + nTempT8, dMaxMat8, sMchngName8 = MB.GetToolDataFromAttrib( sASG, nASGi) + tMhPar.SL = DGD.Lock + end + + -- Anti-splint su Anti-splint + if DGD.MachEn > 0 and tMhPar.EAR and tMhPar.EAR == 2 and sASG then + sASGR = tMhPar.ASG..'_R' + tMhPar.ASGR = sASGR + tMhPar.das2 = tMhPar.das + nTempT9, dMaxMat9, sMchngName9 = MB.GetToolDataFromAttrib( sASGR, nASGRi) + end + + -- extra lines + if tMhPar.TL10 then + if tMhPar.RTL10 and DGD.DEPTH then + tMhPar.TL10 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TL10 == -0.5 then + tMhPar.TL10 = DGD.dT / 2 + elseif tMhPar.TL10 == -1 or tMhPar.TL10 > DGD.dT then + tMhPar.TL10 = DGD.dT + end + end + + if tMhPar.TL11 then + if tMhPar.RTL11 and DGD.DEPTH then + tMhPar.TL11 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TL11 == -0.5 then + tMhPar.TL11 = DGD.dT / 2 + elseif tMhPar.TL11 == -1 or tMhPar.TL11 > DGD.dT then + tMhPar.TL11 = DGD.dT + end + end + + if tMhPar.TL12 then + if tMhPar.RTL12 and DGD.DEPTH then + tMhPar.TL12 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TL12 == -0.5 then + tMhPar.TL12 = DGD.dT / 2 + elseif tMhPar.TL12 == -1 or tMhPar.TL12 > DGD.dT then + tMhPar.TL12 = DGD.dT + end + end + + if tMhPar.TL13 then + if tMhPar.RTL13 and DGD.DEPTH then + tMhPar.TL13 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TL13 == -0.5 then + tMhPar.TL13 = DGD.dT / 2 + elseif tMhPar.TL13 == -1 or tMhPar.TL13 > DGD.dT then + tMhPar.TL13 = DGD.dT + end + end + + if tMhPar.TL14 then + if tMhPar.RTL14 and DGD.DEPTH then + tMhPar.TL14 = EgtIf( DGD.DEPTH > DGD.dT, DGD.dT, DGD.DEPTH) + end + if tMhPar.TL14 == -0.5 then + tMhPar.TL14 = DGD.dT / 2 + elseif tMhPar.TL14 == -1 or tMhPar.TL14 > DGD.dT then + tMhPar.TL14 = DGD.dT + end + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- Raggio: se raggio presente e altro materiale e se raggio minore del diametro utensile + delta, lo annullo +-- if tMhPar.rf and tMhPar.est and ( tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02)) then +-- tMhPar.rf = 0 +-- end + + -- gestisco il risultato della lettura utensili per antischeggia su extra rettangoli + if DGD.bProoduce and not tMhPar.est and tMhPar.das and nTempT8 and nTempT8 <= 0 then + dNumLog = -1594 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT8, sASG, nASGi, tMhPar.das, dNumLog, sMchngName8) + elseif not tMhPar.est and nTempT8 then + tMhPar.das = nTempT8 + end + + -- gestisco il risultato della lettura utensili per antischeggia su antischeggia + if DGD.bProoduce and not tMhPar.est and tMhPar.das2 and nTempT9 and nTempT9 <= 0 then + dNumLog = -1594 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT9, sASGR, nASGRi, tMhPar.das2, dNumLog, sMchngName9) + elseif not tMhPar.est and nTempT9 then + tMhPar.das2 = nTempT9 + end + + if tMhPar.CL and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.W or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CL then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function FlushPull.Draw( tFlushPPar, bPreview, bRunByCompo, nDrawMach, dThickD) + + -- Assegno le dimensioni + local L = tFlushPPar.L + local W = tFlushPPar.W + local T = tFlushPPar.T + local R = tFlushPPar.R + local rf = tFlushPPar.rf + local clc = tFlushPPar.clc + local ccr = tFlushPPar.ccr + local ech = tFlushPPar.ech + local est = tFlushPPar.est + local kbs = tFlushPPar.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tFlushPPar.pbs + local DT = tFlushPPar.DT + local SL = tFlushPPar.SL + local Fc = tFlushPPar.Fc + + -- Assegno i nomi + local LG = tFlushPPar.LG + local LM = tFlushPPar.LM + local CH = tFlushPPar.CH -- suffisso lavorazione chisel + local CL = tFlushPPar.CL + -- Anti-splint su extra rectangle geometry + local EAR = tFlushPPar.EAR + local das = tFlushPPar.das + local ASG = tFlushPPar.ASG + -- Second anti-splint on extra rectangle geometry + local das2 = tFlushPPar.das2 + local ASGR = tFlushPPar.ASGR + + -- tabelle per i fori, rettangoli e linee opzionali + local tExtraBore = {} + local tExtraRect = {} + local tExtraLine = {} + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tFlushPPar.D10, tFlushPPar.T10, tFlushPPar.PX10, tFlushPPar.PY10, tFlushPPar.EB10, tFlushPPar.RBS10}) + table.insert( tExtraBore, { tFlushPPar.D11, tFlushPPar.T11, tFlushPPar.PX11, tFlushPPar.PY11, tFlushPPar.EB11, tFlushPPar.RBS11}) + table.insert( tExtraBore, { tFlushPPar.D12, tFlushPPar.T12, tFlushPPar.PX12, tFlushPPar.PY12, tFlushPPar.EB12, tFlushPPar.RBS12}) + table.insert( tExtraBore, { tFlushPPar.D13, tFlushPPar.T13, tFlushPPar.PX13, tFlushPPar.PY13, tFlushPPar.EB13, tFlushPPar.RBS13}) + table.insert( tExtraBore, { tFlushPPar.D14, tFlushPPar.T14, tFlushPPar.PX14, tFlushPPar.PY14, tFlushPPar.EB14, tFlushPPar.RBS14}) + table.insert( tExtraBore, { tFlushPPar.D15, tFlushPPar.T15, tFlushPPar.PX15, tFlushPPar.PY15, tFlushPPar.EB15, tFlushPPar.RBS15}) + table.insert( tExtraBore, { tFlushPPar.D16, tFlushPPar.T16, tFlushPPar.PX16, tFlushPPar.PY16, tFlushPPar.EB16, tFlushPPar.RBS16}) + table.insert( tExtraBore, { tFlushPPar.D17, tFlushPPar.T17, tFlushPPar.PX17, tFlushPPar.PY17, tFlushPPar.EB17, tFlushPPar.RBS17}) + table.insert( tExtraBore, { tFlushPPar.D18, tFlushPPar.T18, tFlushPPar.PX18, tFlushPPar.PY18, tFlushPPar.EB18, tFlushPPar.RBS18}) + table.insert( tExtraBore, { tFlushPPar.D19, tFlushPPar.T19, tFlushPPar.PX19, tFlushPPar.PY19, tFlushPPar.EB19, tFlushPPar.RBS19}) + -- inserimento dati nella tabella rettangoli; sono invertite lunghezza e larghezza perché nel flush_pull sono interpretate al contrario + table.insert( tExtraRect, { tFlushPPar.WR10, tFlushPPar.LR10, tFlushPPar.RR10, tFlushPPar.CH10, tFlushPPar.TR10, + tFlushPPar.PRX10, tFlushPPar.PRY10, tFlushPPar.AR10, tFlushPPar.ER10, tFlushPPar.RRS10}) + table.insert( tExtraRect, { tFlushPPar.WR11, tFlushPPar.LR11, tFlushPPar.RR11, tFlushPPar.CH11, tFlushPPar.TR11, + tFlushPPar.PRX11, tFlushPPar.PRY11, tFlushPPar.AR11, tFlushPPar.ER11, tFlushPPar.RRS11}) + table.insert( tExtraRect, { tFlushPPar.WR12, tFlushPPar.LR12, tFlushPPar.RR12, tFlushPPar.CH12, tFlushPPar.TR12, + tFlushPPar.PRX12, tFlushPPar.PRY12, tFlushPPar.AR12, tFlushPPar.ER12, tFlushPPar.RRS12}) + table.insert( tExtraRect, { tFlushPPar.WR13, tFlushPPar.LR13, tFlushPPar.RR13, tFlushPPar.CH13, tFlushPPar.TR13, + tFlushPPar.PRX13, tFlushPPar.PRY13, tFlushPPar.AR13, tFlushPPar.ER13, tFlushPPar.RRS13}) + table.insert( tExtraRect, { tFlushPPar.WR14, tFlushPPar.LR14, tFlushPPar.RR14, tFlushPPar.CH14, tFlushPPar.TR14, + tFlushPPar.PRX14, tFlushPPar.PRY14, tFlushPPar.AR14, tFlushPPar.ER14, tFlushPPar.RRS14}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tFlushPPar.LL10, tFlushPPar.TL10, tFlushPPar.PLX10, tFlushPPar.PLY10, tFlushPPar.AL10, tFlushPPar.EL10, tFlushPPar.RLS10}) + table.insert( tExtraLine, { tFlushPPar.LL11, tFlushPPar.TL11, tFlushPPar.PLX11, tFlushPPar.PLY11, tFlushPPar.AL11, tFlushPPar.EL11, tFlushPPar.RLS11}) + table.insert( tExtraLine, { tFlushPPar.LL12, tFlushPPar.TL12, tFlushPPar.PLX12, tFlushPPar.PLY12, tFlushPPar.AL12, tFlushPPar.EL12, tFlushPPar.RLS12}) + table.insert( tExtraLine, { tFlushPPar.LL13, tFlushPPar.TL13, tFlushPPar.PLX13, tFlushPPar.PLY13, tFlushPPar.AL13, tFlushPPar.EL13, tFlushPPar.RLS13}) + table.insert( tExtraLine, { tFlushPPar.LL14, tFlushPPar.TL14, tFlushPPar.PLX14, tFlushPPar.PLY14, tFlushPPar.AL14, tFlushPPar.EL14, tFlushPPar.RLS14}) + + -- variabili per messaggi e settaggi vari + local sCompoName = tFlushPPar.Nome + local nCompoNpar = tFlushPPar.Npar + local sCompoPath = tFlushPPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tFlushPPar.nCod + local sCodAdj = tFlushPPar.sCod + -- variabili per messaggi di errore + local sNamePar1 = tFlushPPar.N1 or 'L' + local sNamePar2 = tFlushPPar.N2 or 'W' + local sNamePar3 = tFlushPPar.N3 or 'T' + local sNamePar4 = tFlushPPar.N4 or 'Radius' + local sNamePar5 = tFlushPPar.N5 or 'rf' + local sNamePar6 = tFlushPPar.N6 or 'clc' + local sNamePar7 = tFlushPPar.N7 or 'ccr' + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1500 + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if L and W and rf then + if 2*rf > min(L,W) then + rf = min(L,W)/2 + end + end + + -- 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 + + if not ASGR then + das2 = nil + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if L and L < DimMin then + EC = 1 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'L' deve essere > DimMin + L = DimMin + elseif W and W < DimMin then + EC = 2 + EM = string.format(EgtDoorsMsg[407],sNamePar2,EgtToUiUnits(W),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'H' deve essere > DimMin + W = DimMin + elseif R and R < DimMin then + EC = 3 + EM = string.format(EgtDoorsMsg[407],sNamePar4,EgtToUiUnits(R),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'D' deve essere > DimMin + R = DimMin + elseif CL and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 4 + EM = string.format(EgtDoorsMsg[407],sNamePar6,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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + local GId, MId + local bSingleMode = true + + if nForceMakeFace ~= 1 then -- se abilitata geometria esterna + -- Costruzione della geometria + if L and W then + if rf > 0 then + GId = DrawRectangleWithFillet ( Lg, W, L, dThickD, rf) + else + GId = EgtRectangle2P( Lg, Point3d( -(W/2), -(L/2), dThickD), Point3d( (W/2), (L/2), dThickD), GDB_RT.GLOB) + -- se ci sono i parametri per i percorsi cleancorner + if CL and clc and clc > 0 and clc < W and clc < L then + -- angolo x-y+ + local CLC1 = MakeClcPath( clc, ccr, CL, Lg, -T) + EgtMove( CLC1, Point3d(-(W/2),(L/2),dThickD) - ORIG()) + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 0 and T < DT then + EgtSetInfo( CLC1, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 0 and T < DT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + -- angolo x+y+ + CLC2 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC2, Point3d((W/2),-(L/2),0) - ORIG()) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((W/2),(L/2),0) - ORIG()) + -- angolo x+y- + CLC3 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC3, Point3d((W/2),-(L/2),0) - ORIG()) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((W/2),-(L/2),0) - ORIG()) + -- angolo x-y- + CLC4 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC4, Point3d((W/2),-(L/2),0) - ORIG()) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(W/2),-(L/2),0) - ORIG()) + end + end + elseif R then + GId = EgtCircle( Lg, Point3d( 0, 0, dThickD), R , GDB_RT.GLOB) + end + + if GId then + EgtModifyCurveThickness( GId, -T) + EgtInvertCurve( GId) + EgtSetName( GId, LG) + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 0 and T < DT then + EgtSetInfo( GId, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 0 and T < DT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( GId, 'ProbeSide', '1') + end + end + -- creo estrusi e superfici piane delle geometrie passanti +-- AddSurfTmByExtrusion( Lg, GId, bSingleMode) + + local mis10 + local AP10 + local TA10 + local ss10 + local SLD10 + local hint_3, hint_4, hint_5, hint_6, hint_7 + + -- Extra bores + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_3 = EgtCircle( Lg, Point3d(PX10,PY10,dThickD), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness(hint_3, -T10) + EgtSetName(hint_3,EB10) + EgtSetInfo(hint_3,'ReferHw',RBS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + end + end + + -- Extra rectangles + for k = 1, 5 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local CH10 = tExtraRect[k][4] + local TR10 = tExtraRect[k][5] + local PRX10 = tExtraRect[k][6] or 0 + local PRY10 = tExtraRect[k][7] or 0 + local AR10 = tExtraRect[k][8] + local ER10 = tExtraRect[k][9] + local RRS10 = tExtraRect[k][10] + + -- se parametri esistenti e dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + -- se ho il chisel abilitato ma il fillet è presente non lo applico + if CH10 then + if abs(RR10) < GEO.EPS_SMALL then -- se il raccordo non è presente applico il chisel + ER10 = ER10 .. '_Chisel' + end + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_3 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(PRY10-(WR10/2)),dThickD), Point3d((PRX10+(LR10/2)),(PRY10+(WR10/2)),dThickD), RR10, AR10, (LR10 > WR10), est) + EgtModifyCurveThickness(hint_3, -TR10) + EgtSetName(hint_3,ER10) + EgtSetInfo(hint_3,'ReferHw',RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and EAR and (( das and das > 0) or ( das2 and das2 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_4, hint_5, hint_6, hint_7 = MakeAspOnStrikeRect( Lg, hint_3, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, DGD.BACK_SET, + das, nil, dThickD, das2, SL, + Fc) + + if hint_4 then + EgtSetName(hint_4, ASG) + if string.lower(Fc) == 'secure' then + EgtSetInfo(hint_4, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + else + EgtSetInfo(hint_4, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + EgtSetInfo(hint_4, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + if hint_5 then + EgtSetName(hint_5, ASG) + if string.lower(Fc) == 'secure' then + EgtSetInfo(hint_5, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + else + EgtSetInfo(hint_5, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + EgtSetInfo(hint_5, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + if hint_6 then + EgtSetName(hint_6, ASGR) + if string.lower(Fc) == 'secure' then + EgtSetInfo(hint_6, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + else + EgtSetInfo(hint_6, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + EgtSetInfo(hint_6, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + if hint_7 then + EgtSetName(hint_7, ASGR) + if string.lower(Fc) == 'secure' then + EgtSetInfo(hint_7, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + else + EgtSetInfo(hint_7, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + EgtSetInfo(hint_7, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + end + end + + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 0 and TR10 < DT then + EgtSetInfo( hint_3, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 0 and TR10 < DT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_3, 'ProbeSide', '1') + end + end + end + end + + -- Extra lines + for k = 1, 5 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_3 = EgtLinePDL( Lg, Point3d( PLX10,PLY10,dThickD), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness(hint_3, -TL10) + EgtSetName(hint_3,EL10) + EgtSetInfo(hint_3,'ReferHw',RLS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 0 and TL10 < DT then + EgtSetInfo( hint_3, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 0 and TL10 < DT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_3, 'ProbeSide', '1') + end + end + end + end + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + -- Costruzione della geometria + if L and W then + if rf > 0 then + MId = DrawRectangleWithFillet ( Lg, W, L, dThickD, rf) + else + MId = EgtRectangle2P( Lg, Point3d( -(W/2), -(L/2), dThickD), Point3d((W/2), (L/2), dThickD), GDB_RT.GLOB) + end + if est then -- se materiale steel inizio sempre sul lato corto + if W > L then + EgtChangeClosedCurveStartPoint( MId, Point3d( -(W/2), 0, dThickD), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, -(L/2), dThickD), GDB_RT.GLOB) + end + else + EgtChangeClosedCurveStartPoint( MId, Point3d( -(W/2), 0, dThickD), GDB_RT.GLOB) + end + elseif R then + MId = EgtCircle( Lg, Point3d( 0, 0, dThickD), R , GDB_RT.GLOB) + end + + if MId then + EgtModifyCurveThickness( MId, -T) + EgtInvertCurve( MId) + EgtSetName( MId, LM) + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 0 and T < DT then + EgtSetInfo( MId, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 0 and T < DT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( MId, 'ProbeSide', '1') + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if GId then + EgtSetColor( GId or GDB_ID.NULL, AQUA()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, AQUA()) + end + else + if GId then + EgtSetColor( GId or GDB_ID.NULL, ORANGE()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, ORANGE()) + end + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'FlushPull') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'R' ,R) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'clc' ,clc) + EgtSetInfo(Lg,'ccr' ,ccr) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'DT' ,DT) + EgtSetInfo(Lg,'SL' ,SL) + EgtSetInfo(Lg,'Fc' ,Fc) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'CL' ,CL) + EgtSetInfo(Lg,'EAR' ,EAR) + EgtSetInfo(Lg,'das' ,das) + EgtSetInfo(Lg,'ASG' ,ASG) + EgtSetInfo(Lg,'das2' ,das2) + EgtSetInfo(Lg,'ASGR' ,ASGR) + 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 FlushPull diff --git a/LuaLibs/Groove.lua b/LuaLibs/Groove.lua new file mode 100644 index 0000000..95c1bbd --- /dev/null +++ b/LuaLibs/Groove.lua @@ -0,0 +1,1904 @@ +-- +-- 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 +-- +-- Groove.lua by EgalWare s.r.l. 2017.10.13 +-- Autore: Filippo Monchi +-- Groove dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e con nomi attributi + +-- 2016.09.21 V1.011 FM aggiunta messaggi di wanrning +-- 2017.12.18 V1.011 FM Gestito uso una sola lama +-- 2017.12.19 V1.012 FM Gestito uso lama anche su groove non passante con percorsi pulitura +-- 2018.04.06 V1.018 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.05.18 V1.019 FM Manage groove on narroow side +-- 2018.05.23 V1.01a FM Manage groove for all 4 sides +-- 2018.07.18 V1.01b FM Manage groove for new ddf parameters (DGD.FST, DGD.HST, DGD.LST) +-- 2018.10.17 V1.01c FM Add parameter to show into message 402 +-- 2019.04.05 V1.01d FM Manage new version that not modify the blade path name by different lead-in and lead-out +-- but assign notes to a path +-- 2019.04.16 V1.01e FM Manage insert mill anti-splint path also on blade cuts +-- 2019.04.16 V1.01e FM Fix problem on mill anti-splint paths when distance on middle line is 0: Add dMinDist set to 0.0015mm parameter +-- 2019.04.29 V1.01f FM Manage max depth by blade parameter .MaxBd +-- 2019.05.14 V1.020 FM Manage antisplint path on Hinge side and opposite side (when they use different tool diameters) +-- 2019.10.18 V1.021 FM Manage steel option (disable to generate anti-splint paths) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.04.29 V2.001 FM Update for aluminum material +-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.04.07 V2.003 FM Manage side step by blade parameter .StpBd +-- 2022.07.27 V2.004 FM Modification to use compiled code +-- 2022.08.31 V2.004 FM Manage groove applied on door with top angle +-- 2022.09.07 V2.005 FM Fix error on assigne a nil value by EgtIf intruction +-- 2024.10.17 V2.006 FM Improve multiple blade step (on Z dir) when wide groobe is bigger than double blade thickness +-- 2024.10.30 V2.007 FM Manage a new .alw parameter to allow width door bigger than door thickness and +-- when blade is enables, get the mill max thickness as blade thickness in case mill is used instead blade +-- 2025.01.20 V2.008 FM Manage a new .slb parameter to set to force use 1 blade for machining LH side +-- Tavola per definizione modulo (serve ma non usata) +local Groove = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local dExtraH = 0.25 +local DgMin = 3. -- valore minimo diametro utensile +local PtMin = 0.1 +local PtMax = 1.0 + +-- valore globale di settaggio +local nNewLeadInOutMode = true + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + + if idTable then + table.insert( idTable, nLine) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumLine = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function Groove.AdjustParams( tMhPar) + + tMhPar.invG = 1 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dMaxMat4 + local dMaxMat5 + local dMaxMat6 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local nTempT5 + local nTempT6 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local sMchngName5 + local sMchngName6 + local nThBl0 + local nThBl1 + local nThBl2 + local nThBl3 + local nThBl4 + local nThBl5 + local nThBl6 + + -- Assegno parametri da ddf + if DGD.WIDTH then + tMhPar.H = DGD.WIDTH + end + + if DGD.DEPTH then + tMhPar.T = DGD.DEPTH + tMhPar.T3 = DGD.DEPTH + end + + -- do errore se altezza cava maggiore o uguale dello spessore porta + if ( not tMhPar.alw or tMhPar.alw == 0 ) and ( tMhPar.H - DGD.dT) >= GEO.EPS_SMALL then + return tMhPar, 2499, string.format(EgtDoorsMsg[540], tMhPar.Nome, tMhPar.H, DGD.dT, tMhPar.Path) + end + + -- disattivo il radius face + tMhPar.rf = 0 + + -- se attivato groove che sborda dal lato narrow forzo alcune caratteristiche + if tMhPar.grs then + tMhPar.bl = false -- disattivo lama + tMhPar.LCC = nil -- disattivo pulitura spigoli + DGD.GRS = true + else + DGD.GRS = false + end + + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if DGD.Push then tMhPar.invG = -tMhPar.invG end + + -- disattivo la lama se la cava è più grande di una certa quota + if tMhPar.MaxBl and tMhPar.H and tMhPar.H > tMhPar.MaxBl then + tMhPar.bl = false + end + + -- disattivo la lama se la cava è più profonda di una certa quota + if tMhPar.MaxBd and tMhPar.T and tMhPar.T > tMhPar.MaxBd then + tMhPar.bl = false + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + if DGD.SIDE == 'hinge' or DGD.SIDE == 'lock' then -- se groove sui fianchi + -- se è di tipo side la trasformo in center + if DGD.TYPE == 'side' then + DGD.TYPE = 'center' + end + end + + if DGD.TYPE == 'center' then + tMhPar.L = DGD.LENGTH - ( 2 * tMhPar.Red) + if not tMhPar.fbagt then + tMhPar.bl = false -- disattivo la lama in caso lo fosse + end + -- se ho specificato gli spessori degli styles + if DGD.HST and DGD.LST then + if ( DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat' or DGD.SIDE == 'bottom') then -- se groove disposto sui lati top o bottom + -- considerando che la porta di base è RH, D_X è positivo se lo spessore style lato lock > style lato hinge + tMhPar.D_X = (DGD.LST - DGD.HST)/2 + else -- altrimenti se groove disposta su lato lock calcolo il D_X per portarsi in centro + tMhPar.D_X = 0 + end + end + elseif DGD.TYPE == 'side' then + tMhPar.L = DGD.LENGTH - tMhPar.Red + if not tMhPar.fbagt then + tMhPar.bl = false -- disattivo la lama in caso lo fosse + end + else -- thru + tMhPar.L = DGD.LENGTH + tMhPar.ech = false -- disattivo chisel se groove passante + tMhPar.LCC = nil -- disattivo pulitura spigoli + end + + -- in caso il lato sia top o bottom e ci sia il delta controllo se la cava sborda sulla larghezza + if tMhPar.D_X then + if ( DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat' or DGD.SIDE == 'bottom') and ( (2*abs(tMhPar.D_X)) + tMhPar.L) >= DGD.SIDELENGTH then + return tMhPar, 2492, string.format(EgtDoorsMsg[634], tMhPar.Nome, tMhPar.Path) + end + end + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s or abs(tMhPar.s) < GEO.EPS_SMALL then + tMhPar.s = tMhPar.T + end + + -- se porta steel o aluminum disabilito la svuotatura, la mortasa e i fori e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LA = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + else + tMhPar.est = nil + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLAH + local nLAHi = 1 + local sLAL + local nLALi = 1 + local sLBM + local nLBMi = 1 + local sLG + local nLGi = 1 + local sLCC + local nLCCi = 1 + + if tMhPar.LM then -- geometria groove + sLM = tMhPar.LM + end + if tMhPar.LA then -- geometria antischeggia groove + sLA = tMhPar.LA + end + if tMhPar.LA then -- geometria antischeggia groove lato hinge + if DGD.SIDE == 'lock' or DGD.SIDE == 'hinge' then -- se lati lunghi + sLAH = tMhPar.LA + else + sLAH = tMhPar.LA .. '_HNG' + if DGD.SDF and DGD.SDF > 1 then + sLAL = tMhPar.LA .. '_LK' + tMhPar.d6 = tMhPar.d2 + tMhPar.T6 = tMhPar.T2 + end + end + tMhPar.d5 = tMhPar.d2 + tMhPar.T5 = tMhPar.T2 + end + if tMhPar.LBM then -- geometria groove con lama + sLBM = tMhPar.LBM + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LCC then -- geometria pulizia spigoli + sLCC = tMhPar.LCC + end + + if DGD.MachEn > 0 and sLM and tMhPar.d and not tMhPar.bl then + nTempT1, dMaxMat1, sMchngName1, nThBl1 = MB.GetToolDataFromAttrib( sLM, nLMi) + end + if DGD.MachEn > 0 and sLA and tMhPar.d2 and not ( tMhPar.bl and not tMhPar.uab) and DGD.TYPE ~= 'center' then + nTempT2, dMaxMat2, sMchngName2, nThBl2 = MB.GetToolDataFromAttrib( sLA, nLAi) + end + if DGD.MachEn > 0 and sLBM and tMhPar.d3 and tMhPar.bl then + nTempT3, dMaxMat3, sMchngName3, nThBl3 = MB.GetToolDataFromAttrib( sLBM, nLBMi, nil, true) + end + if DGD.MachEn > 0 and sLCC and tMhPar.d4 and tMhPar.bl and DGD.TYPE ~= 'thru' then + nTempT4, dMaxMat4, sMchngName4, nThBl4 = MB.GetToolDataFromAttrib( sLCC, nLCCi) + end + if DGD.MachEn > 0 and sLAH and tMhPar.d5 and not ( tMhPar.bl and not tMhPar.uab) and DGD.TYPE ~= 'center' then + nTempT5, dMaxMat5, sMchngName5, nThBl5 = MB.GetToolDataFromAttrib( sLAH, nLAHi) + end + if DGD.MachEn > 0 and sLAL and tMhPar.d6 and not ( tMhPar.bl and not tMhPar.uab) and DGD.TYPE ~= 'center' then + nTempT6, dMaxMat6, sMchngName6, nThBl6 = MB.GetToolDataFromAttrib( sLAL, nLALi) + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- gestisco il risultato della lettura utensili + if tMhPar.d and nTempT1 and nTempT1 <= 0 then -- utensile fresatura + if DGD.bProoduce and not tMhPar.bl then + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + end + elseif nTempT1 then + tMhPar.d = nTempT1 + end + + if tMhPar.d2 and nTempT2 and nTempT2 <= 0 then -- utensile antischeggia + if DGD.bProoduce and not tMhPar.bl and DGD.TYPE ~= 'center' then + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + end + elseif nTempT2 then + tMhPar.d2 = nTempT2 + end + + if tMhPar.d5 and nTempT5 and nTempT5 <= 0 then -- utensile antischeggia lato hinge + if DGD.bProoduce and not tMhPar.bl and DGD.TYPE ~= 'center' then + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT5, sLAH, nLAHi, tMhPar.d5, dNumLog, sMchngName5) + end + elseif nTempT5 then + tMhPar.d5 = nTempT5 + end + + if tMhPar.d6 and nTempT6 and nTempT6 <= 0 then -- utensile antischeggia lato lock + if DGD.bProoduce and not tMhPar.bl and DGD.TYPE ~= 'center' then + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT6, sLAL, nLALi, tMhPar.d6, dNumLog, sMchngName6) + end + elseif nTempT6 then + tMhPar.d6 = nTempT6 + end + + if tMhPar.d3 and nTempT3 and nTempT3 <= 0 then -- lama + if DGD.bProoduce and tMhPar.bl then -- se utilizzo la lama + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLBM, nLMMi, tMhPar.d3, dNumLog, sMchngName3) + end + elseif nTempT3 then + tMhPar.d3 = nTempT3 + if nThBl3 and nThBl3 > 0 then tMhPar.thb = nThBl3 end + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + end + + if tMhPar.d4 and nTempT4 and nTempT4 <= 0 then -- utensile ripresa angoli + if DGD.bProoduce and tMhPar.bl and DGD.TYPE ~= 'thru' then + dNumLog = -2496 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLCC, nLCCi, tMhPar.d4, dNumLog, sMchngName4) + end + elseif nTempT4 then + tMhPar.d4 = nTempT4 + end + + -- se la profondità della groove è maggiore della capacità utensile limito la profondità ed emetto un warning + if not tMhPar.bl and tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then + dNumLog = -2498 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità antischeggia è maggiore della capacità utensile limito la profondità ed emetto un warning + if not tMhPar.bl and tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -2497 + dNumMessage = 541 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità antischeggia lato hinge è maggiore della capacità utensile limito la profondità ed emetto un warning + if not tMhPar.bl and tMhPar.T5 and dMaxMat5 and tMhPar.T5 > dMaxMat5 then + dNumLog = -2491 + dNumMessage = 541 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T5), EgtToUiUnits(dMaxMat5)) + tMhPar.T5 = dMaxMat5 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità antischeggia lato lock è maggiore della capacità utensile limito la profondità ed emetto un warning + if not tMhPar.bl and tMhPar.T6 and dMaxMat6 and tMhPar.T6 > dMaxMat6 then + dNumLog = -2489 + dNumMessage = 541 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T6), EgtToUiUnits(dMaxMat6)) + tMhPar.T6 = dMaxMat6 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità della groove è maggiore della capacità lama limito la profondità ed emetto un warning + if tMhPar.bl and tMhPar.T and dMaxMat3 and tMhPar.T > dMaxMat3 then + dNumLog = -2495 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat3)) + tMhPar.T = dMaxMat3 + end + + if tMhPar.bl and tMhPar.H and nThBl3 and ( tMhPar.H - nThBl3) < -GEO.EPS_SMALL then + dNumLog = -2494 + dNumMessage = 542 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.H), EgtToUiUnits(nThBl3)) + end + + -- se la profondità della groove è maggiore della capacità utensile ripresa antispigolo limito la profondità del percorso di questo ed emetto un warning + if tMhPar.bl and DGD.TYPE ~= 'thru' and tMhPar.T and dMaxMat4 and tMhPar.T > dMaxMat4 then + dNumLog = -2493 + dNumMessage = 612 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat4)) + tMhPar.T3 = dMaxMat4 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function Groove.Draw( tOHead, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni + local L = tOHead.L + local H = tOHead.H + local T = tOHead.T + local d = tOHead.d + local p = tOHead.p + local s = tOHead.s + local T2 = tOHead.T2 + local T5 = tOHead.T5 + local T6 = tOHead.T6 + local d2 = tOHead.d2 + local d5 = tOHead.d5 + local d6 = tOHead.d6 + local grs = tOHead.grs + local rf = tOHead.rf + local uab = tOHead.uab + local bl = tOHead.bl + local f1b = tOHead.f1b -- force 1 blade (RH side) + local slb = tOHead.slb -- set for LH side (only if use 1 blade) + local d3 = tOHead.d3 -- blade diameter + local red = tOHead.Red + local thb = tOHead.thb + local ech = tOHead.ech + local est = tOHead.est + local kbs = tOHead.kbs -- keep backset/thicknesss (0: none, 1: only face, 2: all) + local pbs = tOHead.pbs + local T3 = tOHead.T3 -- clean corner thickness path + local d4 = tOHead.d4 -- clean corner diameter tool + local invG = tOHead.invG -- push door flag + local D_X = tOHead.D_X -- delta position along length + local StpBd = tOHead.StpBd -- side step blade + -- Assegno i nomi geometrie + local LG = tOHead.LG -- nome geometria groove + local LM = tOHead.LM -- nome lavorazione groove con fresa + local LA = tOHead.LA -- nome geometria antischeggia + local LAM = tOHead.LAM -- nome lavorazione groove antischeggia con lama + local LAMU = tOHead.LAMU -- nome lavorazione groove UP antischeggia con lama + local LBM = tOHead.LBM -- nome lavorazione groove con lama + local LBMU = tOHead.LBMU -- nome lavorazione groove UP con lama + local LCC = tOHead.LCC -- nome lavorazione pulitura spigoli + local CH = tOHead.CH -- suffisso lavorazione chisel + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHead.Nome + local nCompoNpar = tOHead.Npar + local sCompoPath = tOHead.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tOHead.nCod + local sCodAdj = tOHead.sCod + -- nomi parametri per messaggi + local sNamePar1 = tOHead.N1 or 'L' + local sNamePar2 = tOHead.N2 or 'H' + local sNamePar3 = tOHead.N3 or 'T' + local sNamePar4 = tOHead.N4 or 'd' + local sNamePar5 = tOHead.N5 or 'p' + local sNamePar6 = tOHead.N6 or 'd2' + local sNamePar7 = tOHead.N7 or 'd5' + local sNamePar8 = tOHead.N8 or 'd6' + local sNamePar12 = tOHead.N12 or 'T2' + local sNamePar13 = tOHead.N13 or 'T5' + local sNamePar14 = tOHead.N14 or 'T6' + local sNamePar15 = tOHead.N15 or 's' + local sNamePar16 = tOHead.N16 or 'red' + local sNamePar17 = tOHead.N17 or 'rf' + -- impronta lama + local dExLenBl = 0 + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2400 + -- variabili che abilitano la creazione della geometria + local bMakeMortGeom = true + local bMakeAsGeom = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + -- o setto la disabilitazione della creazione di alcune geometrie + if not L or not H then + bMakeMortGeom = false + end + + if not D_X then D_X = 0 end + + if not T then T = 0 end + + if not T2 then T2 = 0 end + + if not T5 then T5 = 0 end + + if not T6 then T6 = 0 end + + if not thb then thb = 0 end + + if not StpBd or abs(StpBd) < 1 then StpBd = T + 0.1 end + + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + LG = LG .. CH + tOHead.LG = LG + end + + -- variabile larghezza porta + local dWidthDoor + local dWidthShape = L + -- se il tipo di cava non è passante disabilito la generazione dei percorsi anti-scheggia + if DGD.TYPE == 'center' or ( bl and not uab) then + bMakeAsGeom = false + elseif DGD.TYPE == 'side' then -- se sborda da un lato aumento del raggio fresa + 0.5mm + dWidthDoor = L + red + if not bl then + L = L + ( d / 2) + 0.5 + end + else + dWidthDoor = L + if not bl then + L = L + d + 1 -- se sborda da due lati aumento del diametro fresa + 1mm + end + end + + -- se posso inserire antischeggia + if bMakeAsGeom then + -- se diametro utensile antischeggia lato lock e porta ad angolo + if d2 and DGD.Tpa then + -- Se applicato su lato inclinato o applicato su lato piatto e lock si trova dalla parte opposta al lato piatto + if DGD.SIDE == 'top_angle' or + ( DGD.SIDE == 'top_flat' and ( ( DGD.Lock == 'L' and DGD.tProfs.top.angle > 0) or ( DGD.Lock == 'R' and DGD.tProfs.top.angle < 0))) then + d2 = nil + end + end + + -- se diametro utensile antischeggia lato LOCK (con shuttle lato lock) e porta ad angolo + if d6 and DGD.Tpa then + -- Se applicato su lato inclinato o applicato su lato piatto e hinge si trova dalla parte opposta al lato piatto + if DGD.SIDE == 'top_angle' or + ( DGD.SIDE == 'top_flat' and ( ( DGD.Lock == 'L' and DGD.tProfs.top.angle > 0) or ( DGD.Lock == 'R' and DGD.tProfs.top.angle < 0))) then + d6 = nil + end + end + + -- se diametro utensile antischeggia lato HINGE e porta ad angolo + if d5 and DGD.Tpa then + -- Se applicato su lato inclinato o applicato su lato piatto e hinge si trova dalla parte opposta al lato piatto + if DGD.SIDE == 'top_angle' or + ( DGD.SIDE == 'top_flat' and ( ( DGD.Lock == 'R' and DGD.tProfs.top.angle > 0) or ( DGD.Lock == 'L' and DGD.tProfs.top.angle < 0))) then + d5 = nil + end + end + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeMortGeom and nDrawMach > 0 and not bl 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 bMakeMortGeom and bMakeAsGeom and nDrawMach > 0 and not bl 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 bMakeMortGeom and nDrawMach > 0 and not grs and not bl and H <= d then + if DGD.bProoduce then + EC = 3 + EM = string.format(EgtDoorsMsg[402],sNamePar2,EgtToUiUnits(H),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore al diametro utensile d + H = d + 0.002 + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not bl 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 d + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeMortGeom and bMakeAsGeom and not grs and nDrawMach > 0 and not bl and d2 and H <= d2 then + if DGD.bProoduce then + EC = 5 + EM = string.format(EgtDoorsMsg[402],sNamePar2,EgtToUiUnits(H),sNamePar6,EgtToUiUnits(d2), sCompoPath) -- il parametro 'H' deve essere maggiore al diametro utensile d2 + H = d2 + 0.002 + else + d2 = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not bl 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 bMakeMortGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and bMakeAsGeom and T2 < 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[404],sNamePar12,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere >= 0 + T2 = 0 + elseif bMakeMortGeom and nDrawMach > 0 and not bl and s and s <= 0 then + EC = 9 + EM = string.format(EgtDoorsMsg[401],sNamePar15,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d + elseif bMakeMortGeom and nDrawMach > 0 and grs and rf and L and 2*rf >= L and DGD.TYPE == 'center' then + EC = 10 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(rf),sNamePar1..'/2',EgtToUiUnits(L/2), sCompoPath) -- il parametro 'rf' deve essere < del parametro L/2 + rf = d/2 + elseif bMakeMortGeom and nDrawMach > 0 and grs and H and rf and rf >= H then + EC = 11 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(rf),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'rf' deve essere < del parametro H + rf = H/2 + elseif bMakeMortGeom and nDrawMach > 0 and bl and DGD.TYPE ~= 'thru' then + + if DGD.TYPE ~= 'thru' then + local dR3 = d3/2 + local dDt = dR3 - T + dExLenBl = sqrt( (dR3 * dR3) - ( dDt * dDt)) + end + if DGD.TYPE == 'side' and ( L - dExLenBl) <= 0 then + EC = 12 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L), 'BladeResult', EgtToUiUnits(dExLenBl), sCompoPath) -- il parametro 'T2' deve essere >= 0 + elseif DGD.TYPE == 'center' and ( L - ( 2*dExLenBl)) <= 0 then + EC = 13 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L), 'BladeResult', EgtToUiUnits(dExLenBl*2), sCompoPath) -- il parametro 'T2' deve essere >= 0 + end + elseif bMakeMortGeom and bMakeAsGeom and nDrawMach > 0 and not bl and d5 and d5 < DgMin then + EC = 14 + EM = string.format(EgtDoorsMsg[400],sNamePar7,EgtToUiUnits(d5),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d5 = DgMin + elseif bMakeMortGeom and bMakeAsGeom and nDrawMach > 0 and not bl and d6 and d6 < DgMin then + EC = 17 + EM = string.format(EgtDoorsMsg[400],sNamePar8,EgtToUiUnits(d6),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d6 = DgMin + elseif bMakeMortGeom and bMakeAsGeom and not grs and nDrawMach > 0 and not bl and d5 and H <= d5 then + if DGD.bProoduce then + EC = 15 + EM = string.format(EgtDoorsMsg[402],sNamePar2,EgtToUiUnits(H),sNamePar7,EgtToUiUnits(d5), sCompoPath) -- il parametro 'H' deve essere maggiore al diametro utensile d5 + H = d5 + 0.002 + else + d5 = H - 0.002 + end + elseif bMakeMortGeom and bMakeAsGeom and not grs and nDrawMach > 0 and not bl and d6 and H <= d6 then + if DGD.bProoduce then + EC = 18 + EM = string.format(EgtDoorsMsg[402],sNamePar2,EgtToUiUnits(H),sNamePar8,EgtToUiUnits(d6), sCompoPath) -- il parametro 'H' deve essere maggiore al diametro utensile d6 + H = d6 + 0.002 + else + d6 = H - 0.002 + end + elseif bMakeMortGeom and bMakeAsGeom and T5 < 0 then + EC = 16 + EM = string.format(EgtDoorsMsg[404],sNamePar13,EgtToUiUnits(T5), sCompoPath) -- il parametro 'T5' deve essere >= 0 + T5 = 0 + elseif bMakeMortGeom and bMakeAsGeom and T6 < 0 then + EC = 19 + EM = string.format(EgtDoorsMsg[404],sNamePar14,EgtToUiUnits(T6), sCompoPath) -- il parametro 'T6' deve essere >= 0 + T5 = 0 + 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 + + -- variabili dei percorsi geometrici + local Lg, Dm + local nGeom1 + local nPkToJoin1, nPkToJoin2, nPkToJoin3, nPkToJoin4 + local hint1, hint2, hint3, hint4, hint5, hint6, hintAs, hintAsR + local CleanCor2 = {} + local tPocketAs = {} + local pIni, pEnd + local dMinDist = 0 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + -- geometria antischeggia + if bMakeAsGeom and nDrawMach > 0 then + if grs then -- se groove on side + if DGD.TYPE == 'thru' then -- de groove passante (antisplint da entrambe i lati) + -- se lato lock lavorato con shuttle + if d6 and T6 and not( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + d2 = d6 + T2 = T6 + end + -- disegno secondo percorso (lato lock) |__ <-- + if d2 then -- se parametro diametro utensile valido + if invG > 0 then -- --> __| + pIni = Point3d(-(d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(T-(d2/2)+dExtraH,-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d2/2)+dExtraH,(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else -- |__ <-- + pIni = Point3d((d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(-(T-(d2/2)+dExtraH),-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(T-(d2/2)+dExtraH),(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + end + -- creo percorso + hintAsR = EgtCurveCompo( Lg, tPocketAs, true) + + -- posizionamento geometria + local dAngleRot = -90 + local sNamePR + if hintAsR and LA and ( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + sNamePR = LA + elseif LA then + sNamePR = LA ..'_LK' + end + if invG > 0 then + dAngleRot = 90 + end + + if hintAsR then -- se esiste secondo percorso + EgtModifyCurveThickness( hintAsR, -T2) + -- assegno nome percorso + EgtSetName( hintAsR, sNamePR) + EgtRotate( hintAsR, ORIG(), Y_AX(), dAngleRot ) -- ruoto su faccia laterale opposta + if invG > 0 then + EgtMove( hintAsR, Point3d((dWidthDoor/2),0,0) - ORIG()) + EgtInvertCurve(hintAsR) + else + EgtMove( hintAsR, Point3d(-(dWidthDoor/2),0,0) - ORIG()) + end + if kbs and kbs > 1 then + EgtSetInfo( hintAsR, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto lato narrow + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAsR, 'ProbeSide', '1') + end + if DGD.SIDE and ( DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat') then + EgtInvertCurve(hintAsR) + end + end + end + end + + if DGD.TYPE ~= 'center' then -- se groove non in centro + -- disegno primo percorso (lato hinge) --> __| + if d5 then -- se parametro valido + tPocketAs = {} + if invG > 0 then -- |__ <-- + pIni = Point3d((d5*3/4),-(H-(d5/2)+dExtraH),0) + pEnd = Point3d(-(T-(d5/2)+dExtraH),-(H-(d5/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(T-(d5/2)+dExtraH),(d5*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + else -- --> __| + pIni = Point3d(-(d5*3/4),-(H-(d5/2)+dExtraH),0) + pEnd = Point3d(T-(d5/2)+dExtraH,-(H-(d5/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d5/2)+dExtraH,(d5*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + end + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + end + + -- posizionamento geometria + local dAngleRot = 90 + local sNameP + if hintAs and LA and ( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + sNameP = LA + elseif LA then + sNameP = LA ..'_HNG' + end + if invG > 0 then + dAngleRot = -90 + end + + if hintAs then -- se esiste primo percorso + EgtModifyCurveThickness( hintAs, -T5) + -- assegno nome percorso + EgtSetName( hintAs, sNameP) + -- rotazione percorso + EgtRotate( hintAs, ORIG(), Y_AX(), dAngleRot ) -- ruoto su faccia laterale + EgtSetInfo( hintAs, 'UseBlade', bl) + EgtSetInfo( hintAs, 'UseTwiceBl', not f1b) + EgtSetInfo( hintAs, 'SideApp', EgtIf( DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat', 'top', DGD.SIDE)) + if invG > 0 then + EgtMove( hintAs, Point3d(-(dWidthDoor/2),0,0) - ORIG()) + else + EgtMove( hintAs, Point3d((dWidthDoor/2),0,0) - ORIG()) + EgtInvertCurve(hintAs) + end + if kbs and kbs > 1 then + EgtSetInfo( hintAs, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto lato narrow + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + if DGD.SIDE and ( DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat') then + EgtInvertCurve(hintAs) + end + end + end + else -- groove normale + if DGD.TYPE == 'thru' then -- se groove passante (antisplint da entrambe i lati) + -- se lato lock lavorato con shuttle + if d6 and T6 and not( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + d2 = d6 + T2 = T6 + end + -- disegno secondo percorso (lato lock) + if d2 then -- se parametro valido + if abs(H-d2+(2*dExtraH)) <= GEO.EPS_SMALL then -- se distanza punti inconsistente, aggiungo 0.0015mm per fare almeno una piccola linea + dMinDist = 0.0015 + end + pIni = Point3d(-(d2*3/4),-((H-d2+dMinDist)/2)-dExtraH,0) + pEnd = Point3d(T-(d2/2)+dExtraH,-((H-d2+dMinDist)/2)-dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d2/2)+dExtraH,((H-d2+dMinDist)/2)+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(d2*3/4),((H-d2+dMinDist)/2)+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + -- creo percorso + hintAsR = EgtCurveCompo( Lg, tPocketAs, true) + end + end + + if DGD.TYPE ~= 'center' then -- se groove non in centro + -- disegno primo percorso (lato hinge) + if d5 then -- se parametro valido + tPocketAs = {} + if abs(H-d5+(2*dExtraH)) <= GEO.EPS_SMALL then -- se distanza punti inconsistente, aggiungo 0.0015mm per fare almeno una piccola linea + dMinDist = 0.0015 + end + pIni = Point3d(-(d5*3/4),-((H-d5+dMinDist)/2)-dExtraH,0) + pEnd = Point3d(T-(d5/2)+dExtraH,-((H-d5+dMinDist)/2)-dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d5/2)+dExtraH,((H-d5+dMinDist)/2)+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(d5*3/4),((H-d5+dMinDist)/2)+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d5/2), true, true, ORANGE(), ORANGE()) + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + end + end + + local dAngleRot = 90 + local sNameP + if hintAs and LA and (DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + sNameP = LA + elseif LA then + sNameP = LA ..'_HNG' + end + local sNamePR + if hintAsR and LA and (DGD.SIDE == 'hinge' or DGD.SIDE == 'lock') then + sNamePR = LA + elseif LA then + sNamePR = LA ..'_LK' + end + + if hintAs then -- se esiste primo percorso + EgtModifyCurveThickness( hintAs, -T5) + -- assegno nome percorso + EgtSetName( hintAs, sNameP) + -- rotazione percorso + EgtRotate( hintAs, ORIG(), Y_AX(), dAngleRot ) -- ruoto su faccia laterale + EgtSetInfo( hintAs, 'UseBlade', bl) + EgtSetInfo( hintAs, 'UseTwiceBl', not f1b) + EgtSetInfo( hintAs, 'SideApp', EgtIf( DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat', 'top', DGD.SIDE)) + + -- posizionamento geometria + EgtMove( hintAs, Point3d((dWidthDoor/2),0,0) - ORIG()) + EgtSetInfo( hintAs, 'TypePath', 1) + EgtInvertCurve(hintAs) + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintAs, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + end + + if hintAsR then -- se esiste secondo percorso + EgtModifyCurveThickness( hintAsR, -T2) + -- assegno nomi ai percorsi + EgtSetName( hintAsR, sNamePR) + -- rotazione percorso + EgtRotate( hintAsR, ORIG(), Y_AX(), dAngleRot ) -- ruoto su faccia laterale + -- rotazione geometria + EgtRotate( hintAsR, ORIG(), Z_AX(), 180 ) -- ruoto copia su faccia laterale opposta + + -- posizionamento geometria + EgtMove( hintAsR, Point3d(-(dWidthDoor/2),0,0) - ORIG()) + EgtSetInfo( hintAsR, 'TypePath', 2) + EgtInvertCurve(hintAsR) + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintAsR, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAsR, 'ProbeSide', '1') + end + end + end + end +--[[ + -- vecchia + -- geometria antischeggia + if bMakeAsGeom and nDrawMach > 0 then + + if d2 then -- se parametro valido + + if grs then -- se groove on side + if DGD.TYPE == 'thru' then + -- disegno secondo percorso + pIni = Point3d((d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(-(T-(d2/2)+dExtraH),-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(T-(d2/2)+dExtraH),(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + -- creo percorso + hintAsR = EgtCurveCompo( Lg, tPocketAs, true) + EgtModifyCurveThickness( hintAsR, -T2) + -- rotazione geometria + EgtRotate( hintAsR, ORIG(), Y_AX(), -90 ) -- ruoto su faccia laterale opposta + tPocketAs = {} + -- disegno primo percorso + pIni = Point3d(-(d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(T-(d2/2)+dExtraH,-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d2/2)+dExtraH,(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + -- disegno primo percorso + if invG > 0 then + pIni = Point3d((d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(-(T-(d2/2)+dExtraH),-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(T-(d2/2)+dExtraH),(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + pIni = Point3d(-(d2*3/4),-(H-(d2/2)+dExtraH),0) + pEnd = Point3d(T-(d2/2)+dExtraH,-(H-(d2/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d2/2)+dExtraH,(d2*3/4),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + end + end + else + if abs(H-d2) <= GEO.EPS_SMALL then -- se distanza punti inconsistente, aggiungo 0.0015mm per fare almeno una piccola linea + dMinDist = 0.0015 + end + pIni = Point3d(-(d2*3/4),-((H-d2+dMinDist)/2),0) + pEnd = Point3d(T-(d2/2),-((H-d2+dMinDist)/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(T-(d2/2),((H-d2+dMinDist)/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(d2*3/4),((H-d2+dMinDist)/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + end + + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + EgtModifyCurveThickness( hintAs, -T2) + + local dAngleRot = 90 + local sNameP = EgtIf( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock', LA, LA ..'_HNG') + + if grs then + if DGD.TYPE == 'thru' then + if invG > 0 then + sNameP = LA + end + else + if invG > 0 then + dAngleRot = -90 + end + end + end + + -- assegno nome percorso + EgtSetName( hintAs, sNameP) + -- rotazione percorso + EgtRotate( hintAs, ORIG(), Y_AX(), dAngleRot ) -- ruoto su faccia laterale + EgtSetInfo( hintAs, 'UseBlade', bl) + EgtSetInfo( hintAs, 'UseTwiceBl', not f1b) + EgtSetInfo( hintAs, 'SideApp', DGD.SIDE) + + -- posizionamento geometria + if DGD.TYPE == 'side' then + if grs then + if invG > 0 then + EgtMove( hintAs, Point3d(-(dWidthDoor/2),0,0) - ORIG()) + else + EgtMove( hintAs, Point3d((dWidthDoor/2),0,0) - ORIG()) + end + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintAs, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto il lato narrow + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + else + EgtMove( hintAs, Point3d((dWidthDoor/2),0,0) - ORIG()) + EgtSetInfo( hintAs, 'TypePath', 1) + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintAs, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + end + elseif DGD.TYPE == 'thru' then + + local sNameP + local sNamePR + + if grs then + if invG > 0 then + sNamePR = EgtIf( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock', LA, LA ..'_HNG') -- per lato cerniere (groove top o bottom) aggiungo suffisso + sNameP = LA + else + sNamePR = LA + sNameP = EgtIf( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock', LA, LA ..'_HNG') -- per lato cerniere (groove top o bottom) aggiungo suffisso + end + else + -- copio il percorso + hintAsR = EgtCopyGlob ( hintAs, Lg) + sNamePR = LA + sNameP = EgtIf( DGD.SIDE == 'hinge' or DGD.SIDE == 'lock', LA, LA ..'_HNG') -- per lato cerniere (groove top o bottom) aggiungo suffisso + -- rotazione geometria + EgtRotate( hintAsR, ORIG(), Z_AX(), 180 ) -- ruoto copia su faccia laterale opposta + end + + -- assegno nomi ai percorsi + EgtSetName( hintAsR, sNamePR) + EgtSetName( hintAs, sNameP) + if grs then + -- inverto il percorso + EgtInvertCurve(hintAsR) + else + EgtSetInfo( hintAs, 'TypePath', 1) + EgtSetInfo( hintAsR, 'TypePath', 2) + end + EgtMove( hintAs, Point3d((dWidthDoor/2),0,0) - ORIG()) + EgtMove( hintAsR, Point3d(-(dWidthDoor/2),0,0) - ORIG()) + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + if grs then -- se groove on side + EgtSetInfo( hintAs, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto lato narrow + EgtSetInfo( hintAsR, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto lato narrow + else + EgtSetInfo( hintAs, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hintAsR, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + EgtSetInfo( hintAsR, 'ProbeSide', '1') + end + end + if grs and DGD.SIDE and DGD.SIDE == 'top' then + if hintAs then + EgtInvertCurve(hintAs) + end + if hintAsR then + EgtInvertCurve(hintAsR) + end + end + end + end +]]-- + + if bMakeMortGeom then + if not bl then + -- cava mortasa + local dMortise = {} + local sRequireCompoName + local GId + -- assegno i valori coerenti con la tabella del componente + if grs then + dMortise.L = L + dMortise.H = H + dMortise.T = T + dMortise.d = d + dMortise.p = p + dMortise.sf = s + dMortise.rf = rf + dMortise.d2 = nil + dMortise.jn = false + dMortise.L2 = L + dMortise.H2 = H + dMortise.D = 0 + dMortise.D_X = 0 + dMortise.invG = EgtIf( DGD.SIDE and ( DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat'), -1, 1) + dMortise.LG = LG + dMortise.LM = LM + dMortise.LA = LA + dMortise.Nome = sCompoName + sRequireCompoName = '_LatchStrike' + else + dMortise.T = T + dMortise.L2 = L + dMortise.H2 = H + dMortise.T2 = T + dMortise.d = d + dMortise.p = p + dMortise.s = s + dMortise.jn = false + dMortise.d3 = d + dMortise.p3 = p + dMortise.invG = 1 + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.L3 = L + dMortise.H3 = H + dMortise.LGM = LG + dMortise.LMM = LM + dMortise.Nome = sCompoName + dMortise.jne = false + dMortise.D_X = 0 + + if DGD.TYPE == 'side' and ech then + dMortise.smr = 1 -- inserisco i raccordini per non fare il chisel + else + dMortise.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + end + sRequireCompoName = '_Mortise' + end + + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- creo la geometria che rappresenta l'ingombro della groove sulla porta + if EC == 0 and grs and nDrawMach > 0 then + -- setto la griglia dietro + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.BACK)) + GId = EgtRectangle2P( Lg, Point3d( -((dWidthShape-d)/2), 0, 0), Point3d( ((dWidthShape-d)/2), -T, 0), GDB_RT.GRID) + if GId then + EgtInvertCurve(GId) + EgtModifyCurveThickness( GId, -H) + EgtSetName( GId, 'BOXGROOVE') + end + -- risetto la griglia top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + + if EC == 0 and ( nGeom1 or nPkToJoin1) then + if DGD.TYPE == 'side' then -- sposto le geometrie del valore settato + if red and red ~= 0 then + local dMove = ((red/2)+(d/4)+0.25) + local dMove2 = (red/2) + if grs and invG > 0 then + dMove = -dMove + dMove2 = -dMove2 + end + + if nGeom1 then + EgtMove( nGeom1, Point3d(dMove,0,0) - ORIG()) + end + if nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d(dMove,0,0) - ORIG()) + end + if GId then + EgtMove( GId, Point3d(dMove2,0,0) - ORIG()) + end + end + elseif DGD.TYPE == 'center' and D_X then -- se in centro e D_X ha un valore sposto le geometrie + if nGeom1 then + EgtMove( nGeom1, Point3d(D_X,0,0) - ORIG()) + end + if nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d(D_X,0,0) - ORIG()) + end + if GId then + EgtMove( GId, Point3d(D_X,0,0) - ORIG()) + end + end + + if kbs and kbs > 1 then + if nGeom1 then + if grs then + EgtSetInfo( nGeom1, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto il lato narrow + else + EgtSetInfo( nGeom1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + if nPkToJoin1 then + if grs then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto il lato narrow + else + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + end + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + if nGeom1 then + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + end + end + end + else -- con lama + + -- posizione Y iniziale (Z bassa) + local dIniPosY = ((-H+thb)/2) + local nEndPosY = ((H-thb)/2) + + if DGD.TYPE == 'side' then + pEnd = EgtIf( f1b, Point3d((L/2), dIniPosY,-T), Point3d(2, dIniPosY,-T)) + else + pEnd = EgtIf( f1b, Point3d(((L/2)-dExLenBl), dIniPosY,-T), Point3d(2, dIniPosY,-T)) + end + + pIni = Point3d( -((L/2)-dExLenBl), dIniPosY, -T) + local nSideStep = 0 + local dSideDepth + local bInvertPoint + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- se lama singola e settata antioraria inverto i punti + if f1b and slb and not bInvertPoint then + pIni, pEnd = pEnd, pIni + bInvertPoint = true + end + + -- percorso dw già affondato allo spessore cava e calcolato per il centro spessore lama + hint1 = DrawAddLineDrawCircle( Point3d( pIni:getX(), pIni:getY(), -dSideDepth), Point3d( pEnd:getX(), pEnd:getY(), -dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin1 = EgtCurveCompo( Lg, {hint1}, true) + EgtModifyCurveThickness( nPkToJoin1, 0) + EgtModifyCurveExtrusion( nPkToJoin1, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin1, LBM .. '_NLI') + else + EgtSetName( nPkToJoin1, LBM) + EgtSetInfo( nPkToJoin1, 'PathType', 'NR') + -- se lama singola e settata antioraria inverto i punti + if f1b and slb then + EgtSetInfo( nPkToJoin1, 'InvDir', 'INV') + end + EgtSetInfo( nPkToJoin1, 'LeadType', '_NLI') + if not f1b then + EgtSetInfo( nPkToJoin1, 'ToolsUse', 'TW') + end + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin1, LBM .. '_NLILO') + else + EgtSetName( nPkToJoin1, LBM) + EgtSetInfo( nPkToJoin1, 'PathType', 'NR') + EgtSetInfo( nPkToJoin1, 'LeadType', '_NLILO') + if not f1b then + EgtSetInfo( nPkToJoin1, 'ToolsUse', 'TW') + end + end + else + EgtSetName( nPkToJoin1, LBM) + if nNewLeadInOutMode then + EgtSetInfo( nPkToJoin1, 'PathType', 'NR') + if not f1b then + EgtSetInfo( nPkToJoin1, 'ToolsUse', 'TW') + end + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + end + until dSideDepth >= T + + -- se passi intermedi + if H > ( thb + 10*GEO.EPS_SMALL) then + + -- calsolo il passo in Y in base alla larghezza cava + local dMatOnY = (H-thb) + local dStepOnY = thb + if dMatOnY > ( thb + 10*GEO.EPS_SMALL) then + dStepOnY = thb * 0.95 + end + + local nStepY = EgtIf( thb > 10*GEO.EPS_SMALL, ceil((H-thb)/dStepOnY), 1) -- numero di passate + local dStepY = ((H-thb)/nStepY) -- passo ricalcolato + local nPass = 1 + local dMiddlePosY = dIniPosY + dStepY + + -- ciclo inserimento linee + while nPass <= nStepY and dMiddlePosY < ( nEndPosY + 10*GEO.EPS_SMALL) do + + if DGD.TYPE == 'side' then + pEnd = EgtIf( f1b, Point3d((L/2), dMiddlePosY,-T), Point3d(2, dMiddlePosY,-T)) + else + pEnd = EgtIf( f1b, Point3d(((L/2)-dExLenBl), dMiddlePosY,-T), Point3d(2, dMiddlePosY,-T)) + end + + nSideStep = 0 + bInvertPoint = false + pIni = Point3d( -((L/2)-dExLenBl), dMiddlePosY, -T) + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- se lama singola e settata antioraria inverto i punti + if f1b and slb and not bInvertPoint then + pIni, pEnd = pEnd, pIni + bInvertPoint = true + end + + -- percorso up già affondato allo spessore cava e calcolato per il centro spessore lama + hint3 = DrawAddLineDrawCircle( Point3d( pIni:getX(), pIni:getY(), -dSideDepth), Point3d( pEnd:getX(), pEnd:getY(), -dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin3 = EgtCurveCompo( Lg, {hint3}, true) + EgtModifyCurveThickness( nPkToJoin3, 0) + EgtModifyCurveExtrusion( nPkToJoin3, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU .. '_NLI') + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + -- se lama singola e settata antioraria inverto i punti + if f1b and slb then + EgtSetInfo( nPkToJoin3, 'InvDir', 'INV') + end + EgtSetInfo( nPkToJoin3, 'LeadType', '_NLI') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU .. '_NLILO') + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + EgtSetInfo( nPkToJoin3, 'LeadType', '_NLILO') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + else + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU) + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin3 then + EgtMove( nPkToJoin3, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin3 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + end + until dSideDepth >= T + + -- incremento passo + nPass = nPass + 1 + -- nuova posizione in Y + dMiddlePosY = dMiddlePosY + dStepY + end + end + +--[[ + if H > thb + 10*GEO.EPS_SMALL then + + if DGD.TYPE == 'side' then + pEnd = EgtIf( f1b, Point3d((L/2), nEndPosY,-T), Point3d(2, nEndPosY,-T)) + else + pEnd = EgtIf( f1b, Point3d(((L/2)-dExLenBl), nEndPosY,-T), Point3d(2, nEndPosY,-T)) + end + + nSideStep = 0 + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- percorso up già affondato allo spessore cava e calcolato per il centro spessore lama + hint3 = DrawAddLineDrawCircle( Point3d(-((L/2)-dExLenBl), nEndPosY,-dSideDepth), Point3d( pEnd:getX(), pEnd:getY(),-dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin3 = EgtCurveCompo( Lg, {hint3}, true) + EgtModifyCurveThickness( nPkToJoin3, 0) + EgtModifyCurveExtrusion( nPkToJoin3, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU .. '_NLI') + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + EgtSetInfo( nPkToJoin3, 'LeadType', '_NLI') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU .. '_NLILO') + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + EgtSetInfo( nPkToJoin3, 'LeadType', '_NLILO') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + else + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin3, LBMU) + else + EgtSetName( nPkToJoin3, LBM) + EgtSetInfo( nPkToJoin3, 'PathType', 'NR') + if not f1b then + EgtSetInfo( nPkToJoin3, 'ToolsUse', 'TW') + end + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin3 then + EgtMove( nPkToJoin3, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin3 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + end + until dSideDepth >= T + end +]]-- + -- se non ho la forzatura a utilizzare solo una lama + if not f1b then + + if DGD.TYPE == 'side' then + pIni = Point3d((L/2), dIniPosY,-T) + else + pIni = Point3d(((L/2)-dExLenBl), dIniPosY,-T) + end + + nSideStep = 0 + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- percorso inverso ( antischeggia) dw già affondato allo spessore cava e calcolato per il centro spessore lama + hint2 = DrawAddLineDrawCircle( Point3d( pIni:getX(), pIni:getY(),-dSideDepth), Point3d(-2, dIniPosY,-dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin2 = EgtCurveCompo( Lg, {hint2}, true) + EgtModifyCurveThickness( nPkToJoin2, 0) + EgtModifyCurveExtrusion( nPkToJoin2, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin2, LAM .. '_NLO') + else + EgtSetName( nPkToJoin2, LAM) + EgtSetInfo( nPkToJoin2, 'LeadType', '_NLO') + EgtSetInfo( nPkToJoin2, 'PathType', 'AS') + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin2, LAM .. '_NLILO') + else + EgtSetName( nPkToJoin2, LAM) + EgtSetInfo( nPkToJoin2, 'LeadType', '_NLILO') + EgtSetInfo( nPkToJoin2, 'PathType', 'AS') + end + else + EgtSetName( nPkToJoin2, LAM) + if nNewLeadInOutMode then + EgtSetInfo( nPkToJoin2, 'PathType', 'AS') + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin2 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + end + until dSideDepth >= T + + -- se passi intermedi + if H > ( thb + 10*GEO.EPS_SMALL) then + + -- calsolo il passo in Y in base alla larghezza cava + local dMatOnY = (H-thb) + local dStepOnY = thb + if dMatOnY > ( thb + 10*GEO.EPS_SMALL) then + dStepOnY = thb * 0.95 + end + + local nStepY = EgtIf( thb > 10*GEO.EPS_SMALL, ceil((H-thb)/dStepOnY), 1) -- numero di passate + local dStepY = ((H-thb)/nStepY) -- passo ricalcolato + local nPass = 1 + local dMiddlePosY = dIniPosY + dStepY + + -- ciclo inserimento linee + while nPass <= nStepY and dMiddlePosY < ( nEndPosY + 10*GEO.EPS_SMALL) do + + if DGD.TYPE == 'side' then + pIni = Point3d((L/2), dMiddlePosY,-T) + else + pIni = Point3d(((L/2)-dExLenBl), dMiddlePosY,-T) + end + + nSideStep = 0 + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- percorso inverso ( antischeggia) up già affondato allo spessore cava e calcolato per il centro spessore lama + hint4 = DrawAddLineDrawCircle( Point3d( pIni:getX(), pIni:getY(),-dSideDepth), Point3d(-2, dMiddlePosY,-dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin4 = EgtCurveCompo( Lg, {hint4}, true) + EgtModifyCurveThickness( nPkToJoin4, 0) + EgtModifyCurveExtrusion( nPkToJoin4, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU .. '_NLO') + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'LeadType', '_NLO') + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU .. '_NLILO') + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'LeadType', '_NLILO') + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + else + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU) + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin4 then + EgtMove( nPkToJoin4, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin4 then + EgtSetInfo( nPkToJoin4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin4 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin4, 'ProbeSide', '1') + end + until dSideDepth >= T + + -- incremento passo + nPass = nPass + 1 + -- nuova posizione in Y + dMiddlePosY = dMiddlePosY + dStepY + end + end + +--[[ + if H > thb then + + if DGD.TYPE == 'side' then + pIni = Point3d((L/2), nEndPosY,-T) + else + pIni = Point3d(((L/2)-dExLenBl), nEndPosY,-T) + end + + nSideStep = 0 + + -- creo n percorsi di side step + repeat + + nSideStep = nSideStep + 1 + dSideDepth = EgtIf( (StpBd * nSideStep) > T, T, (StpBd * nSideStep)) + + -- percorso inverso ( antischeggia) up già affondato allo spessore cava e calcolato per il centro spessore lama + hint4 = DrawAddLineDrawCircle( Point3d( pIni:getX(), pIni:getY(),-dSideDepth), Point3d(-2, nEndPosY,-dSideDepth), + Lg, nil, bPreview, Dm, (d3/2), false, false, ORANGE(), ORANGE()) + nPkToJoin4 = EgtCurveCompo( Lg, {hint4}, true) + EgtModifyCurveThickness( nPkToJoin4, 0) + EgtModifyCurveExtrusion( nPkToJoin4, Y_AX(), GDB_RT.GLOB) + + if DGD.TYPE == 'side' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU .. '_NLO') + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'LeadType', '_NLO') + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + elseif DGD.TYPE == 'center' then + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU .. '_NLILO') + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'LeadType', '_NLILO') + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + else + if not nNewLeadInOutMode then + EgtSetName( nPkToJoin4, LAMU) + else + EgtSetName( nPkToJoin4, LAM) + EgtSetInfo( nPkToJoin4, 'PathType', 'AS') + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and nPkToJoin4 then + EgtMove( nPkToJoin4, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and nPkToJoin4 then + EgtSetInfo( nPkToJoin4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and nPkToJoin4 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin4, 'ProbeSide', '1') + end + until dSideDepth >= T + end +--]] + end + + -- creo percorso/i pulitura spigoli + if DGD.TYPE ~= 'thru' and d4 and dExLenBl and dExLenBl > 0 then + + local CleanCor1 = {} + pIni = Point3d(-((L/2)-dExLenBl-(H/2)),0,0) + pEnd = Point3d(-((L/2)-dExLenBl-(H/2)),-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, CleanCor1, bPreview, Dm, (d4/2), false, false, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(L/2),-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, CleanCor1, bPreview, Dm, (d4/2), false, false, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-(L/2),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, CleanCor1, bPreview, Dm, (d4/2), false, false, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-((L/2)-dExLenBl-(H/2)),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, CleanCor1, bPreview, Dm, (d4/2), false, false, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d(-((L/2)-dExLenBl-(H/2)),0,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, CleanCor1, bPreview, Dm, (d4/2), false, false, ORANGE(), ORANGE()) + hint5 = EgtCurveCompo( Lg, CleanCor1, true) + EgtModifyCurveThickness( hint5, -T3) + EgtSetName( hint5, LCC) + + if DGD.TYPE == 'center' then + hint6 = EgtCopyGlob( hint5, Lg) + EgtRotate( hint6, ORIG(), Z_AX(), 180) + -- se mantiene backset su mortise + if kbs and kbs > 1 then + EgtSetInfo( hint6, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint6, 'ProbeSide', '1') + end + end + + if red and red ~= 0 and DGD.TYPE == 'side' and hint5 then + EgtMove( hint5, Point3d((red/2),0,0) - ORIG()) + end + -- se mantiene backset su mortise + if kbs and kbs > 1 and hint5 then + EgtSetInfo( hint5, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and hint5 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + end + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'Groove') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'s' ,s) + EgtSetInfo(Lg,'T2' ,T2) + EgtSetInfo(Lg,'T5' ,T5) + EgtSetInfo(Lg,'T6' ,T6) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'d5' ,d5) + EgtSetInfo(Lg,'d6' ,d6) + EgtSetInfo(Lg,'grs' ,grs) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'bl' ,bl) + EgtSetInfo(Lg,'f1b' ,f1b) + EgtSetInfo(Lg,'slb' ,slb) + EgtSetInfo(Lg,'d3' ,d3) + EgtSetInfo(Lg,'T3' ,T3) + EgtSetInfo(Lg,'d4' ,d4) + EgtSetInfo(Lg,'red' ,red) + EgtSetInfo(Lg,'thb' ,thb) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'D_X' ,D_X) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LAM' ,LAM) + EgtSetInfo(Lg,'LAMU' ,LAMU) + EgtSetInfo(Lg,'LBM' ,LBM) + EgtSetInfo(Lg,'LBMU' ,LBMU) + EgtSetInfo(Lg,'LCC' ,LCC) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return Groove diff --git a/LuaLibs/ImportNgeFile.lua b/LuaLibs/ImportNgeFile.lua new file mode 100644 index 0000000..c544630 --- /dev/null +++ b/LuaLibs/ImportNgeFile.lua @@ -0,0 +1,201 @@ +-- +-- 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 +-- +-- ImportNgeFile.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- importazione file .nge + +-- 2017.06.16 V1.011 FM Check bore thickness when its color is not green or red +-- 2019.04.19 V1.012 FM Fix import hinges as nge file; fix on import DeltaPos note from geometry and let it to a new layer +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2021.04.23 V2.001 FM Manage info about hatching +-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V2.003 FM Modification to use compiled code +-- 2023.05.08 V2.004 FM Manage scale factor if length and width are <= than 10 (max scale factor) + +-- Tavola per definizione modulo (serve ma non usata) +local ImportNgeFile = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + + +-- Funzione di disegno +function ImportNgeFile.Draw( CustGeomPath, CustGeomFile ) + + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1050 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Pezzo e Layer + local Pz = EgtGetCurrPart() -- pezzo corrente + local Lg + + -- Gestione file custom + local MakeFaceGeom = true + local sCompoName + -- nota presenza hatching + local bHatch + + -- caricamento del file custom + if CustGeomFile and string.find( string.lower(CustGeomFile), '.nge') then + + -- sostituisco il carattere '\' con '_' nel nome file + CustGeomFile = string.gsub(CustGeomFile, '\\', '_') + CustGeomFile = string.gsub(CustGeomFile, '/', '_') + _,sCompoName,_ = EgtSplitPath( CustGeomFile) + + -- concateno il file alla path + local sCustomPathFile = CustGeomPath..CustGeomFile + local nNewPart + local nNewLayer + local nNewEnt + local nTypeEnt + local sTypeInfo + local cColor + local sDeltaPos + + -- provo ad inserire + MakeFaceGeom = not EgtInsertFile( sCustomPathFile) + + -- se fallito inserimento file do un messaggio di errore + if MakeFaceGeom then + EC = 1 + EM = string.format( EgtDoorsMsg[412], sCustomPathFile) + return (ErrorBase+EC), EM + end + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale + EgtSetName(Lg,sCompoName) + + nNewPart = EgtGetNext(Pz) -- nome nuovo pezzo + nNewLayer = EgtGetFirstInGroup( nNewPart) -- ottengo nuovo layer + + -- applico la scala + if nNewLayer then + -- se è in mm + local dCompare = 1 + if DGD.bMM then + dCompare = 1 + else + dCompare = 25.4 + end + -- se ha la nota che permette di scalare + local bScale = EgtGetInfo( nNewPart, 'AllowScale', 'b') or false + + -- se inferiore ai 10" + if bScale and abs(DGD.LENGTH)/dCompare <= 10 and abs(DGD.WIDTH)/dCompare <= 10 then + local dLength = EgtIf( DGD.bMM, abs(DGD.LENGTH), abs(DGD.LENGTH)/dCompare) + local dWidth = EgtIf( DGD.bMM, abs(DGD.WIDTH), abs(DGD.WIDTH)/dCompare) + EgtScale(nNewPart,{{0,0,0},{1,0,0},{0,1,0},{0,0,1}}, dWidth, dLength, 1, GDB_RT.GLOB) + end + end + + -- riloco tutti i nuovi layer dal nuovo pezzo al pezzo corrente + while nNewLayer do + -- verifico se esiste la nota hatch + bHatch = EgtGetInfo( nNewLayer, 'hatch', 'b') + nNewEnt = EgtGetFirstInGroup( nNewLayer) -- ottengo nuova entità + + while nNewEnt do + + -- controllo se ha dei colori e le note giuste per cambiare lo spessore + nTypeEnt = EgtGetType( nNewEnt) + sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor') + if not sDeltaPos then + sDeltaPos = EgtGetInfo( nNewEnt, 'DeltaPos') + end + cColor = EgtGetCalcColor( nNewEnt) + local sNoteKeepBs = EgtGetInfo( nNewEnt, 'KeepBackSet') + local sNoteProbes = EgtGetInfo( nNewEnt, 'ProbeSide') + + if sTypeInfo and cColor and DGD.dT then + if string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + if AreSameColor(cColor,RED(),30) then -- se colore rosso allora spessore completo + EgtModifyCurveThickness( nNewEnt, -DGD.dT) + elseif AreSameColor(cColor,LIME(),30) then -- se colore verde allora metà spessore + EgtModifyCurveThickness( nNewEnt, -(DGD.dT/2)) + if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if sNoteProbes then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + else -- altrimenti controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if sNoteProbes then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + end + elseif sTypeInfo and ( string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure') then + -- controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + if sNoteKeepBs then -- se ho assegnato la nota la ritrascrivo modificata + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if sNoteProbes then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + + EgtRelocateGlob( nNewEnt, Lg) -- riloco nel layer corrente + nNewEnt = EgtGetFirstInGroup(nNewLayer) + end + nNewLayer = EgtGetNext(nNewLayer) + end + + -- cancello il nuovo pezzo + EgtErase(nNewPart) + -- assegno la nota sulla posizione locale + if sDeltaPos then + EgtSetInfo( Lg, 'DeltaPos', sDeltaPos) + end + else + EC = ErrorBase + 2 + EM = string.format( EgtDoorsMsg[411], CustGeomFile, DGD.FILE) + end + + -- se non ho caricato il file geom esco + if not MakeFaceGeom then + + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + -- scrivo note nel layer + EgtSetInfo( Lg, 'Type' , 'ImportNgeFile') + EgtSetInfo( Lg, 'CustGeomFile' ,CustGeomFile) + EgtSetInfo( Lg, 'CustGeomPath' ,CustGeomPath) + EgtSetInfo( Lg, 'hatch' ,bHatch) + end + + return EC, EM, Lg +end + +return ImportNgeFile diff --git a/LuaLibs/LockMortiseCyl.lua b/LuaLibs/LockMortiseCyl.lua new file mode 100644 index 0000000..df66927 --- /dev/null +++ b/LuaLibs/LockMortiseCyl.lua @@ -0,0 +1,3506 @@ +-- +-- 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 +-- +-- LockMortiseCyl.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- serratura tipo mortise o cilindrica + +-- 2016.09.21 FM aggiunta messaggi di wanrning +-- 2017.06.16 V1.011 FM Disable check if screw interax < handle bore diam +-- 2017.06.16 V1.011 FM Is possible insert only screws bores without handle bore ( on keyway and secure side) +-- 2017.06.16 V1.011 FM Check if bore thickness > door thickness and modify if their thickness > door thickness +-- 2017.08.17 V1.012 FM Add Mounting screw, 10 more Extra bore on keyway side and 10 more Extra bore on secure side, +-- Add flag for not rotate Face on bevel profile +-- 2017.12.12 V1.013 FM Add parameter for rotate horizontal bore and manage a pre Bore before long dril +-- 2018.02.27 V1.014 FM Add vertical rectangle (5 on secure side and 5 on keyway side) +-- 2018.02.27 V1.014 FM Add vertical line (5 on secure side and 5 on keyway side) +-- 2018.02.28 V1.015 FM Manage new mode to allow mortise and 2 horizontah hole together and manage also old mode (only mortise or side holes) +-- 2018.03.01 V1.016 FM Fix bugs on new mode horizontal bores +-- 2018.04.06 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.10.22 V1.019 FM Manage better the big radius fillet parameter +-- 2018.10.22 V1.019 FM Add new parameter D_XE to move all geometries +-- 2018.10.22 V1.019 FM Manage new parameter reference (backset or door side) for keyway and secure extra geometries +-- 2018.11.21 V1.01a FM Manage inclinated slide machining on first keyway/secure custom bore +-- 2018.11.26 V1.01b FM Manage disposition also on top and bottom side +-- 2018.12.20 V1.01c FM Extend previous feature to different disposition/reference side assigned to paremeter DGD.SIDE: +-- top, lock_top, lock_bottom, bottom +-- 2019.01.14 V1.01d FM Fix error on assign wrong Mtable column if check .dl is set to force horizontal the face geometries on bevel edge +-- 2019.03.25 V1.01e FM Add 2nd horizontal bore and its pilot bore +-- 2019.05.22 V1.01f FM Manage anti-splint path on strike extra rectangle geometry +-- 2019.09.30 V1.020 FM Manage anti-splint path on anti-splint path +-- 2019.10.10 V1.021 FM Manage steel option (disable to generate pocket paths, mortise) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.28 V2.001 FM Add clean corner geometries +-- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.003 FM fix a bug on clean corner direction path in case main path turn reverse +-- 2020.04.29 V2.004 FM Update for aluminum material +-- 2020.05.25 V2.005 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.06.24 V2.006 FM Add new line of mounting screw bores +-- 2020.07.01 V2.007 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2020.10.28 V2.008 FM Add 3 mounting screw bore groups +-- 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 Check and adjust the angle parameter on ebtra rectangle and extra lines +-- 2021.03.24 V3.002 FM Fix error on check GD.SIDE with value lock_top +-- 2021.11.08 V3.003 FM Fix error on not disable jn parameter when face is not present +-- 2021.11.24 V3.004 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.20 V3.005 FM Use parameter .ITP (Internal Path) from template lua file instead of function EgtGetSourceDir(1) +-- 2022.07.27 V3.006 FM Modification to use compiled code +-- 2024.02.02 V3.007 FM Manage new geometry name suffix _HD, enabled by SideDoorDefined CurrCamInfo parameter, to applied on side geometry +-- when the lock is applied on side differeent than lock side +-- 2024.02.16 V3.008 FM Manage new parameter TPGxx on Extra Rect geometries to trim protruding geometry and leave open path ( for contouring machining), +-- or trim the protruding geometry and close the path with line (defined as OPEN) for pocketing machining ( into MakeAspOnStrikeRect function) +-- 2024.05.09 V3.009 FM Fix error on check parameter DGD.SIDE on setting suffix _HD (by DGD.SDF/SideDoorDefined parameter) +-- 2024.07.19 V3.00a FM Set note 'NotCheckDir' to pocketing and antisplint paths +-- 2024.10.02 V3.00b FM Manage probe geometry and their offset position when template is disposed on lock side +-- 2024.10.29 V3.00c FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local LockMortiseCyl = {} + +-- 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.25 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nLine = EgtLine(nGroup, pInitial, pFinal, nReference) + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , nReference) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function MakeRectWithFillet( Lg, P1, P2, Rf, Ang, bBigLength, est) + + local hint_3 = EgtRectangle2P( Lg, P1, P2, GDB_RT.LOC) + + if hint_3 then + + local nNewId, nNumEnt = EgtExplodeCurveCompo( hint_3) + + if nNewId and nNumEnt and nNumEnt > 0 then + + local pStartIni + + -- se devo inserire i raccordi + if Rf > 0 then + + local tIdFil = {} + local nLine + for p = 1, (nNumEnt-1) do + nLine = EgtCurveFillet( Lg, ( nNewId + p - 1), EgtEP( nNewId + p - 1), ( nNewId + p), EgtSP( nNewId + p), Rf, true) + table.insert( tIdFil, nLine) + end + nLine = EgtCurveFillet( Lg, ( nNewId + nNumEnt - 1), EgtEP( nNewId + nNumEnt - 1), nNewId, EgtSP(nNewId), Rf, true) + table.insert( tIdFil, nLine) + + if est then -- se materiale steel inizio sul lato più corto + if bBigLength then -- se lunghezza maggiore (in X) di altezza (in Y) + pStartIni = EgtMP( nNewId+1) + else -- lunghezza (in X) minore o uguale a altezza (in Y) + pStartIni = EgtMP( nNewId) + end + else -- altrimenti come fatto prima (sulla prima entità) + pStartIni = EgtMP( nNewId) + end + -- creo curvecompo + hint_3 = EgtCurveCompo( Lg, { nNewId, tIdFil[1], (nNewId+1), tIdFil[2], (nNewId+2), tIdFil[3], (nNewId+3), tIdFil[4]}, true) + else + if est then -- se materiale steel inizio sul lato più corto + if bBigLength then -- se lunghezza maggiore (in X) di altezza (in Y) + pStartIni = EgtMP( nNewId+1) + else -- lunghezza (in X) minore o uguale a altezza (in Y) + pStartIni = EgtMP( nNewId) + end + else -- altrimenti come fatto prima (sulla prima entità) + pStartIni = EgtMP( nNewId) + end + -- creo curvecompo + hint_3 = EgtCurveCompo( Lg, { nNewId, (nNewId+1), (nNewId+2), (nNewId+3)}, true) + end + + if hint_3 then + EgtChangeClosedCurveStartPoint( hint_3, pStartIni, GDB_RT.LOC) -- cambio punto di inizio + if Ang ~= 0 then + EgtRotate( hint_3, EgtGP( hint_3), Z_AX(), Ang, GDB_RT.LOC) -- ruoto + end + end + end + end + + return hint_3 +end + +local function MakeSlidePath( Lg, dX, dY, dDiam, dPlaneAng, dTiltAng, dStep) + + if dTiltAng == 0 or dTiltAng == 90 then + return + end + + local tPath = {} + local dCompAng = 90 - dTiltAng -- angolo complementare + + -- calcolo l'ampiezza della cava + local dLung = dDiam / sin(dCompAng) + local dMaxDepth = (dDiam / cos(dCompAng)) - ( dDiam * tan(dCompAng)) + local nStep = ceil(dMaxDepth/dStep) + -- ricalcolo i passi in modo che siano dispari + nStep = EgtIf( fmod(nStep,2) > 0, nStep, nStep + 1) + local dStep = dMaxDepth/nStep + local nInv = 1 + local pIni, pEnd + + pIni = Point3d( 0, 0, 0) + + for g = 1, nStep do + + -- determino l'ingresso + if nInv > 0 then -- se positivo ingresso perpendicolare + pEnd = Point3d( pIni:getX(), 0, -(dStep*g)) + else + pEnd = Point3d( pIni:getX()-(dStep/tan(dCompAng)), 0, -(dStep*g)) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, false, nil, (dDiam/2), false, true, ORANGE(), ORANGE()) + pIni = pEnd + + -- determino la passata + local dLength = 1 + if nInv > 0 then -- se positivo + dLength = ( dLung - dDiam - ((dStep*g)/tan(dCompAng))) + pEnd = Point3d( (pIni:getX() + dLength), 0, pIni:getZ()) + else + pEnd = Point3d( 0, 0, pIni:getZ()) + end + if dLength > 0 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, false, nil, (dDiam/2), false, true, ORANGE(), ORANGE()) + end + pIni = pEnd + + -- inverto il senso di lavorazione + nInv = -nInv + end + + -- uscita inclinata + pEnd = Point3d( pIni:getX()+(((dStep*nStep)+0.5)/tan(dCompAng)), 0, 0.5) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, false, nil, (dDiam/2), false, true, ORANGE(), ORANGE()) + pIni = pEnd + local hint_3 + + -- se il percorso esiste + if tPath then + + hint_3 = EgtCurveCompo( Lg, tPath, true) + + if hint_3 then -- se il percorso esiste lo ruoto e lo posiziono + if dPlaneAng ~= 0 then -- se l'angolo non è nullo lo ruoto + EgtRotate( hint_3, Point3d(0,0,0), Z_AX(), dPlaneAng, GDB_RT.LOC) -- ruoto + end + EgtMove( hint_3, Point3d(dX,dY,0) - ORIG()) + end + end + + return hint_3 +end + +local function MakeAspOnStrikeRect( Lg, nHint, dX, dY, dThick, + dDoorTh, dShiftX, dShiftY, bRefSide, dBack_set, + dDiam, bOpposite, dZedPos, dDiam2, sSideLock, + Fc, Tpg) + + local nLine + local ptIni, ptEnd, pInt1, pInt1, ptIni2, ptEnd2 + local tPath = {} + local nPath1, nPath2, nPath3, nPath4 + local nInv = 1 + local dLocDiam = dDiam + + if not dBack_set then dBack_set = 0 end + + -- se ho il lato aperto ma non ho selezionato l'amtisplint setto un valore minimo al diametro + if ( Tpg and Tpg > 0) and not dLocDiam then + dLocDiam = 1 + end + + -- creo la linea + ptIni = Point3d( (dShiftX - max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + ptEnd = Point3d( (dShiftX + max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + nLine = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dLocDiam/2), true, true, ORANGE(), ORANGE()) + + if nLine then + + -- verifico se ci sono intersezioni + pInt1 = EgtIP( nLine, nHint, ptIni) + pInt2 = EgtIP( nLine, nHint, ptEnd) + + -- se ci sono entrambe i punti e la loro distanza è maggiore del diametro fresa + if pInt1 and pInt2 then + + local dDist = dist( pInt1, pInt2) + + if dDiam and dDist>= dDiam then -- se larghezza maggiore dell'utensile + + -- imposto la griglia + if bOpposite then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + nInv = -1 + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + end + + ptIni = Point3d( (pInt1:getX() + (dDiam/2) - dExtraH)*nInv, dDiam*3/4, -pInt1:getY()) + if dDiam2 then + ptIni2 = Point3d( (pInt1:getX() + (dDiam2/2) - dExtraH)*nInv, dDiam2*3/4, -pInt1:getY()) + end + + if dDoorTh - dThick > GEO.EPS_SMALL then -- se spessore non passante + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick + (dDiam/2) - dExtraH, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick + (dDiam2/2) - dExtraH, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- se spessore passante + + if (dDist - dDiam) < 2*dDiam then -- se larghezza minore del doppio diametro utensile + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- larghezza maggiore del doppio diametro, creao due linee distinte + + -- creo 2 persorsi composti da una linea ciascuno + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + nPath1 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptEnd:getY(), -pInt2:getY()) + ptEnd = Point3d( ptIni:getX(), (dDiam*3/4), ptIni:getZ()) + nPath2 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + if dDiam2 then + -- creo 2 persorsi composti da una linea ciascuno + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + nPath3 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptEnd2:getY(), -pInt2:getY()) + ptEnd2 = Point3d( ptIni2:getX(), (dDiam2*3/4), ptIni2:getZ()) + nPath4 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + end + end + end + end + + if dDist>= dLocDiam then -- se larghezza maggiore dell'utensile + -- se c'è il flag per tagliare la geometria che sborda dalla porta + if Tpg and Tpg > 0 then + -- verifico se posso tagliare il percorso con i punti di intersezione + -- setto il punto di partenza + if bOpposite then + -- setto il pnto di partenza vicino al punto finale + if EgtChangeClosedCurveStartPoint( nHint, pInt1) then + local SecondPath = EgtSplitCurveAtPoint( nHint, pInt2) + if SecondPath then + EgtErase( SecondPath) + end + -- se opzione di svuotatura chiudo il percorso iniziale con una linea e segno l'entità nelle note open del percorso + if Tpg == 1 then + EgtCloseCurveCompo( nHint) + local nNumEnt1, nNumEnt2 = EgtCurveDomain( nHint) + if nNumEnt2 > 1 then + EgtSetInfo( nHint, 'OPEN', nNumEnt2-1) + end + end + end + else + -- setto il pnto di partenza vicino al punto iniziale + if EgtChangeClosedCurveStartPoint( nHint, pInt2) then + local SecondPath = EgtSplitCurveAtPoint( nHint, pInt1) + if SecondPath then + EgtErase( SecondPath) + end + -- se opzione di svuotatura chiudo il percorso iniziale con una linea e segno l'entità nelle note open del percorso + if Tpg == 1 then + EgtCloseCurveCompo( nHint) + local nNumEnt1, nNumEnt2 = EgtCurveDomain( nHint) + if nNumEnt2 > 1 then + EgtSetInfo( nHint, 'OPEN', nNumEnt2-1) + end + end + end + end + end + end + + -- se esistono gli eventuali percorso setto spessore 0 + if nPath1 then + EgtModifyCurveThickness(nPath1, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + end + if nPath2 then + EgtModifyCurveThickness(nPath2, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + end + if nPath3 then + EgtModifyCurveThickness(nPath3, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + end + if nPath4 then + EgtModifyCurveThickness(nPath4, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + end + + -- re-imposto la griglia da sopra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + -- elimino la linea + EgtErase(nLine) + end + + return nPath1, nPath2, nPath3, nPath4 +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function LockMortiseCyl.AdjustParams( tMhPar) + + tMhPar.invG = 1 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 -- per face chisel o materiale diverso da wood + local dMaxMat1 -- per face machining + local dMaxMat2 -- per mortise machining o foro profondo + local dMaxMat3 -- per 2nd foro profondo + local dMaxMat4 -- per mounting screw + local dMaxMat10 -- per mounting screw + local dMaxMat11 -- per mounting screw + local dMaxMat12 -- per mounting screw + local dMaxMat13 -- per mounting screw + local dMaxMat5 -- per preforo + local dMaxMat7 -- per 2nd preforo + local dMaxMat8 -- per antisplint su extra-rettangolo + local dMaxMat9 -- per antisplint su antisplint + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local nTempT5 + local nTempT6 + local nTempT7 + local nTempT8 + local nTempT9 + local nTempT10 + local nTempT11 + local nTempT12 + local nTempT13 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local sMchngName5 + local sMchngName6 + local sMchngName7 + local sMchngName8 + local sMchngName9 + local sMchngName10 + local sMchngName11 + local sMchngName12 + local sMchngName13 + local dOffset = DGD.OFFSET or 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 DGD.nTypePz == 3 or DGD.nTypePz == 4 then + tMhPar.dThD = DGD.dW + tMhPar.TTP = DGD.dW -- setto come valore iniziale, poi se è abilitata le generazione si setta con il giusto valore + elseif DGD.nTypePz == 5 or DGD.nTypePz == 6 then + tMhPar.dThD = DGD.dH + tMhPar.TTP = DGD.dH -- setto come valore iniziale, poi se è abilitata le generazione si setta con il giusto valore + elseif DGD.nTypePz <= 2 then + tMhPar.dThD = DGD.dT + tMhPar.TTP = DGD.dT + end + tMhPar.TyP = DGD.nTypePz + + -- do errore se il tipo di giunzione flushbolt non è adatto per il tipo di porta ( inactive) + if tMhPar.Type and string.lower(tMhPar.Type) == 'flushbolt' and + not( DGD.sSwing == 'LHI' or DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI' or DGD.sSwing == 'LHRI') then + return tMhPar, 1798, string.format(EgtDoorsMsg[458], tMhPar.Type, DGD.sSwing) + end + + -- do errore se profilo lock è tipo bullnose e/o convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or + DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') and + ( not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom') then + return tMhPar, 1799, string.format(EgtDoorsMsg[430], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se profilo bevel disabilito la giunzione tra face e mortise + if ( DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' ) and + ( not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom') then + tMhPar.jnb = false + -- setto il flag che indica profilo bevel + tMhPar.bev = true + else + tMhPar.jnb = true + end + + -- se serratura su lato destro setto il flag per invertire i percorsi + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + tMhPar.SL = DGD.Lock + + if tMhPar.dl and tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.jnb then + -- se non ruoto face risetto il flag che impedisce il chain tra face e mortise + tMhPar.jnb = true + -- ricalcolo la profondità per avere spessore minimo = al valore di .T + tMhPar.T = tMhPar.T + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + else + tMhPar.dl = false + end + + --se non è presente il face ed è attivo il join lo disabilito + if ( not tMhPar.L or not tMhPar.H or not tMhPar.LM) and tMhPar.jn then + tMhPar.jn = false -- disattivo il join tra face e mortasa + end + + -- se non ho il parametro di abilitazione chisel lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template è applicato sul lato top o bottom, attivo il suffisso per tutte le geometrie sul lato + tMhPar.HD = '' + if DGD.SDF and DGD.SDF > 1 and ( DGD.SIDE == 'top' or DGD.SIDE == 'bottom') then + tMhPar.HD = '_HD' + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template non è sui lati top e bottom + elseif DGD.SDF and DGD.SDF > 1 then + + -- calcolo la posizione del centro foro sullo spessore porta + if dOffset > 0 then + if DGD.Push then + tMhPar.posh = (DGD.dT/2) - dOffset + else + tMhPar.posh = -(DGD.dT/2) + dOffset + end + else + tMhPar.posh = 0 + end + + if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + + -- se non ho il parametro di arrotondamento lati lo setto disabilitato + if not tMhPar.cl then + tMhPar.cl = 0 + end + + -- se arrotondo entrambe le estremità disabilito il chisel e il clean corner + if tMhPar.cl == 3 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.cl > 0 and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- se non c'è il parametro angolo foro lo setto a 0 + if not tMhPar.AB then + tMhPar.AB = 0 + elseif abs(tMhPar.AB) >= 80 then + tMhPar.AB = 0 + end + + -- se non c'è il parametro angolo foro lo setto a 0 + if not tMhPar.AB2 then + tMhPar.AB2 = 0 + elseif abs(tMhPar.AB2) >= 80 then + tMhPar.AB2 = 0 + end + + -- se non c'è il parametro di profondità preforo lo setto a -1 + if not tMhPar.FBP then + tMhPar.FBP = -1 + end + + -- se non c'è il parametro di profondità preforo lo setto a -1 + if not tMhPar.FBP2 then + tMhPar.FBP2 = -1 + end + + -- se non c'è il parametro di diametro preforo lo setto a 0 + if not tMhPar.FBD then + tMhPar.FBD = 0 + end + + -- se non c'è il parametro di diametro preforo lo setto a 0 + if not tMhPar.FBD2 then + tMhPar.FBD2 = 0 + end + + if tMhPar.FBP >= 0 then -- se ha un valore lo ricalcolo perché il valore indica la profondità minima + -- se ho il diametro e l'angolo è maggiore di zero + if tMhPar.FBD > 0 and abs(tMhPar.AB) >= 0 then + tMhPar.FBP = tMhPar.FBP + ( ( tMhPar.FBD / tan( 90 - abs(tMhPar.AB))) / 2) + if tMhPar.FBP < GEO.EPS_SMALL then -- se la profondità calcolata è zero lo annullo + tMhPar.FBD = 0 + tMhPar.FBP = -1 + end + -- se il diametro è valido e di conseguenza l'angolo è a zero, annullo in diametro per non fare il foro. + elseif tMhPar.FBD > 0 then + tMhPar.FBD = 0 + tMhPar.FBP = -1 + end + end + + if tMhPar.FBP2 >= 0 then -- se ha un valore lo ricalcolo perché il valore indica la profondità minima + -- se ho il diametro e l'angolo è maggiore di zero + if tMhPar.FBD2 > 0 and abs(tMhPar.AB2) >= 0 then + tMhPar.FBP2 = tMhPar.FBP2 + ( ( tMhPar.FBD2 / tan( 90 - abs(tMhPar.AB2))) / 2) + if tMhPar.FBP2 < GEO.EPS_SMALL then -- se la profondità calcolata è zero lo annullo + tMhPar.FBD2 = 0 + tMhPar.FBP2 = -1 + end + -- se il diametro è valido e di conseguenza l'angolo è a zero, annullo in diametro per non fare il foro. + elseif tMhPar.FBD2 > 0 then + tMhPar.FBD2 = 0 + tMhPar.FBP2 = -1 + end + end + + -- se c'è il parametro delta Y delle mounting screw e la porta è a tirare, inverto il valore dell'offset + if tMhPar.PY9 then + if not DGD.Push then + tMhPar.PY9 = - tMhPar.PY9 + end + end + if tMhPar.PY41 then + if not DGD.Push then + tMhPar.PY41 = - tMhPar.PY41 + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM -- face machining + local nLMi = 1 + local sLA -- mortise machining + local nLAi = 1 + local sLGH -- bore machining + local nLGHi = 1 + local sLGH2 -- 2nd bore machining + local nLGH2i = 1 + local sLG -- face chiseling or other material + local nLGi = 1 + local sLMS1 -- mounting screws machining + local sLMS2 -- mounting screws machining + local sLMS3 -- mounting screws machining + local sLMS4 -- mounting screws machining + local sLMS5 -- mounting screws machining + local nLMSi = 1 + local sLMP -- prebore machining + local nLMPi = 1 + local sLMP2 -- 2nd prebore machining + local nLMP2i = 1 + local sASG -- anti-splint on extra rectangle + local nASGi = 1 + local sASGR -- anti-splint on antisplint + local nASGRi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + tMhPar.ASG = 0 + tMhPar.EAR = nil + tMhPar.das = nil + else + tMhPar.est = nil + end + + -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere + if ( DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB') and not tMhPar.dl then -- profilo serrratura bevel up e non è forzato come mortise + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLGi = 3 + nLMi = 3 + else + nLGi = 2 + nLMi = 2 + end + elseif ( DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB') and not tMhPar.dl then -- profilo serrratura bevel dn e non è forzato come mortise + -- se lato cerniere opposto mi troverò il bevel al contrario perché comanda il lato cerniere + if DGD.bBothOppoBevel then + nLGi = 2 + nLMi = 2 + else + nLGi = 3 + nLMi = 3 + end + end + + if tMhPar.est and tMhPar.LG then -- se altro materiale + sLG = tMhPar.LG .. tMhPar.HD + if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LM then + sLM = tMhPar.LM .. tMhPar.HD + if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH .. tMhPar.HD + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LA then -- mortasa + sLA = tMhPar.LA .. tMhPar.HD + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end + end + + -- foro o foro profondo + if tMhPar.mh and tMhPar.LGH then + sLGH = tMhPar.LGH .. tMhPar.HD + if DGD.MachEn > 0 then nTempT3, dMaxMat2, sMchngName3 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end + end + + -- secondo foro o secondo foro profondo + if tMhPar.mh2 and tMhPar.LGH2 then + sLGH2 = tMhPar.LGH2 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT6, dMaxMat3, sMchngName6 = MB.GetToolDataFromAttrib( sLGH2, nLGH2i) end + end + + -- mounting screws + if tMhPar.LMS then + sLMS1 = tMhPar.LMS .. tMhPar.HD + if DGD.MachEn > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLMS1, nLMSi) end + end + if tMhPar.LMS41 then + sLMS2 = tMhPar.LMS41 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT10, dMaxMat10, sMchngName10 = MB.GetToolDataFromAttrib( sLMS2, nLMSi) end + end + if tMhPar.LMS42 then + sLMS3 = tMhPar.LMS42 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT11, dMaxMat11, sMchngName11 = MB.GetToolDataFromAttrib( sLMS3, nLMSi) end + end + if tMhPar.LMS43 then + sLMS4 = tMhPar.LMS43 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT12, dMaxMat12, sMchngName12 = MB.GetToolDataFromAttrib( sLMS4, nLMSi) end + end + if tMhPar.LMS44 then + sLMS5 = tMhPar.LMS44 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT13, dMaxMat13, sMchngName13 = MB.GetToolDataFromAttrib( sLMS5, nLMSi) end + end + + -- preforo + if tMhPar.mh and tMhPar.LMP and tMhPar.FBP > GEO.EPS_SMALL then + sLMP = tMhPar.LMP .. tMhPar.HD + if DGD.MachEn > 0 then nTempT5, dMaxMat5, sMchngName5 = MB.GetToolDataFromAttrib( sLMP, nLMPi) end + end + + -- secondo preforo + if tMhPar.mh2 and tMhPar.LMP2 and tMhPar.FBP2 > GEO.EPS_SMALL then + sLMP2 = tMhPar.LMP2 .. tMhPar.HD + if DGD.MachEn > 0 then nTempT7, dMaxMat7, sMchngName7 = MB.GetToolDataFromAttrib( sLMP2, nLMP2i) end + end + + -- vertical bores parameters + if tMhPar.T3 then + if tMhPar.T3 == -0.5 then + tMhPar.T3 = DGD.dT / 2 + elseif tMhPar.T3 == -1 or tMhPar.T3 > DGD.dT then + tMhPar.T3 = DGD.dT + end + end + + if tMhPar.T4 then + if tMhPar.T4 == -0.5 then + tMhPar.T4 = DGD.dT / 2 + elseif tMhPar.T4 == -1 or tMhPar.T4 > DGD.dT then + tMhPar.T4 = DGD.dT + end + end + + if tMhPar.T5 then + if tMhPar.T5 == -0.5 then + tMhPar.T5 = DGD.dT / 2 + elseif tMhPar.T5 == -1 or tMhPar.T5 > DGD.dT then + tMhPar.T5 = DGD.dT + end + end + + if tMhPar.T6 then + if tMhPar.T6 == -0.5 then + tMhPar.T6 = DGD.dT / 2 + elseif tMhPar.T6 == -1 or tMhPar.T6 > DGD.dT then + tMhPar.T6 = DGD.dT + end + end + + if tMhPar.T7 then + if tMhPar.T7 == -0.5 then + tMhPar.T7 = DGD.dT / 2 + elseif tMhPar.T7 == -1 or tMhPar.T7 > DGD.dT then + tMhPar.T7 = DGD.dT + end + end + + if tMhPar.T8 then + if tMhPar.T8 == -0.5 then + tMhPar.T8 = DGD.dT / 2 + elseif tMhPar.T8 == -1 or tMhPar.T8 > DGD.dT then + tMhPar.T8 = DGD.dT + end + end + + -- extra bores + if tMhPar.T10 then + if tMhPar.T10 == -0.5 then + tMhPar.T10 = DGD.dT / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > DGD.dT then + tMhPar.T10 = DGD.dT + end + end + + -- inclinated slide on first extra bore + if tMhPar.AP10 and not tMhPar.est then + while tMhPar.AP10 > 360 do + tMhPar.AP10 = tMhPar.AP10 - 360 + end + while tMhPar.AP10 < -360 do + tMhPar.AP10 = tMhPar.AP10 + 360 + end + else + tMhPar.AP10 = nil + end + + if tMhPar.TA10 and not tMhPar.est then + if tMhPar.TA10 > 85 then -- se superiore a 80 gradi lo setto la max 80 gradi + tMhPar.TA10 = 85 + end + if tMhPar.TA10 > 0 and tMhPar.TA10 < 5 then -- se inferiore di 10 gradi lo setto al minimo di 10 gradi + tMhPar.TA10 = 5 + end + if tMhPar.TA10 < -85 then -- se superiore a 80 gradi lo setto la max 80 gradi + tMhPar.TA10 = -85 + end + if tMhPar.TA10 < 0 and tMhPar.TA10 > -5 then -- se inferiore di -10 gradi lo setto al minimo di -10 gradi + tMhPar.TA10 = -5 + end + else + tMhPar.TA10 = nil + end + + if tMhPar.T11 then + if tMhPar.T11 == -0.5 then + tMhPar.T11 = DGD.dT / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > DGD.dT then + tMhPar.T11 = DGD.dT + end + end + + if tMhPar.T12 then + if tMhPar.T12 == -0.5 then + tMhPar.T12 = DGD.dT / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > DGD.dT then + tMhPar.T12 = DGD.dT + end + end + + if tMhPar.T13 then + if tMhPar.T13 == -0.5 then + tMhPar.T13 = DGD.dT / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > DGD.dT then + tMhPar.T13 = DGD.dT + end + end + + if tMhPar.T14 then + if tMhPar.T14 == -0.5 then + tMhPar.T14 = DGD.dT / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > DGD.dT then + tMhPar.T14 = DGD.dT + end + end + + if tMhPar.T15 then + if tMhPar.T15 == -0.5 then + tMhPar.T15 = DGD.dT / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > DGD.dT then + tMhPar.T15 = DGD.dT + end + end + + if tMhPar.T16 then + if tMhPar.T16 == -0.5 then + tMhPar.T16 = DGD.dT / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > DGD.dT then + tMhPar.T16 = DGD.dT + end + end + + if tMhPar.T17 then + if tMhPar.T17 == -0.5 then + tMhPar.T17 = DGD.dT / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > DGD.dT then + tMhPar.T17 = DGD.dT + end + end + + if tMhPar.T18 then + if tMhPar.T18 == -0.5 then + tMhPar.T18 = DGD.dT / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > DGD.dT then + tMhPar.T18 = DGD.dT + end + end + + if tMhPar.T19 then + if tMhPar.T19 == -0.5 then + tMhPar.T19 = DGD.dT / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > DGD.dT then + tMhPar.T19 = DGD.dT + end + end + + if tMhPar.T20 then + if tMhPar.T20 == -0.5 then + tMhPar.T20 = DGD.dT / 2 + elseif tMhPar.T20 == -1 or tMhPar.T20 > DGD.dT then + tMhPar.T20 = DGD.dT + end + end + + -- inclinated slide on first extra bore + if tMhPar.AP20 and not tMhPar.est then + while tMhPar.AP20 > 360 do + tMhPar.AP20 = tMhPar.AP20 - 360 + end + while tMhPar.AP20 < -360 do + tMhPar.AP20 = tMhPar.AP20 + 360 + end + else + tMhPar.AP20 = nil + end + + if tMhPar.TA20 and not tMhPar.est then + if tMhPar.TA20 > 85 then -- se superiore a 80 gradi lo setto la max 80 gradi + tMhPar.TA20 = 85 + end + if tMhPar.TA20 > 0 and tMhPar.TA20 < 5 then -- se inferiore di 10 gradi lo setto al minimo di 10 gradi + tMhPar.TA20 = 5 + end + if tMhPar.TA20 < -85 then -- se superiore a 80 gradi lo setto la max 80 gradi + tMhPar.TA20 = -85 + end + if tMhPar.TA20 < 0 and tMhPar.TA20 > -5 then -- se inferiore di -10 gradi lo setto al minimo di -10 gradi + tMhPar.TA20 = -5 + end + else + tMhPar.TA20 = nil + end + + if tMhPar.T21 then + if tMhPar.T21 == -0.5 then + tMhPar.T21 = DGD.dT / 2 + elseif tMhPar.T21 == -1 or tMhPar.T21 > DGD.dT then + tMhPar.T21 = DGD.dT + end + end + + if tMhPar.T22 then + if tMhPar.T22 == -0.5 then + tMhPar.T22 = DGD.dT / 2 + elseif tMhPar.T22 == -1 or tMhPar.T22 > DGD.dT then + tMhPar.T22 = DGD.dT + end + end + + if tMhPar.T23 then + if tMhPar.T23 == -0.5 then + tMhPar.T23 = DGD.dT / 2 + elseif tMhPar.T23 == -1 or tMhPar.T23 > DGD.dT then + tMhPar.T23 = DGD.dT + end + end + + if tMhPar.T24 then + if tMhPar.T24 == -0.5 then + tMhPar.T24 = DGD.dT / 2 + elseif tMhPar.T24 == -1 or tMhPar.T24 > DGD.dT then + tMhPar.T24 = DGD.dT + end + end + + if tMhPar.T25 then + if tMhPar.T25 == -0.5 then + tMhPar.T25 = DGD.dT / 2 + elseif tMhPar.T25 == -1 or tMhPar.T25 > DGD.dT then + tMhPar.T25 = DGD.dT + end + end + + if tMhPar.T26 then + if tMhPar.T26 == -0.5 then + tMhPar.T26 = DGD.dT / 2 + elseif tMhPar.T26 == -1 or tMhPar.T26 > DGD.dT then + tMhPar.T26 = DGD.dT + end + end + + if tMhPar.T27 then + if tMhPar.T27 == -0.5 then + tMhPar.T27 = DGD.dT / 2 + elseif tMhPar.T27 == -1 or tMhPar.T27 > DGD.dT then + tMhPar.T27 = DGD.dT + end + end + + if tMhPar.T28 then + if tMhPar.T28 == -0.5 then + tMhPar.T28 = DGD.dT / 2 + elseif tMhPar.T28 == -1 or tMhPar.T28 > DGD.dT then + tMhPar.T28 = DGD.dT + end + end + + if tMhPar.T29 then + if tMhPar.T29 == -0.5 then + tMhPar.T29 = DGD.dT / 2 + elseif tMhPar.T29 == -1 or tMhPar.T29 > DGD.dT then + tMhPar.T29 = DGD.dT + end + end + + -- extra rectangles + if tMhPar.TR10 then + if tMhPar.TR10 == -0.5 then + tMhPar.TR10 = DGD.dT / 2 + elseif tMhPar.TR10 == -1 or tMhPar.TR10 > DGD.dT then + tMhPar.TR10 = DGD.dT + end + end + + if tMhPar.TR11 then + if tMhPar.TR11 == -0.5 then + tMhPar.TR11 = DGD.dT / 2 + elseif tMhPar.TR11 == -1 or tMhPar.TR11 > DGD.dT then + tMhPar.TR11 = DGD.dT + end + end + + if tMhPar.TR12 then + if tMhPar.TR12 == -0.5 then + tMhPar.TR12 = DGD.dT / 2 + elseif tMhPar.TR12 == -1 or tMhPar.TR12 > DGD.dT then + tMhPar.TR12 = DGD.dT + end + end + + if tMhPar.TR13 then + if tMhPar.TR13 == -0.5 then + tMhPar.TR13 = DGD.dT / 2 + elseif tMhPar.TR13 == -1 or tMhPar.TR13 > DGD.dT then + tMhPar.TR13 = DGD.dT + end + end + + if tMhPar.TR14 then + if tMhPar.TR14 == -0.5 then + tMhPar.TR14 = DGD.dT / 2 + elseif tMhPar.TR14 == -1 or tMhPar.TR14 > DGD.dT then + tMhPar.TR14 = DGD.dT + end + end + + if tMhPar.TR20 then + if tMhPar.TR20 == -0.5 then + tMhPar.TR20 = DGD.dT / 2 + elseif tMhPar.TR20 == -1 or tMhPar.TR20 > DGD.dT then + tMhPar.TR20 = DGD.dT + end + end + + if tMhPar.TR21 then + if tMhPar.TR21 == -0.5 then + tMhPar.TR21 = DGD.dT / 2 + elseif tMhPar.TR21 == -1 or tMhPar.TR21 > DGD.dT then + tMhPar.TR21 = DGD.dT + end + end + + if tMhPar.TR22 then + if tMhPar.TR22 == -0.5 then + tMhPar.TR22 = DGD.dT / 2 + elseif tMhPar.TR22 == -1 or tMhPar.TR22 > DGD.dT then + tMhPar.TR22 = DGD.dT + end + end + + if tMhPar.TR23 then + if tMhPar.TR23 == -0.5 then + tMhPar.TR23 = DGD.dT / 2 + elseif tMhPar.TR23 == -1 or tMhPar.TR23 > DGD.dT then + tMhPar.TR23 = DGD.dT + end + end + + if tMhPar.TR24 then + if tMhPar.TR24 == -0.5 then + tMhPar.TR24 = DGD.dT / 2 + elseif tMhPar.TR24 == -1 or tMhPar.TR24 > DGD.dT then + tMhPar.TR24 = DGD.dT + end + end + + -- Anti-splint su extra rettangoli + if DGD.MachEn > 0 and tMhPar.ASG and tMhPar.EAR and + ( ( tMhPar.TR10 and tMhPar.TR10 > GEO.EPS_SMALL) or ( tMhPar.TR11 and tMhPar.TR11 > GEO.EPS_SMALL) or ( tMhPar.TR12 and tMhPar.TR12 > GEO.EPS_SMALL) or + ( tMhPar.TR13 and tMhPar.TR13 > GEO.EPS_SMALL) or ( tMhPar.TR14 and tMhPar.TR14 > GEO.EPS_SMALL) or ( tMhPar.TR20 and tMhPar.TR20 > GEO.EPS_SMALL) or + ( tMhPar.TR21 and tMhPar.TR21 > GEO.EPS_SMALL) or ( tMhPar.TR22 and tMhPar.TR22 > GEO.EPS_SMALL) or ( tMhPar.TR23 and tMhPar.TR23 > GEO.EPS_SMALL) or + ( tMhPar.TR24 and tMhPar.TR24 > GEO.EPS_SMALL)) then + sASG = tMhPar.ASG + nTempT8, dMaxMat8, sMchngName8 = MB.GetToolDataFromAttrib( sASG, nASGi) + end + + -- Anti-splint su Anti-splint + if DGD.MachEn > 0 and tMhPar.EAR and tMhPar.EAR == 2 and sASG then + sASGR = tMhPar.ASG..'_R' + tMhPar.ASGR = sASGR + tMhPar.das2 = tMhPar.das + nTempT9, dMaxMat9, sMchngName9 = MB.GetToolDataFromAttrib( sASGR, nASGRi) + end + + -- extra lines + if tMhPar.TL10 then + if tMhPar.TL10 == -0.5 then + tMhPar.TL10 = DGD.dT / 2 + elseif tMhPar.TL10 == -1 or tMhPar.TL10 > DGD.dT then + tMhPar.TL10 = DGD.dT + end + end + + if tMhPar.TL11 then + if tMhPar.TL11 == -0.5 then + tMhPar.TL11 = DGD.dT / 2 + elseif tMhPar.TL11 == -1 or tMhPar.TL11 > DGD.dT then + tMhPar.TL11 = DGD.dT + end + end + + if tMhPar.TL12 then + if tMhPar.TL12 == -0.5 then + tMhPar.TL12 = DGD.dT / 2 + elseif tMhPar.TL12 == -1 or tMhPar.TL12 > DGD.dT then + tMhPar.TL12 = DGD.dT + end + end + + if tMhPar.TL13 then + if tMhPar.TL13 == -0.5 then + tMhPar.TL13 = DGD.dT / 2 + elseif tMhPar.TL13 == -1 or tMhPar.TL13 > DGD.dT then + tMhPar.TL13 = DGD.dT + end + end + + if tMhPar.TL14 then + if tMhPar.TL14 == -0.5 then + tMhPar.TL14 = DGD.dT / 2 + elseif tMhPar.TL14 == -1 or tMhPar.TL14 > DGD.dT then + tMhPar.TL14 = DGD.dT + end + end + + if tMhPar.TL20 then + if tMhPar.TL20 == -0.5 then + tMhPar.TL20 = DGD.dT / 2 + elseif tMhPar.TL20 == -1 or tMhPar.TL20 > DGD.dT then + tMhPar.TL20 = DGD.dT + end + end + + if tMhPar.TL21 then + if tMhPar.TL21 == -0.5 then + tMhPar.TL21 = DGD.dT / 2 + elseif tMhPar.TL21 == -1 or tMhPar.TL21 > DGD.dT then + tMhPar.TL21 = DGD.dT + end + end + + if tMhPar.TL22 then + if tMhPar.TL22 == -0.5 then + tMhPar.TL22 = DGD.dT / 2 + elseif tMhPar.TL22 == -1 or tMhPar.TL22 > DGD.dT then + tMhPar.TL22 = DGD.dT + end + end + + if tMhPar.TL23 then + if tMhPar.TL23 == -0.5 then + tMhPar.TL23 = DGD.dT / 2 + elseif tMhPar.TL23 == -1 or tMhPar.TL23 > DGD.dT then + tMhPar.TL23 = DGD.dT + end + end + + if tMhPar.TL24 then + if tMhPar.TL24 == -0.5 then + tMhPar.TL24 = DGD.dT / 2 + elseif tMhPar.TL24 == -1 or tMhPar.TL24 > DGD.dT then + tMhPar.TL24 = DGD.dT + end + end + + -- percorso custom nge + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + 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 <= 0 then + dNumLog = -1794 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili per face machining + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + -- gestisco il risultato della lettura utensili per mortise machining + if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + end + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + -- gestisco il risultato della lettura utensili per antischeggia su extra rettangoli + if DGD.bProoduce and not tMhPar.est and tMhPar.das and nTempT8 and nTempT8 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT8, sASG, nASGi, tMhPar.das, dNumLog, sMchngName8) + elseif not tMhPar.est and nTempT8 then + tMhPar.das = nTempT8 + end + + -- gestisco il risultato della lettura utensili per antischeggia su antischeggia + if DGD.bProoduce and not tMhPar.est and tMhPar.das2 and nTempT9 and nTempT9 <= 0 then + dNumLog = -1794 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT9, sASGR, nASGRi, tMhPar.das2, dNumLog, sMchngName9) + elseif not tMhPar.est and nTempT9 then + tMhPar.das2 = nTempT9 + end + + -- primo foro orizzontale + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per foro profondo + if DGD.bProoduce and tMhPar.mh and sLGH and not dMaxMat2 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLGH, nLGHi, nil, dNumLog, sMchngName3) + end + + -- primo pre-foro orizzontale + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per preforo + if DGD.bProoduce and tMhPar.mh and sLMP and not dMaxMat5 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT5, sLMP, nLMPi, nil, dNumLog, sMchngName5) + end + + -- secondo foro orizzontale + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per foro profondo + if DGD.bProoduce and tMhPar.mh2 and sLGH2 and not dMaxMat3 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT6, sLGH2, nLGH2i, nil, dNumLog, sMchngName6) + end + + -- secondo pre-foro orizzontale + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per preforo + if DGD.bProoduce and tMhPar.mh2 and sLMP2 and not dMaxMat7 then + dNumLog = -1793 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT7, sLMP2, nLMP2i, nil, dNumLog, sMchngName7) + end + + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per mounting screw + if DGD.bProoduce and sLMS1 and not dMaxMat4 then + dNumLog = -1792 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLMS1, nLMSi, nil, dNumLog, sMchngName4) + end + if DGD.bProoduce and sLMS2 and not dMaxMat10 then + dNumLog = -1792 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT10, sLMS2, nLMSi, nil, dNumLog, sMchngName10) + end + if DGD.bProoduce and sLMS3 and not dMaxMat11 then + dNumLog = -1792 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT11, sLMS3, nLMSi, nil, dNumLog, sMchngName11) + end + if DGD.bProoduce and sLMS4 and not dMaxMat12 then + dNumLog = -1792 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT12, sLMS4, nLMSi, nil, dNumLog, sMchngName12) + end + if DGD.bProoduce and sLMS5 and not dMaxMat13 then + dNumLog = -1792 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT13, sLMS5, nLMSi, nil, dNumLog, sMchngName13) + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + 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 = -1790 + 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 = -1797 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and ( not tMhPar.mh or ( tMhPar.mh and tMhPar.TB2)) and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -1796 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if ( not tMhPar.jn or not tMhPar.jnb) and not tMhPar.mh and + tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1795 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + + -- se primo foro e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and dMaxMat2 then + if tMhPar.TB2 and tMhPar.TB2 > dMaxMat2 then + dNumLog = -1795 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(dMaxMat2)) + tMhPar.TB2 = dMaxMat2 + elseif tMhPar.T2 and not tMhPar.L2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -1795 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + end + + -- se primo preforo e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and dMaxMat5 and + tMhPar.FBP and tMhPar.FBP > dMaxMat5 then + dNumLog = -1795 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.FBP), EgtToUiUnits(dMaxMat5)) + tMhPar.FBP = dMaxMat5 + end + + -- se secondo foro e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh2 and dMaxMat3 then + if tMhPar.TB2_2 and tMhPar.TB2_2 > dMaxMat3 then + dNumLog = -1795 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.TB2_2), EgtToUiUnits(dMaxMat3)) + tMhPar.TB2_2 = dMaxMat3 + end + end + + -- se primo preforo e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh2 and dMaxMat7 and + tMhPar.FBP2 and tMhPar.FBP2 > dMaxMat7 then + dNumLog = -1795 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.FBP2), EgtToUiUnits(dMaxMat7)) + tMhPar.FBP2 = dMaxMat7 + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T9 and dMaxMat4 and tMhPar.T9 > dMaxMat4 then + dNumLog = -1791 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T9), EgtToUiUnits(dMaxMat4)) + tMhPar.T9 = dMaxMat4 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T41 and dMaxMat10 and tMhPar.T41 > dMaxMat10 then + dNumLog = -1791 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T41), EgtToUiUnits(dMaxMat10)) + tMhPar.T41 = dMaxMat10 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T42 and dMaxMat11 and tMhPar.T42 > dMaxMat11 then + dNumLog = -1791 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T42), EgtToUiUnits(dMaxMat11)) + tMhPar.T42 = dMaxMat11 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T43 and dMaxMat12 and tMhPar.T43 > dMaxMat12 then + dNumLog = -1791 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T43), EgtToUiUnits(dMaxMat12)) + tMhPar.T43 = dMaxMat12 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T44 and dMaxMat13 and tMhPar.T44 > dMaxMat13 then + dNumLog = -1791 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T44), EgtToUiUnits(dMaxMat13)) + tMhPar.T44 = dMaxMat13 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- 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.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + 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 = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.FBP2 and abs(tMhPar.FBP2) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'FBP2', EgtToUiUnits(tMhPar.FBP2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.FBP2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T9 and abs(tMhPar.T9) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T9', EgtToUiUnits(tMhPar.T9), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T9 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T41 and abs(tMhPar.T41) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T41', EgtToUiUnits(tMhPar.T41), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T41 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T42 and abs(tMhPar.T42) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T42', EgtToUiUnits(tMhPar.T42), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T42 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T43 and abs(tMhPar.T43) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T43', EgtToUiUnits(tMhPar.T43), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T43 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T44 and abs(tMhPar.T44) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T44', EgtToUiUnits(tMhPar.T44), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T44 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.FBP and abs(tMhPar.FBP) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'FBP', EgtToUiUnits(tMhPar.FBP), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.FBP = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.TB2 and abs(tMhPar.TB2) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'TB2', EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.TB2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.TB2_2 and abs(tMhPar.TB2_2) > tMhPar.TTP then + dNumLog = -1789 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'TB2_2', EgtToUiUnits(tMhPar.TB2_2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.TB2_2 = tMhPar.TTP + 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 LockMortiseCyl.Draw( tLckP, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni geometrie di fianco + local L = tLckP.L + local H = tLckP.H + local T = tLckP.T + local d = tLckP.d + local p = tLckP.p + local sf = tLckP.sf + local dl = tLckP.dl + local mh = tLckP.mh + local mh2 = tLckP.mh2 + local L2 = tLckP.L2 + local H2 = tLckP.H2 + local T2 = tLckP.T2 + local HB2 = tLckP.HB2 + local TB2 = tLckP.TB2 + local HB2_2 = tLckP.HB2_2 + local TB2_2 = tLckP.TB2_2 + local d2 = tLckP.d2 + local p2 = tLckP.p2 + local s = tLckP.s + local FBD = tLckP.FBD + local FBP = tLckP.FBP + local AB = tLckP.AB + local FBD2 = tLckP.FBD2 + local FBP2 = tLckP.FBP2 + local AB2 = tLckP.AB2 + local cl = tLckP.cl + local rf = tLckP.rf -- raggio arrotondamento face + local clc = tLckP.clc + local ccr = tLckP.ccr + local ech = tLckP.ech -- abilitazione chisel + local est = tLckP.est -- altro materiale trovato + local kbs = tLckP.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tLckP.pbs + local SL = tLckP.SL + -- tabelle per i viti fissaggio (mounting screw) + local tMountingScrew = {} + -- inserimento dati nella tabella fori + table.insert( tMountingScrew, { tLckP.D9, tLckP.T9, tLckP.I9, tLckP.IY9, tLckP.PX9, tLckP.PY9, tLckP.LMS}) + table.insert( tMountingScrew, { tLckP.D41, tLckP.T41, tLckP.I41, tLckP.IY41, tLckP.PX41, tLckP.PY41, tLckP.LMS41}) + table.insert( tMountingScrew, { tLckP.D42, tLckP.T42, tLckP.I42, tLckP.IY42, tLckP.PX42, tLckP.PY42, tLckP.LMS42}) + table.insert( tMountingScrew, { tLckP.D43, tLckP.T43, tLckP.I43, tLckP.IY43, tLckP.PX43, tLckP.PY43, tLckP.LMS43}) + table.insert( tMountingScrew, { tLckP.D44, tLckP.T44, tLckP.I44, tLckP.IY44, tLckP.PX44, tLckP.PY44, tLckP.LMS44}) + local dws = tLckP.Dws + local dthd = tLckP.dThD + local typ = tLckP.TyP +-- gestione inversione percorsi + local invG = tLckP.invG -- flag per invertire il senso dei percorsi di lavorazione + -- Assegno i flag + local jn = tLckP.jn -- flag per giunzione face con mortise + local jnb = tLckP.jnb -- flag che indica se profilo tipo bevel o no + -- Inserimento geometrie probe + local posh = tLckP.posh -- posizione in Y del foro di tastatura + local posp = tLckP.posp -- posizione in X del foro di tastatura + -- Disassamento della mortise rispetto alla face + local D_X = tLckP.D_X -- disassamento cava (mortasa o foro) da centro lunghezza face + -- Disassamento dei fori (1st) rispetto al face + local DH_X = tLckP.DH_X -- disassamento fori (1st) da centro lunghezza face + -- Disassamento dei fori (2nd) rispetto al face + local DH_X2 = tLckP.DH_X2 -- disassamento fori (2nd) da centro lunghezza face + -- Disassamento globale + local D_XE = tLckP.D_XE -- Extra delta on X pos for all geometries + -- Nome file custom geometry e percorso file da caricare + local CustGeomFile = tLckP.CGF or '' + local CustGeomPath = tLckP.CGP or '' + -- Anti-splint su extra rectangle geometry + local EAR = tLckP.EAR + local das = tLckP.das + local ASG = tLckP.ASG + -- Second anti-splint on extra rectangle geometry + local das2 = tLckP.das2 + local ASGR = tLckP.ASGR + -- tabelle per i fori, rettangoli e linee opzionali + local tExtraBore = {} + local tExtraRect = {} + local tExtraLine = {} + -- Assegno le dimensioni geometrie KEYWAY + local D3 = tLckP.D3 + local T3 = tLckP.T3 + local P3 = tLckP.P3 + local D4 = tLckP.D4 + local T4 = tLckP.T4 + local P4 = tLckP.P4 + local ms = tLckP.ms + local D5 = tLckP.D5 + local T5 = tLckP.T5 + local I5 = tLckP.I5 + local AV = tLckP.AV + local mc = tLckP.mc + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D10, tLckP.T10, tLckP.PX10, tLckP.PY10, tLckP.EB10, tLckP.RBS10, tLckP.mis10, tLckP.AP10, tLckP.TA10, tLckP.ss10, tLckP.SLD10}) + table.insert( tExtraBore, { tLckP.D11, tLckP.T11, tLckP.PX11, tLckP.PY11, tLckP.EB11, tLckP.RBS11}) + table.insert( tExtraBore, { tLckP.D12, tLckP.T12, tLckP.PX12, tLckP.PY12, tLckP.EB12, tLckP.RBS12}) + table.insert( tExtraBore, { tLckP.D13, tLckP.T13, tLckP.PX13, tLckP.PY13, tLckP.EB13, tLckP.RBS13}) + table.insert( tExtraBore, { tLckP.D14, tLckP.T14, tLckP.PX14, tLckP.PY14, tLckP.EB14, tLckP.RBS14}) + table.insert( tExtraBore, { tLckP.D15, tLckP.T15, tLckP.PX15, tLckP.PY15, tLckP.EB15, tLckP.RBS15}) + table.insert( tExtraBore, { tLckP.D16, tLckP.T16, tLckP.PX16, tLckP.PY16, tLckP.EB16, tLckP.RBS16}) + table.insert( tExtraBore, { tLckP.D17, tLckP.T17, tLckP.PX17, tLckP.PY17, tLckP.EB17, tLckP.RBS17}) + table.insert( tExtraBore, { tLckP.D18, tLckP.T18, tLckP.PX18, tLckP.PY18, tLckP.EB18, tLckP.RBS18}) + table.insert( tExtraBore, { tLckP.D19, tLckP.T19, tLckP.PX19, tLckP.PY19, tLckP.EB19, tLckP.RBS19}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR10, tLckP.WR10, tLckP.RR10, tLckP.TR10, tLckP.PRX10, tLckP.PRY10, tLckP.AR10, tLckP.ER10, tLckP.RRS10, tLckP.TPG10}) + table.insert( tExtraRect, { tLckP.LR11, tLckP.WR11, tLckP.RR11, tLckP.TR11, tLckP.PRX11, tLckP.PRY11, tLckP.AR11, tLckP.ER11, tLckP.RRS11, tLckP.TPG11}) + table.insert( tExtraRect, { tLckP.LR12, tLckP.WR12, tLckP.RR12, tLckP.TR12, tLckP.PRX12, tLckP.PRY12, tLckP.AR12, tLckP.ER12, tLckP.RRS12, tLckP.TPG12}) + table.insert( tExtraRect, { tLckP.LR13, tLckP.WR13, tLckP.RR13, tLckP.TR13, tLckP.PRX13, tLckP.PRY13, tLckP.AR13, tLckP.ER13, tLckP.RRS13, tLckP.TPG13}) + table.insert( tExtraRect, { tLckP.LR14, tLckP.WR14, tLckP.RR14, tLckP.TR14, tLckP.PRX14, tLckP.PRY14, tLckP.AR14, tLckP.ER14, tLckP.RRS14, tLckP.TPG14}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL10, tLckP.TL10, tLckP.PLX10, tLckP.PLY10, tLckP.AL10, tLckP.EL10, tLckP.RLS10}) + table.insert( tExtraLine, { tLckP.LL11, tLckP.TL11, tLckP.PLX11, tLckP.PLY11, tLckP.AL11, tLckP.EL11, tLckP.RLS11}) + table.insert( tExtraLine, { tLckP.LL12, tLckP.TL12, tLckP.PLX12, tLckP.PLY12, tLckP.AL12, tLckP.EL12, tLckP.RLS12}) + table.insert( tExtraLine, { tLckP.LL13, tLckP.TL13, tLckP.PLX13, tLckP.PLY13, tLckP.AL13, tLckP.EL13, tLckP.RLS13}) + table.insert( tExtraLine, { tLckP.LL14, tLckP.TL14, tLckP.PLX14, tLckP.PLY14, tLckP.AL14, tLckP.EL14, tLckP.RLS14}) + -- Assegno le dimensioni geometrie SECURE + local D6 = tLckP.D6 + local T6 = tLckP.T6 + local P6 = tLckP.P6 + local D7 = tLckP.D7 + local T7 = tLckP.T7 + local P7 = tLckP.P7 + local msd = tLckP.msd + local D8 = tLckP.D8 + local T8 = tLckP.T8 + local I8 = tLckP.I8 + local AVd = tLckP.AVd + local mcd = tLckP.mcd + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D20, tLckP.T20, tLckP.PX20, tLckP.PY20, tLckP.EB20, tLckP.RBS20, tLckP.mis20, tLckP.AP20, tLckP.TA20, tLckP.ss20, tLckP.SLD20}) + table.insert( tExtraBore, { tLckP.D21, tLckP.T21, tLckP.PX21, tLckP.PY21, tLckP.EB21, tLckP.RBS21}) + table.insert( tExtraBore, { tLckP.D22, tLckP.T22, tLckP.PX22, tLckP.PY22, tLckP.EB22, tLckP.RBS22}) + table.insert( tExtraBore, { tLckP.D23, tLckP.T23, tLckP.PX23, tLckP.PY23, tLckP.EB23, tLckP.RBS23}) + table.insert( tExtraBore, { tLckP.D24, tLckP.T24, tLckP.PX24, tLckP.PY24, tLckP.EB24, tLckP.RBS24}) + table.insert( tExtraBore, { tLckP.D25, tLckP.T25, tLckP.PX25, tLckP.PY25, tLckP.EB25, tLckP.RBS25}) + table.insert( tExtraBore, { tLckP.D26, tLckP.T26, tLckP.PX26, tLckP.PY26, tLckP.EB26, tLckP.RBS26}) + table.insert( tExtraBore, { tLckP.D27, tLckP.T27, tLckP.PX27, tLckP.PY27, tLckP.EB27, tLckP.RBS27}) + table.insert( tExtraBore, { tLckP.D28, tLckP.T28, tLckP.PX28, tLckP.PY28, tLckP.EB28, tLckP.RBS28}) + table.insert( tExtraBore, { tLckP.D29, tLckP.T29, tLckP.PX29, tLckP.PY29, tLckP.EB29, tLckP.RBS29}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR20, tLckP.WR20, tLckP.RR20, tLckP.TR20, tLckP.PRX20, tLckP.PRY20, tLckP.AR20, tLckP.ER20, tLckP.RRS20, tLckP.TPG20}) + table.insert( tExtraRect, { tLckP.LR21, tLckP.WR21, tLckP.RR21, tLckP.TR21, tLckP.PRX21, tLckP.PRY21, tLckP.AR21, tLckP.ER21, tLckP.RRS21, tLckP.TPG21}) + table.insert( tExtraRect, { tLckP.LR22, tLckP.WR22, tLckP.RR22, tLckP.TR22, tLckP.PRX22, tLckP.PRY22, tLckP.AR22, tLckP.ER22, tLckP.RRS22, tLckP.TPG22}) + table.insert( tExtraRect, { tLckP.LR23, tLckP.WR23, tLckP.RR23, tLckP.TR23, tLckP.PRX23, tLckP.PRY23, tLckP.AR23, tLckP.ER23, tLckP.RRS23, tLckP.TPG23}) + table.insert( tExtraRect, { tLckP.LR24, tLckP.WR24, tLckP.RR24, tLckP.TR24, tLckP.PRX24, tLckP.PRY24, tLckP.AR24, tLckP.ER24, tLckP.RRS24, tLckP.TPG24}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL20, tLckP.TL20, tLckP.PLX20, tLckP.PLY20, tLckP.AL20, tLckP.EL20, tLckP.RLS20}) + table.insert( tExtraLine, { tLckP.LL21, tLckP.TL21, tLckP.PLX21, tLckP.PLY21, tLckP.AL21, tLckP.EL21, tLckP.RLS21}) + table.insert( tExtraLine, { tLckP.LL22, tLckP.TL22, tLckP.PLX22, tLckP.PLY22, tLckP.AL22, tLckP.EL22, tLckP.RLS22}) + table.insert( tExtraLine, { tLckP.LL23, tLckP.TL23, tLckP.PLX23, tLckP.PLY23, tLckP.AL23, tLckP.EL23, tLckP.RLS23}) + table.insert( tExtraLine, { tLckP.LL24, tLckP.TL24, tLckP.PLX24, tLckP.PLY24, tLckP.AL24, tLckP.EL24, tLckP.RLS24}) + -- Assegno le label degli attributi fianco porta + local LG = tLckP.LG -- nome geometria face + local LG2 = tLckP.LG2 -- nome geometria mortise + local LM = tLckP.LM -- nome geometria lavorazione face + local LA = tLckP.LA -- nome geometria lavorazione mortise + local CH = tLckP.CH -- nome suffisso lavorazione chisel + local CLC = tLckP.CLC -- nome geometria clean corner + local LGH = tLckP.LGH -- nome geometria 1st horizontal bore + local LMP = tLckP.LMP -- nome geometria 1st horizontal pre bore + local LGH2 = tLckP.LGH2 -- nome geometria 2nd horizontal bore + local LMP2 = tLckP.LMP2 -- nome geometria 2nd horizontal pre bore + local HD = tLckP.HD -- nome suffisso lavorazione su lati superiore/inferiore porta + -- Assegno le label degli attributi porta KEYWAY + local LSU = tLckP.LSU + local HHU = tLckP.HHU + local SCU = tLckP.SCU + -- Assegno le label degli attributi porta SECURE + local LSD = tLckP.LSD + local HHD = tLckP.HHD + local SCD = tLckP.SCD + -- variabile nome geometrie probe + local LH = 'Shuttle_Probe' + -- variabili per messaggi e settaggi vari + local sCompoName = tLckP.Nome + local nCompoNpar = tLckP.Npar + local sCompoPath = tLckP.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLckP.nCod + local sCodAdj = tLckP.sCod + -- variabili per messaggi di errore + local sNamePar1 = tLckP.NPL or 'L' + local sNamePar2 = tLckP.NPH or 'H' + local sNamePar3 = tLckP.NPT or 'T' + local sNamePar4 = tLckP.NPd or 'd' + local sNamePar5 = tLckP.NPp or 'p' + local sNamePar7 = tLckP.NL2 or 'L2' + local sNamePar8 = tLckP.NT2 or 'T2' + local sNamePar9 = tLckP.NPd2 or 'd2' + local sNamePar10 = tLckP.NPp2 or 'p2' + local sNamePar11 = tLckP.NPS or 's' + local sNamePar12 = tLckP.NTB2 or 'TB2' + local sNamePar13 = tLckP.NTB2_2 or 'TB2_2' + local sNamePar14 = tLckP.FPB or 'FPB' + local sNamePar15 = tLckP.FPB_2 or 'FPB2' + local sNamePar21 = tLckP.NPI5 or 'I5' + local sNamePar22 = tLckP.NPAV or 'Screw direction on KEYWAY side' + local sNamePar33 = tLckP.NPI8 or 'I8' + local sNamePar34 = tLckP.NPAVd or 'Screw direction on SECURE side' + local sNamePar47 = tLckP.NPH2 or 'H2' + local sNamePar48 = tLckP.NPSF or 'sf' + local sNamePar49 = tLckP.NPRF or 'rf' + local sNamePar50 = tLckP.N50 or 'clc' + local sNamePar51 = tLckP.N51 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1700 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeBoreGeom = true + local bMake2ndBoreGeom = true + + -- se ho il suffisso per lavorazione su teste modifico i nomi geometrie applicati sui lati + if HD and #HD > 0 then + if LG then + LG = LG .. HD + end + if LG2 then + LG2 = LG2 .. HD + end + if LM then + LM = LM .. HD + end + if LA then + LA = LA .. HD + end + if CLC then + CLC = CLC .. HD + end + if LGH then + LGH = LGH .. HD + end + if LMP then + LMP = LMP .. HD + end + if LGH2 then + LGH2 = LGH2 .. HD + end + if LMP2 then + LMP2 = LMP2 .. HD + end + end + + -- verifico se dei parametri sono nulli e nel caso disattivo la generazione della face + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + clc = nil + CLC = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom then + if L >= H then + if rf > (H/2) then + rf = (H/2) + end + else + if rf > (L/2) then + rf = (L/2) + end + end + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not bRunByCompo then RC = false end + if not T then T = 0 end + if not T2 then T2 = 0 end + if not D_X then D_X = 0 end + if not DH_X then DH_X = 0 end + if not DH_X2 then DH_X2 = 0 end + if not D_XE then D_XE = 0 end + + -- se rilevato profilo bevel disattivo il join tra face e mortasa + if not jnb then jn = false end + -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione + if not nDrawMach then nDrawMach = 0 end + + if est or ( not L2 or not H2 or not LG2 or not LA) or ( mh and not HB2) then + bMakeMortGeom = false + -- disattivo il join + jn = false + end + +-- if ( not HB2 or not TB2) and ( not ( H2 and not L2) or not T2) or not mh then + if ( not HB2 or not TB2) and ( not H2 or not T2) or not mh then + bMakeBoreGeom = false + end + + if ( not HB2_2 or not TB2_2) or not mh2 then + bMake2ndBoreGeom = false + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + end + + if not ASGR then + das2 = nil + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not mh and d2 < DgMin then + EC = 2 + EM = string.format(EgtDoorsMsg[400],sNamePar9, EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EC = 3 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 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 bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 5 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and ( p2 < PtMin or p2 > PtMax) then + EC = 6 + EM = string.format(EgtDoorsMsg[403],sNamePar10,p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + p2 = 0.8 + elseif ms and ( AV < 0 or AV > 180) then + EC = 7 + EM = string.format(EgtDoorsMsg[403],sNamePar22,AV,0,180, sCompoPath) -- il parametro 'AV' deve essere compreso tra + AV = 90 + elseif msd and ( AVd < 0 or AVd > 180) then + EC = 8 + EM = string.format(EgtDoorsMsg[403],sNamePar34,AVd,0,180, sCompoPath) -- il parametro 'AVd' deve essere compreso tra + AVd = 90 + elseif bMakeFaceGeom and T < 0 then + EC = 9 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeFaceGeom and L <= 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d*2 + elseif bMakeFaceGeom and bMakeMortGeom and not mh and L2 >= L then + EC = 11 + EM = string.format(EgtDoorsMsg[406],sNamePar7,EgtToUiUnits(L2),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + L2 = L - 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EC = 12 + EM = string.format(EgtDoorsMsg[456],sNamePar47,EgtToUiUnits(H2),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H2' deve essere <= 'H' + H2 = H + elseif bMakeMortGeom and T2 <= 0 then + EC = 13 + EM = string.format(EgtDoorsMsg[401],sNamePar8,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + T2 = 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 <= T then + EC = 14 + EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + T2 = T + 0.1 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and s and s <= 0 then + EC = 15 + EM = string.format(EgtDoorsMsg[401],sNamePar11,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d2 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and L2 <= d2 then + if DGD.bProoduce then + EC = 16 + EM = string.format(EgtDoorsMsg[402],sNamePar7,EgtToUiUnits(L2),sNamePar9,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L2 = d + 0.002 + else + d = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not mh and H2 < d2 then + if DGD.bProoduce then + EC = 17 + EM = string.format(EgtDoorsMsg[405],sNamePar47,EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeFaceGeom and H <= 0 then + EC = 18 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d + elseif bMakeMortGeom and H2 <= 0 then + EC = 19 + EM = string.format(EgtDoorsMsg[401],sNamePar47,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 + H2 = d2 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 20 + EM = string.format(EgtDoorsMsg[401],sNamePar48,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMakeFaceGeom and cl and cl > 0 and rf < 0 then + EC = 21 + EM = string.format(EgtDoorsMsg[404],sNamePar49,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + rf = H/2 + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 22 + EM = string.format(EgtDoorsMsg[407],sNamePar50,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + elseif bMakeBoreGeom and FBP and ( ( TB2 and FBP >= TB2) or ( not TB2 and T2 and FBP >= T2)) then + if TB2 and FBP >= TB2 then + EC = 23 + EM = string.format(EgtDoorsMsg[407],sNamePar12,EgtToUiUnits(TB2),sNamePar14,EgtToUiUnits(FBP), sCompoPath) -- il parametro 'TB2' deve essere > 'FBP' + TB2 = FBP + 0.1 + elseif T2 and FBP >= T2 then + EC = 24 + EM = string.format(EgtDoorsMsg[407],sNamePar8,EgtToUiUnits(T2),sNamePar14,EgtToUiUnits(FBP), sCompoPath) -- il parametro 'T2' deve essere > 'FBP' + T2 = FBP + 0.1 + end + elseif bMake2ndBoreGeom and FBP2 and TB2_2 and FBP2 >= TB2_2 then + EC = 25 + EM = string.format(EgtDoorsMsg[407],sNamePar13,EgtToUiUnits(TB2_2),sNamePar15,EgtToUiUnits(FBP2), sCompoPath) -- il parametro 'TB2_2' deve essere > 'FBP2' + TB2_2 = FBP2 + 0.1 + 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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale + EgtSetName(Lg,sCompoName) + + local nPos1st = 0 + local hint, hint_1, hint_2, hint_7, hint_8, hint_9 -- variabili percorsi sul fianco + local thint_3, thint_4, thint_5, thint_6 -- tabelle fori sul fianco + local hint_10, hint_11, hint_12, hint_13, hint_14, hint_15 -- variabili percorsi su secure o keyway + local hintPk, hintPk2 -- variabili percorsi di lavorazione + local nPkJoin + local dFirstface = {} + local dMortise = {} + local nForceMakeFace = nDrawMach + + if bMakeFaceGeom then + + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPos1st = rf/2 + elseif cl == 2 then -- se arrotondamento a destra + nPos1st = -(rf/2) + else + nPos1st = 0 + end + + -- prima cava face completa + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = L + dFirstface.H = H + dFirstface.T = T + dFirstface.d = d + dFirstface.p = p + dFirstface.sf = sf + dFirstface.jn = jn + dFirstface.L2 = L2 + dFirstface.H2 = H2 + dFirstface.cl = cl + dFirstface.rf = rf + dFirstface.est = est + dFirstface.invG = invG + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dFirstface.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 + else + dFirstface.LG = LG + end + dFirstface.LM = LM + dFirstface.Nome = sCompoName + dFirstface.D_X = D_X - nPos1st + dFirstface.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + + -- lancio il primo componente base per disegnare la face completa + MHgen = require( '_Latch') + hint, hintPk = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + local sSide = EgtIf( dl, 'Lock', 'Side') + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if hint then + EgtSetInfo(hint,'SideDoor', sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint, 'ProbeSide', '1') + end + end + if hintPk then + EgtSetInfo(hintPk,'SideDoor', sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPk, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk, 'ProbeSide', '1') + end + end + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo + if CLC and clc and clc > 0 and clc < H and clc < L then + + local bInvert = (SL == 'R') + if DGD.SIDE == 'top' then bInvert = not bInvert end + local CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T, bInvert) + + if CLC1 then + -- se mantiene backset + if kbs and kbs > 0 then + EgtSetInfo( CLC1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + EgtSetInfo( CLC1,'SideDoor',sSide) + if cl <= 1 or cl == 3 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + if cl == 1 then + EgtErase(CLC1) + end + end + if cl == 0 or cl >= 2 then + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + end + end + + if bMakeBoreGeom then -- se primo foro orizzontale abilitato + + -- se parametri foro/preforo + if FBD and FBD > 0 and FBP and FBP > 0 then + hint_7 = EgtCircle( Lg, Point3d(0,0,0), FBD/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_7, -FBP) + EgtSetName( hint_7, LMP) + if AB and abs(AB) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_7, Point3d(0,0,0), Z_AX(), AB, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + end + -- se parametri secondo foro + if HB2 and TB2 and LGH then + hint_8 = EgtCircle( Lg, Point3d(0,0,0), HB2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_8, -TB2) + elseif H2 and T2 and LGH then + hint_8 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_8, -T2) + end + + if hint_8 then -- se esiste secondo foro + EgtSetName( hint_8, LGH) + if AB and abs(AB) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_8, Point3d(0,0,0), Z_AX(), AB, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + + EgtSetInfo( hint_8, 'SideDoor', 'Lock') + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( hint_8, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_8, 'ProbeSide', '1') + end + end + if hint_7 then -- se esiste foro/preforo + EgtSetInfo( hint_7, 'SideDoor', 'Lock') + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( hint_7, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_7, 'ProbeSide', '1') + end + end + end + + if bMake2ndBoreGeom then -- se secondo foro orizzontale abilitato + + -- se parametri foro/preforo + if FBD2 and FBD2 > 0 and FBP2 and FBP2 > 0 then + hint_1 = EgtCircle( Lg, Point3d(0,0,0), FBD2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_1, -FBP2) + EgtSetName( hint_1, LMP2) + if AB2 and abs(AB2) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_1, Point3d(0,0,0), Z_AX(), AB2, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + end + -- se parametri secondo foro + if HB2_2 and TB2_2 and LGH2 then + hint_9 = EgtCircle( Lg, Point3d(0,0,0), HB2_2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_9, -TB2_2) + end + + if hint_9 then -- se esiste secondo foro + EgtSetName( hint_9, LGH2) + if AB2 and abs(AB2) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_9, Point3d(0,0,0), Z_AX(), AB2, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + + EgtSetInfo( hint_9, 'SideDoor', 'Lock') + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( hint_9, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_9, 'ProbeSide', '1') + end + end + if hint_1 then -- se esiste foro/preforo + EgtSetInfo( hint_1, 'SideDoor', 'Lock') + -- se mantiene centro spessore su mortise + if kbs and kbs > 0 then + EgtSetInfo( hint_1, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_1, 'ProbeSide', '1') + end + end + end + + if bMakeMortGeom then -- se seconda cava abilitata + + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d + dMortise.p = p + dMortise.jn = jn + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.invG = invG + dMortise.mkrev = false -- disabilito la creazione del percorso in senso contrario + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.LGM = LG2 + dMortise.LMM = LA + dMortise.Nome = sCompoName + dMortise.jne = false + dMortise.D_X = D_X + dMortise.pbs = pbs + + -- lancio il secondo componente base + MHgen = require('_Mortise') + hint_2, hintPk2 = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, 0) + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + if hint_2 then EgtSetInfo(hint_2,'SideDoor','Lock') end + if hintPk2 then EgtSetInfo(hintPk2,'SideDoor','Lock') end + end + + -- disegno le geometrie mounting screw + if EC == 0 then + + thint_3 = {} + thint_4 = {} + thint_5 = {} + thint_6 = {} + + for k = 1, 5 do + + local D9 = tMountingScrew[k][1] + local T9 = tMountingScrew[k][2] + local I9 = tMountingScrew[k][3] or 0 + local IY9 = tMountingScrew[k][4] or 0 + local PX9 = tMountingScrew[k][5] or 0 + local PY9 = tMountingScrew[k][6] or 0 + local LMS = tMountingScrew[k][7] + + -- se dimensioni foro viti idonee + if D9 and T9 and LMS then + + if D9 > 0 and T9 ~= 0 and LMS ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + local hint_3 = EgtCircle( Lg, Point3d(PX9+(I9/2),PY9+(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_3, -T9) + -- se ho il suffisso per lavorazione su teste + if HD and #HD > 0 then + LMS = LMS .. HD + end + EgtSetName( hint_3, LMS) + EgtSetInfo( hint_3, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint_3, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_3, 'ProbeSide', '1') + end + table.insert( thint_3, hint_3) + + if IY9 ~= 0 then + local hint_5 = EgtCircle( Lg, Point3d(PX9+(I9/2),PY9-(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_5, -T9) + EgtSetName( hint_5, LMS) + EgtSetInfo( hint_5, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint_5, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_5, 'ProbeSide', '1') + end + table.insert( thint_5, hint_5) + end + + if I9 ~= 0 then + local hint_4 = EgtCircle( Lg, Point3d(PX9-(I9/2),PY9+(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_4, -T9) + EgtSetName( hint_4, LMS) + EgtSetInfo( hint_4, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint_4, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_4, 'ProbeSide', '1') + end + table.insert( thint_4, hint_4) + + if IY9 ~= 0 then + local hint_6 = EgtCircle( Lg, Point3d(PX9-(I9/2),PY9-(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_6, -T9) + EgtSetName( hint_6, LMS) + EgtSetInfo( hint_6, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint_6, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_6, 'ProbeSide', '1') + end + table.insert( thint_6, hint_6) + end + end + end + end + end + end + + if EC == 0 and ( hint or hintPk) and abs(nPos1st) > GEO.EPS_SMALL then -- se esiste la prima face + if hint then + EgtMove( hint, Point3d(nPos1st,0,0) - ORIG()) + end + if hintPk then + EgtMove( hintPk, Point3d(nPos1st,0,0) - ORIG()) + end + end + + if EC == 0 and bMakeBoreGeom and hint_8 then -- se esiste il secondo foro (1st) + if DH_X and abs(DH_X) > GEO.EPS_SMALL then + EgtMove( hint_8, Point3d(DH_X,0,0) - ORIG()) + elseif not HB2 and abs(D_X) > GEO.EPS_SMALL then + EgtMove( hint_8, Point3d(D_X,0,0) - ORIG()) + end + end + if EC == 0 and bMakeBoreGeom and hint_7 then -- se esiste il foro/preforo (1st) + if DH_X and abs(DH_X) > GEO.EPS_SMALL then + EgtMove( hint_7, Point3d(DH_X,0,0) - ORIG()) + elseif not HB2 and abs(D_X) > GEO.EPS_SMALL then + EgtMove( hint_7, Point3d(D_X,0,0) - ORIG()) + end + end + + if EC == 0 and bMake2ndBoreGeom and hint_9 then -- se esiste il secondo foro (2nd) + if DH_X2 and abs(DH_X2) > GEO.EPS_SMALL then + EgtMove( hint_9, Point3d(DH_X2,0,0) - ORIG()) + end + end + if EC == 0 and bMake2ndBoreGeom and hint_1 then -- se esiste il foro/preforo (2nd) + if DH_X2 and abs(DH_X2) > GEO.EPS_SMALL then + EgtMove( hint_1, Point3d(DH_X2,0,0) - ORIG()) + end + end + + if EC == 0 and ( hint_2 or hintPk2) and abs(D_X) > GEO.EPS_SMALL then -- se esiste la seconda cava + if hint_2 then + EgtMove( hint_2, Point3d(D_X,0,0) - ORIG()) + end + if hintPk2 then + EgtMove( hintPk2, Point3d(D_X,0,0) - ORIG()) + end + end + + if jn and EC == 0 and hintPk and hintPk2 then + nPkJoin = EgtCurveCompo( Lg, {hintPk,hintPk2}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM) + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nPkJoin, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkJoin, 'ProbeSide', '1') + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 40 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 and hintPk2 then + -- se mantiene centro spessore su mortise + if kbs and kbs > 1 then + EgtSetInfo( hintPk2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + EgtSetInfo( hint_2, 'KeepBackSet', 'c') -- setto 'c' perché viene mantenuto il centro spessore + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2, 'ProbeSide', '1') + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + end + + if EC == 0 then -- se nessun errore + + -- Gestione file custom + local MakeFaceGeom = true + + -- caricamento del file custom + if string.len(CustGeomFile) > 0 and string.find( string.lower(CustGeomFile), '.nge') > 0 then + + -- sostituisco il carattere '\' con '_' nel nome file + CustGeomFile = string.gsub(CustGeomFile, '\\', '_') + CustGeomFile = string.gsub(CustGeomFile, '/', '_') + -- concateno il file alla path + local sCustomPathFile = CustGeomPath..CustGeomFile + local nNewPart + local nNewLayer + local nNewEnt + local nTypeEnt + local sTypeInfo + local cColor + + -- provo ad inserire + MakeFaceGeom = not EgtInsertFile( sCustomPathFile) + + -- se fallito inserimento file dò un messaggio di errore + if MakeFaceGeom then + EC = ErrorBase + 41 + EM = string.format( EgtDoorsMsg[457], sCustomPathFile) + else + + nNewPart = EgtGetNext(Pz) -- nome nuovo pezzo + nNewLayer = EgtGetFirstInGroup( nNewPart) -- ottengo nuovo layer + + -- riloco tutti i nuovi layer dal nuovo pezzo al pezzo corrente + while nNewLayer do + + nNewEnt = EgtGetFirstInGroup( nNewLayer) -- ottengo nuova entità + + while nNewEnt do + + -- controllo se ha dei colori e le note giuste per cambiare lo spessore + nTypeEnt = EgtGetType( nNewEnt) + sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor') + cColor = EgtGetCalcColor( nNewEnt) + + if sTypeInfo and cColor and DGD.dT then + if string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + if AreSameColor(cColor,RED(),30) then -- se colore rosso allora spessore completo + EgtModifyCurveThickness(nNewEnt, -DGD.dT) + elseif AreSameColor(cColor,LIME(),30) then -- se colore verde allora metà spessore + EgtModifyCurveThickness(nNewEnt, -(DGD.dT/2)) + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + else -- altrimenti controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + end + elseif sTypeInfo and string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + -- controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + + EgtRelocateGlob( nNewEnt, Lg) -- riloco nel layer della serratura + nNewEnt = EgtGetFirstInGroup(nNewLayer) + end + nNewLayer = EgtGetNext(nNewLayer) + end + + -- cancello il nuovo pezzo + EgtErase(nNewPart) + end + end + + -- Costruzione della geometria Keyway + -- se dimensioni foro serratura idonee + if D3 and T3 and LSU then + if D3 > 0 and T3 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not P3 then + P3 = 0 + end + + hint_13 = EgtCircle( Lg, Point3d(P3,0,0), D3/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T3) + EgtSetName(hint_13,LSU) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + -- se dimensioni foro maniglia idonee Keyway + if D4 and T4 and HHU then + if D4 > 0 and T4 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not P4 then + P4 = 0 + end + + hint_13 = EgtCircle( Lg, Point3d(P4,0,0), D4/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T4) + EgtSetName(hint_13,HHU) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + if ms then -- se devo fare le viti Keyway + + if not P4 then + P4 = 0 + end + + if D5 and T5 and SCU then + + -- se dimensioni foro vite idonee + if D5 > 0 and T5 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not I5 then + I5 = D4 + end + + hint_12 = EgtCircle( Lg, Point3d((P4-((I5/2) * sin(AV))),((I5/2) * cos(AV)),0), D5/2 , GDB_RT.LOC) + hint_13 = EgtCircle( Lg, Point3d((P4+((I5/2) * sin(AV))),-((I5/2) * cos(AV)),0), D5/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_12, -T5) + EgtModifyCurveThickness(hint_13, -T5) + EgtSetName(hint_12,SCU) + EgtSetName(hint_13,SCU) + EgtSetInfo(hint_12,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_12, 'ProbeSide', '1') + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + + if mc then -- se fori vite a croce + hint_12 = EgtCircle( Lg, Point3d((P4-((I5/2) * sin(AV+90))),((I5/2) * cos(AV+90)),0), D5/2 , GDB_RT.LOC) + hint_13 = EgtCircle( Lg, Point3d((P4+((I5/2) * sin(AV+90))),-((I5/2) * cos(AV+90)),0), D5/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_12, -T5) + EgtModifyCurveThickness(hint_13, -T5) + EgtSetName(hint_12,SCU) + EgtSetName(hint_13,SCU) + EgtSetInfo(hint_12,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_12, 'ProbeSide', '1') + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + local mis10 + local AP10 + local TA10 + local ss10 + local SLD10 + + -- Extra bores Keyway + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + if k == 1 then + mis10 = tExtraBore[k][7] + AP10 = tExtraBore[k][8] + TA10 = tExtraBore[k][9] + ss10 = tExtraBore[k][10] + SLD10 = tExtraBore[k][11] + end + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,PY10,0), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T10) + EgtSetName(hint_13,EB10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + if k == 1 and mis10 and AP10 and TA10 and ss10 and SLD10 then + if ss10 > 0 and SLD10 ~= '' and hint_13 then + hint_13 = MakeSlidePath ( Lg, PX10, PY10, D10, AP10, TA10, ss10) + if hint_13 then + EgtModifyCurveThickness(hint_13, 0) + EgtSetName(hint_13,SLD10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + -- Extra rectangles Keyway + for k = 1, 5 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + local TPG10 = tExtraRect[k][10] + + -- se parametri esistenti e dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(PRY10+(WR10/2)),0), RR10, AR10, (LR10 > WR10), est) + if hint_13 then + EgtModifyCurveThickness(hint_13, -TR10) + EgtSetName(hint_13,ER10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and ( ( EAR and (( das and das > 0) or ( das2 and das2 > 0))) or ( TPG10 and TPG10 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, DGD.BACK_SET, + das, nil, nil, das2, SL, + 'keyway', TPG10) + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TR10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TR10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + -- Extra lines Keyway + for k = 1, 5 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -TL10) + EgtSetName(hint_13,EL10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RLS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TL10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TL10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Costruzione della geometria SECURE + -- se dimensioni foro serratura idonee + if D6 and T6 and LSD then + if D6 > 0 and T6 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not P6 then + P6 = 0 + end + + hint_13 = EgtCircle( Lg, Point3d(P6,0,0), D6/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T6) + EgtSetName(hint_13,LSD) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + -- se dimensioni foro maniglia idonee + if D7 and T7 and HHD then + if D7 > 0 and T7 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not P7 then + P7 = 0 + end + + hint_13 = EgtCircle( Lg, Point3d(P7,0,0), D7/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T7) + EgtSetName(hint_13,HHD) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + if msd then -- se devo fare le viti lato secure + + if not P7 then + P7 = 0 + end + + -- se dimensioni foro vite idonee + if D8 and T8 and SCD then + if D8 > 0 and T8 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer del foro serratura SECURE + EgtSetName(Lg,sCompoName) + end + + if not I8 then + I8 = D7 + end + + hint_12 = EgtCircle( Lg, Point3d((P7-((I8/2) * sin(AVd))),((I8/2) * cos(AVd)),0), D8/2 , GDB_RT.LOC) + hint_13 = EgtCircle( Lg, Point3d((P7+((I8/2) * sin(AVd))),-((I8/2) * cos(AVd)),0), D8/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_12, -T8) + EgtModifyCurveThickness(hint_13, -T8) + EgtSetName(hint_12,SCD) + EgtSetName(hint_13,SCD) + EgtSetInfo(hint_12,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_12, 'ProbeSide', '1') + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + + if mcd then -- se fori vite a croce + hint_12 = EgtCircle( Lg, Point3d((P7-((I8/2) * sin(AVd+90))),((I8/2) * cos(AVd-90)),0), D8/2 , GDB_RT.LOC) + hint_13 = EgtCircle( Lg, Point3d((P7+((I8/2) * sin(AVd+90))),-((I8/2) * cos(AVd-90)),0), D8/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_12, -T8) + EgtModifyCurveThickness(hint_13, -T8) + EgtSetName(hint_12,SCD) + EgtSetName(hint_13,SCD) + EgtSetInfo(hint_12,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_12, 'ProbeSide', '1') + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + mis10 = nil + AP10 = nil + TA10 = nil + ss10 = nil + SLD10 = nil + + -- Extra bores Secure + for k = 11, 20 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + if k == 11 then + mis10 = tExtraBore[k][7] + AP10 = tExtraBore[k][8] + TA10 = tExtraBore[k][9] + ss10 = tExtraBore[k][10] + SLD10 = tExtraBore[k][11] + end + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,-PY10,0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T10) + EgtSetName(hint_13,EB10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + + if k == 11 and mis10 and AP10 and TA10 and ss10 and SLD10 then + if ss10 > 0 and SLD10 ~= '' and hint_13 then + hint_13 = MakeSlidePath ( Lg, PX10, -PY10, D10, -AP10, TA10, ss10) + if hint_13 then + EgtModifyCurveThickness(hint_13, 0) + EgtSetName(hint_13,SLD10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + -- Extra rectangles Secure + for k = 6, 10 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + local TPG10 = tExtraRect[k][10] + + -- se dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(-PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(-PRY10+(WR10/2)),0), RR10, AR10, (LR10 > WR10), est) + if hint_13 then + EgtModifyCurveThickness( hint_13, -TR10) + EgtSetName( hint_13, ER10) + EgtSetInfo( hint_13, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_13, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and ( ( EAR and (( das and das > 0) or ( das2 and das2 > 0))) or ( TPG10 and TPG10 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, DGD.BACK_SET, + das, true, nil, das2, SL, + 'secure', TPG10) + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TR10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TR10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + end + + -- Extra lines Secure + for k = 6, 10 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,-PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -TL10) + EgtSetName(hint_13,EL10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RLS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 and TL10 < DGD.dT then + EgtSetInfo( hint_13, 'KeepBackSet', 'x') -- setto 'x' perché non si sa ancora da quale parte viene applicato + end + if pbs and pbs > 1 and TL10 < DGD.dT and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- aggiungo foro probe + if nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + else + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo + if DGC.Fpd then + sSideDoorInfo = 'Lock' + else + sSideDoorInfo = EgtIf( dl, 'Lock', 'Side') + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + if dPosProbe > 0 then + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_1 then + nIdSideBoxUp = EgtCopyGlob( hint_1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_2 then + nIdSideBoxUp = EgtCopyGlob( hint_2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if #thint_3 > 0 then + for i = 1, #thint_3 do + local hint_3 = thint_3[i] + nIdSideBoxUp = EgtCopyGlob( hint_3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + if #thint_4 > 0 then + for i = 1, #thint_4 do + local hint_4 = thint_4[i] + nIdSideBoxUp = EgtCopyGlob( hint_4, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + if #thint_5 > 0 then + for i = 1, #thint_5 do + local hint_5 = thint_5[i] + nIdSideBoxUp = EgtCopyGlob( hint_5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + if #thint_6 > 0 then + for i = 1, #thint_6 do + local hint_6 = thint_6[i] + nIdSideBoxUp = EgtCopyGlob( hint_6, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + if hint_7 then + nIdSideBoxUp = EgtCopyGlob( hint_7, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_8 then + nIdSideBoxUp = EgtCopyGlob( hint_8, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_9 then + nIdSideBoxUp = EgtCopyGlob( hint_9, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + if EC == 0 and D_XE and D_XE ~= 0 then + EgtMove( Lg, Point3d(0,D_XE,0) - ORIG()) + end + + -- cambio colore alla geometria + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo( Lg, 'Type' ,'LockMortiseCyl') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'cl' ,cl) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'dl' ,dl) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'mh' ,mh) + EgtSetInfo( Lg, 'mh2' ,mh2) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 'HB2' ,HB2) + EgtSetInfo( Lg, 'TB2' ,TB2) + EgtSetInfo( Lg, 'HB2_2' ,HB2_2) + EgtSetInfo( Lg, 'TB2_2' ,TB2_2) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'p2' ,p2) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'FBD' ,FBD) + EgtSetInfo( Lg, 'FBP' ,FBP) + EgtSetInfo( Lg, 'AB' ,AB) + EgtSetInfo( Lg, 'FBD2' ,FBD2) + EgtSetInfo( Lg, 'FBP2' ,FBP2) + EgtSetInfo( Lg, 'AB2' ,AB2) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'jn' ,jn) + EgtSetInfo( Lg, 'jnb' ,jnb) + EgtSetInfo( Lg, 'dws' ,dws) + EgtSetInfo( Lg, 'dthd' ,dthd) + EgtSetInfo( Lg, 'SL' ,SL) + EgtSetInfo( Lg, 'D_X' ,D_X) + EgtSetInfo( Lg, 'DH_X' ,DH_X) + EgtSetInfo( Lg, 'D_XE' ,D_XE) + EgtSetInfo( Lg, 'DH_X2' ,DH_X2) + + EgtSetInfo(Lg,'CustGeomFile' ,CustGeomFile) + EgtSetInfo(Lg,'CustGeomPath' ,CustGeomPath) + + EgtSetInfo(Lg,'D3' ,D3) + EgtSetInfo(Lg,'T3' ,T3) + EgtSetInfo(Lg,'P3' ,P3) + EgtSetInfo(Lg,'D4' ,D4) + EgtSetInfo(Lg,'T4' ,T4) + EgtSetInfo(Lg,'P4' ,P4) + EgtSetInfo(Lg,'ms' ,ms) + EgtSetInfo(Lg,'D5' ,D5) + EgtSetInfo(Lg,'T5' ,T5) + EgtSetInfo(Lg,'I5' ,I5) + EgtSetInfo(Lg,'AV' ,AV) + EgtSetInfo(Lg,'mc' ,mc) + + EgtSetInfo(Lg,'D6' ,D6) + EgtSetInfo(Lg,'T6' ,T6) + EgtSetInfo(Lg,'P6' ,P6) + EgtSetInfo(Lg,'D7' ,D7) + EgtSetInfo(Lg,'T7' ,T7) + EgtSetInfo(Lg,'P7' ,P7) + EgtSetInfo(Lg,'msd' ,msd) + EgtSetInfo(Lg,'D8' ,D8) + EgtSetInfo(Lg,'T8' ,T8) + EgtSetInfo(Lg,'I8' ,I8) + EgtSetInfo(Lg,'AVd' ,AVd) + EgtSetInfo(Lg,'mcd' ,mcd) + + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LG2' ,LG2) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LSU' ,LSU) + EgtSetInfo(Lg,'HHU' ,HHU) + EgtSetInfo(Lg,'SCU' ,SCU) + EgtSetInfo(Lg,'LSD' ,LSD) + EgtSetInfo(Lg,'HHD' ,HHD) + EgtSetInfo(Lg,'SCD' ,SCD) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'HD' ,HD) + EgtSetInfo(Lg,'CLC' ,CLC) + EgtSetInfo(Lg,'LGH' ,LGH) + EgtSetInfo(Lg,'LMP' ,LMP) + EgtSetInfo(Lg,'LGH2' ,LGH2) + EgtSetInfo(Lg,'LMP2' ,LMP2) + EgtSetInfo(Lg,'EAR' ,EAR) + EgtSetInfo(Lg,'das' ,das) + EgtSetInfo(Lg,'ASG' ,ASG) + EgtSetInfo(Lg,'das2' ,das2) + EgtSetInfo(Lg,'ASGR' ,ASGR) + 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 LockMortiseCyl diff --git a/LuaLibs/LouverCutOut.lua b/LuaLibs/LouverCutOut.lua new file mode 100644 index 0000000..185771b --- /dev/null +++ b/LuaLibs/LouverCutOut.lua @@ -0,0 +1,744 @@ +-- +-- 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 +-- +-- LouverCutOut.lua by EgalWare s.r.l. 2016.06.30 +-- Autore: Filippo Monchi +-- LouverCutOut dati i valori 'L' e 'H' e con nome attributo + +-- 2017.10.18 V1.0a1 FM Start point path near lock side +-- 2017.12.07 V1.0a3 FM Add Cleancorner path +-- 2018.01.11 V1.0a4 FM Add Hatching +-- 2018.08.24 V1.0a5 FM Add internal radius on clean-corner paths +-- 2018.10.09 V1.0a6 FM check better the error condition with radius on clean corner path +-- 2019.10.02 V1.019 FM Manage steel option (disable generation of some geometries) +-- 2019.10.07 V1.01a FM Manage cut by saw +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.12.06 V2.001 FM Fix error on not initialized variable d into hatching section +-- 2020.04.29 V2.002 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.04.23 V3.001 FM Manage note to indicate if hatching is present +-- 2021.04.27 V3.002 FM Manage special region on hatching paths to remove pods under those +-- 2022.07.27 V3.003 FM Modification to use compiled code +-- 2023.05.12 V3.004 FM Manage clean corner with cone tool +-- 2023.05.12 V3.005 FM Fix error on disabled clean cone parameter ccn +-- 2024.09.12 V3.006 FM Fix error on print error/warning message with wrongg variables +-- 2024.10.19 V3.007 FM Manage drop path with back and forth +-- 2024.11.14 V3.011 FM Manage new ConeCleanCorner path by CurrDoorCustomData DGC.Ccm parameter + +-- Tavola per definizione modulo (serve ma non usata) +local LouverCutOut = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 2. -- valore minimo lato + +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 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor(nCircle2, cColor2) + end + end + + return nLine +end + +----------------------------------------------------------------- +local function DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, nIdPath, dTh) + + local nId, nId1, nId2, nId3, nId4 + + -- faccio gli offset in più e in meno e li unisco con le linee per creare il percorso + nId1 = EgtCopyGlob( nIdPath, Lg) + EgtOffsetCurve( nId1, 0.5) + nId3 = EgtCopyGlob( nIdPath, Lg) + EgtOffsetCurve( nId3, -0.5) + -- inverto il percorso 2 + EgtInvertCurve( nId3) + -- prendo i punti da collegare + local pIni = EgtEP( nId1) + local pEnd = EgtSP( nId3) + nId2 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = EgtEP( nId3) + pEnd = EgtSP( nId1) + nId4 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- creo percorso + nId = EgtCurveCompo( Lg, {nId1,nId2,nId3,nId4}, true) + EgtModifyCurveThickness( nId, dTh) + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( Lg, nId, true, 2) + -- cancello il percorso utilizzato + if nId then + EgtErase( nId) + end +end + +-- Funzione di sistemazione parametri +function LouverCutOut.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 + local nThBl0 + local nThBl1 + + -- Assegno parametri da ddf + if DGD.LENGTH then + tMhPar.L = DGD.LENGTH + end + if DGD.WIDTH then + tMhPar.W = DGD.WIDTH + end + tMhPar.T = DGD.dT + + -- verifico se presente il parametro DGC.Cmx ( massimo spessore per applicare la seconda modalità di ConeCleanCorner) e se ha i valori congruenti + if not DGC.Cmx then + tMhPar.Cmx = 0 + else + tMhPar.Cmx = abs(DGC.Cmx) + end + -- verifico se presente il parametro DGC.Ccm ( ConeCleanCorner mode) e se ha i valori congruenti (0 o 1) + if not DGC.Ccm then + tMhPar.Ccm = 0 + else + tMhPar.Ccm = abs( DGC.Ccm) + if tMhPar.Ccm > 1 then + tMhPar.Ccm = 0 + end + -- verifico se spessore porta ammette la seconda modalità, nel caso torno alla prima modalità + if tMhPar.T > tMhPar.Cmx then + tMhPar.Ccm = 0 + end + end + + -- disattivo la lama se la cava è più profonda di una certa quota + if tMhPar.MaxBd and tMhPar.T and tMhPar.T > tMhPar.MaxBd then + tMhPar.bl = false + dNumLog = -1294 + dNumMessage = 674 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.MaxBd)) + end + + local MB = require( 'MachiningBase') + local sLBM + local nLBMi = 1 + local sDM + local nDMi = 1 + local dMaxCutBladeLen = 0 + local sCLCN + local nCLCNi = 1 + local sNotesMach = '' + + -- se porta steel o aluminum disabilito alcune geometrie non compatibili con il metallo + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.est = true + tMhPar.DM = nil + else + tMhPar.est = nil + end + + if tMhPar.DM then + sDM = tMhPar.DM + end + + if tMhPar.LBM then -- geometria con lama + sLBM = tMhPar.LBM + end + + if tMhPar.CLCN then -- pulitira spigolo con utensile conico + sCLCN = tMhPar.CLCN + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- parametri utensile per hatching + if sDM and tMhPar.d then + nTempT1, dMaxMat1, sMchngName1, nThBl1 = MB.GetToolDataFromAttrib( sDM, nDMi) + end + -- se ha fallito con la prima colonna riprovo con la seconda + -- (la lavorazione potrebbe essere messa sulla seconda colonna della MTAble) + if sDM and tMhPar.d and not( nTempT1 and sMchngName1) then + nDMi = 2 + nTempT1, dMaxMat1, sMchngName1, nThBl1 = MB.GetToolDataFromAttrib( sDM, nDMi) + end + + if sLBM and tMhPar.bl and tMhPar.d3 then + nTempT0, dMaxMat0, sMchngName0, nThBl0 = MB.GetToolDataFromAttrib( sLBM, nLBMi) + end + + if sCLCN then + nTempT2, dMaxMat2, sMchngName2, _, sNotesMach = MB.GetToolDataFromAttrib( sCLCN, nCLCNi, true) + end + + if DGD.bProoduce and not est and nTempT2 and nTempT2 < 0 then + dNumLog = -1293 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sCLCN, nCLCNi, 0, dNumLog, sMchngName2) + else + -- cerco la nota + local nPosFound = string.find( sNotesMach, 'RadToClean') + if nPosFound then + local sParz = string.sub( sNotesMach, nPosFound) + nPosFound = string.find( sParz, ';') + local sTrimmed + if nPosFound then + sTrimmed = string.sub( sParz, 1, nPosFound-1) + else + sTrimmed = sParz + end + if sTrimmed and #sTrimmed > 0 then + local sValue = string.sub( sTrimmed, 12) + if sValue and #sTrimmed > 0 then + local dVal = tonumber( sValue) + if dVal and abs(dVal) > GEO.EPS_SMALL then + tMhPar.dCleanNote = dVal + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + end + + if DGD.bProoduce and not est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1298 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sDM, nDMi, tMhPar.d, dNumLog, sMchngName1) + elseif not est and nTempT1 then + tMhPar.d = nTempT1 + end + + if tMhPar.d3 and nTempT0 and nTempT0 <= 0 then -- lama + if DGD.bProoduce and tMhPar.bl then -- se utilizzo la lama + dNumLog = -1299 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLBM, nLBMi, tMhPar.d3, dNumLog, sMchngName0) + end + elseif nTempT0 then + tMhPar.d3 = nTempT0 + if nThBl0 and nThBl0 > 0 then tMhPar.thb = nThBl0 end + end + + -- se lo spessore porta è maggiore della capacità lama disabilito la lama ed emetto un warning + if tMhPar.bl and tMhPar.T and dMaxMat0 and tMhPar.T >= dMaxMat0 then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1297 + dNumMessage = 672 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) + end + + -- se lo spessore porta è maggiore della capacità utensile hatching disabilito la lavorazione ed emetto un warning + if tMhPar.T and dMaxMat1 and tMhPar.T >= dMaxMat1 then + tMhPar.DM = nil + dNumLog = -1296 + dNumMessage = 672 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName1, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + end + + -- se il blade è attivo calcolo se passa la lama nella sfinestratura + if tMhPar.bl and tMhPar.d3 and tMhPar.L and tMhPar.W then + + -- calcolo la massima impronta lama + local dBladeRadius = tMhPar.d3 / 2 + dMaxCutBladeLen = sqrt( (dBladeRadius * dBladeRadius) - ( ( dBladeRadius - tMhPar.T) * ( dBladeRadius - tMhPar.T))) + + -- se l'impronta lama è maggiore della lunghezza o larghezza escludo la lama e do messaggio di warning + if (2*dMaxCutBladeLen) >= tMhPar.L or (2*dMaxCutBladeLen) >= tMhPar.W then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1295 + dNumMessage = 673 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0) + end + end + + -- se il blade è attivo e utensile lama e c'è il clean corner, lo ricalcolo in funzione del raggio lama + if tMhPar.bl and tMhPar.thb and tMhPar.thb > 0 and tMhPar.clc and tMhPar.clc > 0 then + if dMaxCutBladeLen > tMhPar.clc then + tMhPar.clc = dMaxCutBladeLen + end + end + + if tMhPar.CL and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.W or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CL then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function LouverCutOut.Draw( tLvrPar, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni + local L = tLvrPar.L + local W = tLvrPar.W + local T = tLvrPar.T + local clc = tLvrPar.clc + local ccr = tLvrPar.ccr + local ccn = tLvrPar.ccn + local hml = tLvrPar.hml + local dml = tLvrPar.dml + local dmw = tLvrPar.dmw + local bl = tLvrPar.bl + local dbl = tLvrPar.dbl + local d = tLvrPar.d -- hatching tool diameter + local d3 = tLvrPar.d3 -- blade diameter + local dRadToClean = tLvrPar.dCleanNote or 0 + local dConeCleanMode = tLvrPar.Ccm + local est = tLvrPar.est + -- Assegno i nomi + local LG = tLvrPar.LG + local LM = tLvrPar.LM + local CL = tLvrPar.CL + local CLCN = tLvrPar.CLCN + local DM = tLvrPar.DM -- nome lavorazione hatchind + local LBM = tLvrPar.LBM -- nome lavorazione con lama + -- variabili per messaggi e settaggi vari + local sCompoName = tLvrPar.Nome + local nCompoNpar = tLvrPar.Npar + local sCompoPath = tLvrPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLvrPar.nCod + local sCodAdj = tLvrPar.sCod + -- variabili per messaggi e settaggi vari + local sNamePar1 = tLvrPar.N1 or 'L' + local sNamePar2 = tLvrPar.N2 or 'H' + local sNamePar3 = tLvrPar.N3 or 'T' + local sNamePar4 = tLvrPar.N5 or 'clc' + local sNamePar5 = tLvrPar.N5 or 'ccr' + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1200 + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- variabile per gestione presenza hatching + local bExistsHatching = false + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if L and L < DimMin then + EC = 1 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'L' deve essere > DimMin + D = DimMin + elseif W and W < DimMin then + EC = 2 + EM = string.format(EgtDoorsMsg[407],sNamePar2,EgtToUiUnits(H),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'H' deve essere > DimMin + W = DimMin +--[[ + elseif CL and clc and clc > 0 and ( 2*clc) >= W then + EC = 3 + EM = string.format(EgtDoorsMsg[407],sNamePar4..'*2',EgtToUiUnits(clc),sNamePar2,EgtToUiUnits(W), sCompoPath) -- il parametro 'clc*2' deve essere > W + clc = W/2-0.2 + elseif CL and clc and clc > 0 and ( 2*clc) >= L then + EC = 4 + EM = string.format(EgtDoorsMsg[407],sNamePar4..'*2',EgtToUiUnits(clc),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'clc*2' deve essere > L + clc = L/2-0.2 +]]-- + elseif CL and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 5 + EM = string.format(EgtDoorsMsg[407],sNamePar4,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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + local pIni, pEnd + local GId, MId, CLC1, CLC2, CLC3, CLC4 + local CLCN1, CLCN2, CLCN3, CLCN4 + local nKindGeom + local bSingleMode = true + + -- Costruzione della geometria + GId = EgtRectangle2P( Lg, Point3d( 0, 0, T), Point3d( W, L, T), GDB_RT.GLOB) + + -- Costruzione della geometria clean corner + if nDrawMach >= 0 then -- se abilitata geometria + -- se ci sono i parametri per i percorsi clean corner + if CL and clc and clc > 0 and clc < W and clc < L then + -- angolo x-y+ + CLC1 = MakeClcPath( clc, ccr, CL, Lg, -T) + EgtMove( CLC1, Point3d(0,L,T) - ORIG()) + -- angolo x+y+ + CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,L,0), Z_AX(), -90) + EgtMove( CLC2, Point3d(W,0,0) - ORIG()) + -- angolo x+y- + CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,L,0), Z_AX(), 180) + EgtMove( CLC3, Point3d(W,-L,0) - ORIG()) + -- angolo x-y- + CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,L,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(0,-L,0) - ORIG()) + end + -- se ci sono i parametri per i percorsi di clean corner con utensile conico + if CLCN and ccn and ccn > 0 and dRadToClean and dRadToClean > 0 then + -- angolo x-y+ + CLCN1 = MakeConeClcPath( CLCN, Lg, -T, dRadToClean, dConeCleanMode) + EgtMove( CLCN1, Point3d(0,L,T) - ORIG()) + -- angolo x+y+ + CLCN2 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN2, Point3d(0,L,0), Z_AX(), -90) + EgtMove( CLCN2, Point3d(W,0,0) - ORIG()) + -- angolo x+y- + CLCN3 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN3, Point3d(0,L,0), Z_AX(), 180) + EgtMove( CLCN3, Point3d(W,-L,0) - ORIG()) + -- angolo x-y- + CLCN4 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN4, Point3d(0,L,0), Z_AX(), 90) + EgtMove( CLCN4, Point3d(0,-L,0) - ORIG()) + end + if GId then + EgtModifyCurveThickness( GId, -T) + EgtInvertCurve( GId) + EgtSetName( GId, LG) + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion(Lg, GId, bSingleMode) + end + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + -- Costruzione della geometria + MId = EgtRectangle2P( Lg, Point3d( 0, 0, T), Point3d( W, L, T), GDB_RT.GLOB) + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, L /2, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( W, L /2, T), GDB_RT.GLOB) + end + EgtModifyCurveThickness( MId, -T) + EgtInvertCurve( MId) + if bl then + EgtSetName( MId, LBM) + EgtSetInfo( MId, 'ByBlade', bl) + else + EgtSetName( MId, LM) + end + + -- se ci sono tutti i parametri per l'hatching + if DM and ( ( hml and dml) or dmw) then + + local bMakeDrop = false + + if not d then d = 0 end + + -- se l'utensile e i parametri per la lunghezza sono presenti + if d > 0 and hml and dml then + -- se lunghezza inferiore del limite inserisco le linee + if L <= hml then + if L > dml then -- se lunghezza e' maggiore del drop inserisco linee + + -- determino quante linee inserire + local nStep = ceil(L/dml) -- numero di passate + local dStep = (L/nStep) -- passo ricalcolato + local nPass = 1 + local nDir = 1 + bMakeDrop = true + bExistsHatching = bMakeDrop + + -- ciclo inserimento linee + while nPass < nStep do + + pIni = Point3d( EgtIf( nDir > 0, (d*9/16), (W-(d*9/16))),(dStep*nPass),T) + pEnd = Point3d( EgtIf( nDir > 0, (W-(d*9/16)), (d*9/16)),(dStep*nPass),T) + hint1 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- se ho doppia linea + if dbl and dbl == 1 then + EgtTrimExtendCurveByLen( hint1, -(d/2), pEnd) + pIni = EgtSP( hint1) + pEnd = EgtEP( hint1) + -- seconda linea + hint2 = DrawAddLineDrawCircle( pEnd, pIni, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + DRP1 = EgtCurveCompo( Lg, {hint1,hint2}, true) + else + DRP1 = EgtCurveCompo( Lg, hint1, true) + end + EgtModifyCurveThickness( DRP1, -T) + EgtSetName( DRP1, DM) + if dbl and dbl == 1 then + EgtSetInfo( DRP1, 'DoubleLine', 1) + end + -- creo estrusi e superfici attorno alla linea di drop + DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, DRP1, -T) + + -- se non ho doppia linea creao linee di verso alternato + if not dbl or dbl == 0 then + nDir = -nDir + end + nPass = nPass + 1 + end -- end while + end + end + end + + if d > 0 and dmw then + -- se lunghezza inferiore del limite inserisco le linee + if L <= hml then + if W > dmw then -- se larghezza e' maggiore del drop inserisco linee + + -- determino quante linee inserire + local nStep = ceil(W/dmw) -- numero di passate + local dStep = (W/nStep) -- passo ricalcolato + local nPass = 1 + local nDir = 1 + bMakeDrop = true + bExistsHatching = bMakeDrop + + -- ciclo inserimento linee + while nPass < nStep do + + pIni = Point3d( (dStep*nPass), EgtIf( nDir > 0, (d*9/16), (L-(d*9/16))),T) + pEnd = Point3d( (dStep*nPass), EgtIf( nDir > 0, (L-(d*9/16)), (d*9/16)),T) + hint1 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- se ho doppia linea + if dbl and dbl == 1 then + EgtTrimExtendCurveByLen( hint1, -(d/2), pEnd) + pIni = EgtSP( hint1) + pEnd = EgtEP( hint1) + -- seconda linea + hint2 = DrawAddLineDrawCircle( pEnd, pIni, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + DRP1 = EgtCurveCompo( Lg, {hint1,hint2}, true) + else + DRP1 = EgtCurveCompo( Lg, hint1, true) + end + EgtModifyCurveThickness( DRP1, -T) + EgtSetName( DRP1, DM) + if dbl and dbl == 1 then + EgtSetInfo( DRP1, 'DoubleLine', 1) + end + -- creo estrusi e superfici attorno alla linea di drop + DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, DRP1, -T) + + -- se non ho doppia linea creao linee di verso alternato + if not dbl or dbl == 0 then + nDir = -nDir + end + nPass = nPass + 1 + end -- end while + end + end + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if GId then + EgtSetColor( GId or GDB_ID.NULL, AQUA()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, AQUA()) + end + if CLC1 then + EgtSetColor( CLC1 or GDB_ID.NULL, AQUA()) + end + if CLC2 then + EgtSetColor( CLC2 or GDB_ID.NULL, AQUA()) + end + if CLC3 then + EgtSetColor( CLC3 or GDB_ID.NULL, AQUA()) + end + if CLC4 then + EgtSetColor( CLC4 or GDB_ID.NULL, AQUA()) + end + else + if GId then + EgtSetColor( GId or GDB_ID.NULL, ORANGE()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, ORANGE()) + end + if CLC1 then + EgtSetColor( CLC1 or GDB_ID.NULL, ORANGE()) + end + if CLC2 then + EgtSetColor( CLC2 or GDB_ID.NULL, ORANGE()) + end + if CLC3 then + EgtSetColor( CLC3 or GDB_ID.NULL, ORANGE()) + end + if CLC4 then + EgtSetColor( CLC4 or GDB_ID.NULL, ORANGE()) + end + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer + EgtSetInfo( Lg, 'Type' , 'LouverCutOut') + EgtSetInfo( Lg, 'L' , L) + EgtSetInfo( Lg, 'H' , H) + EgtSetInfo( Lg, 'T' , T) + EgtSetInfo( Lg, 'clc' , clc) + EgtSetInfo( Lg, 'ccr' , ccr) + EgtSetInfo( Lg, 'ccn' , ccn) + EgtSetInfo( Lg, 'hml' , hml) + EgtSetInfo( Lg, 'dml' , dml) + EgtSetInfo( Lg, 'dmw' , dmw) + EgtSetInfo( Lg, 'bl' , bl) + EgtSetInfo( Lg, 'dbl' , dbl) + EgtSetInfo( Lg, 'd' , d) + EgtSetInfo( Lg, 'd3' , d3) + EgtSetInfo( Lg, 'est' , est) + EgtSetInfo( Lg, 'hatch' , bExistsHatching) + EgtSetInfo( Lg, 'LG' , LG) + EgtSetInfo( Lg, 'LM' , LM) + EgtSetInfo( Lg, 'CL' , CL) + EgtSetInfo( Lg, 'CLCN' , CLCN) + EgtSetInfo( Lg, 'DM' , DM) + EgtSetInfo( Lg, 'LBM' , LBM) + 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 LouverCutOut diff --git a/LuaLibs/MachiningBase.lua b/LuaLibs/MachiningBase.lua new file mode 100644 index 0000000..e695fb1 --- /dev/null +++ b/LuaLibs/MachiningBase.lua @@ -0,0 +1,3367 @@ +-- +-- 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 +-- +-- MachiningBase.lua by EgalWare s.r.l. 2016.07.10 +-- Machining Base library + +-- 2017.06.30 V1.013 FM Add function for optimization paths with same machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo into functions AdjustThrouIsle and AdjustVertHole +-- 2018.08.22 V1.015 FM Add parameter dBevelOffs on MakeRoughPaths function +-- 2018.08.22 V1.016 FM add parameter nForceUseShuttle on AdjustHead function to set only the forced shuttle +-- 2019.01.11 V1.017 FM Manage note Mach2nd into function FindEntitiesCompMach +-- 2019.01.14 V1.018 FM Manage note Mach2nd into functions AdjustThrouIsle and AdjustVertHole +-- 2019.01.21 V1.019 FM Add output of variable nTypeGeom on function AdjustVertHole +-- 2019.01.24 V1.01a FM Fix error into FindEntitiesCompMach on compare with sKeepProbe +-- 2019.01.24 V1.01b FM Extend cases on AdjustHeadChisel function +-- 2019.04.08 V1.01c FM Add common functions ModifyLiLo (used into AddAndDelMachining) and AdjustBladeVertCurve +-- to manage blade lead-in and lead-out +-- 2019.04.30 V1.01d FM Add functions AdjustASplintWithBlade to manage anti-splint paths when groove by blade +-- 2019.04.08 V1.01d FM Add functions AdjustHeadOnASplint to manage anti-splint path on hinge side when groove by blade +-- 2019.04.08 V1.01d FM Add common functions DefineASplint (used into AdjustHeadOnASplint and AdjustASplintWithBlade) +-- 2019.07.17 V1.01e FM Manage better the delta angle when probemode is active on function AdjustHorizDrillX and AdjustHorizDrillY +-- 2019.08.27 V1.01f FM Release Notes info on exit of AddAndDelMachining function +-- 2019.08.27 V1.01f FM Add FindGeomWithNote function +-- 2019.10.01 V1.020 FM Delete function FindProperties (already present into EgtDoorBase as FindProperty) +-- 2019.10.01 V1.021 FM Add AdjPrfThrouCurveNew function +-- 2019.10.17 V1.023 FM Manage note for blade into AdjustThrouIsle +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.21 V2.001 FM Add function ModifyLiLoToExt to modify lead-in and lead-out for strike steel machining +-- 2019.11.11 V2.002 FM Into function MakeRoughPaths manage also Top chamfer shape +-- 2019.12.02 V2.003 FM Modify function ModifyLiLoToExt to disable also oscillation parameters +-- 2020.12.22 V2.004 FM Manage Open Paths into TestThrouIsle and AdjustThrouIsle functions +-- 2021.04.02 V2.005 FM Manage Closed paths with no area into TestThrouIsle and AdjustThrouIsle functions +-- 2021.05.25 V2.006 FM Manage Closed paths with no area into TestVertHole and AdjustVertHole functions +-- 2021.11.24 V2.007 FM Add functions AdjustProbeMill to manage probe paths +-- 2022.02.21 V2.008 FM Manage machining note CUT_LENGTH=xxx to machine only distance defined by value (in mm) +-- 2023.05.24 V2.009 FM Add function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides +-- 2023.07.26 V2.00a FM Fix error on calculate area on closed curved into AdjustThrouIsle function +-- 2023.09.16 V2.00b FM Manage to invert path also with Zpositive direction path into AdjustThrouCurve function +-- 2023.10.25 V2.00c FM Manage add extra leadout length into AddAndDelMachining +-- 2023.10.25 V2.00d FM Manage new input interface parameter nModeOrder into OrderEnt function +-- to have head machining ordered from X pos to X neg +-- 2023.10.25 V2.00d FM Manage new input interface parameter bNoModifyPath into AdjustBevel function +-- to manage 5 axis head and 3 axis head ( that machine bevel profile) on same machine +-- 2023.11.13 V2.00e FM into AddAndDelMachining function let to Outpuut the machining note also when 'not generation machining' flag is enable +-- 2024.01.19 V2.010 FM Fix error into InsZedByTool when use max function with a paarameter at nil value +-- 2024.05.31 V2.011 FM Add to function interface (and manage) the bNarrowDoor parameter into AddAndDelMachining function let to manage narrow doors +-- Add to function interface (and manage) the bSkipOnSecCol parameter into AdjustBevel function +-- Add to function interface (and manage) the bSkipOnSecCol parameter into AdjustThrouCurve function +-- 2024.06.21 V2.012 FM Manage to set clockwise direction on closed path into Adjusthead (by new parameter: bCheckDirection) +-- 2024.10.30 V2.013 FM into GetToolDataFromAttrib function, if force read thicknnes is enabled get the mill max thickness as blade thickness +-- in case mill is used instead blade +-- 2024.11.14 V2.014 FM Manage the flipping geometry into AdjustConeCleanPaths from solid layer than geometry +-- 2025.01.13 V2.015 FM Initialize DGD.GHT to be compatible with old Machining_xxx +-- 2025.01.17 V2.016 FM Set infos (Parent and LinkCode) to ghost paths (into MakeGhostCopy function) +-- and disable the machining that has info LinkCode with negative value ( into AddAndDelMachining function) +-- 2025.01.20 V2.017 FM Manage new info type 'InvDir' from groove compo into funtion ModifyLiLo + +require( 'EgtBase') +require( 'EgtConst') +local EgtDoorsMsg = require( 'EgtDoorsMsg') + +-- Tavola per definizione modulo +local MachiningBase = {} + +print( 'MachiningBase started') +DoorOutLog( ' MachiningBase started', 1) + +-- set the DGD with old value to be compatible with old Machining_x files +if not DGD.GHT then + DGD.GHT = '_HIDE' +end + +----------------------------------------------------------------- +-- *** Disposition Functions *** +----------------------------------------------------------------- + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustXFixture( dX) + -- per non trovarsi tra i due tavoli + if dX > 2360 and dX < 2570 then + dX = 2570 + end + return dX +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustXReference( dX, HintList) + local DX_ENG = 200 + dX = MachiningBase.AdjustXFixture( dX) + --for i = 1, #HintList, 2 do + -- if dX > HintList[i] - DX_ENG and dX < HintList[i+1] + DX_ENG then + -- dX = HintList[i] - DX_ENG + -- end + --end + return dX +end + +----------------------------------------------------------------- +-- *** Make Ghost copy of entity *** +----------------------------------------------------------------- +function MachiningBase.MakeGhostCopy( EntId, bCheckDirection) + + local sParnt = EgtGetParent( EntId) + local EntName = EgtGetName( EntId) + local nNewEntId = EgtCopyGlob( EntId, sParnt) + EgtSetName( nNewEntId, EntName..DGD.GHT) + EgtSetStatus( nNewEntId, GDB_ST.OFF) + + -- Se ottimizzazione lavorazioni macchine in linea + if DGD.OML then + EgtSetInfo( nNewEntId, 'Parent', EntId) + end + -- assegno nota con valore il campo Link della Mtable + if DGD.LVL and abs(DGD.LVL) > 0 then + EgtSetInfo( nNewEntId, 'LinkCode', DGD.LVL) + end + + -- se check per verifica direzione percorso + if bCheckDirection then + + -- verifico se ho la nota per non fare il controllo di direzione percorso ( per esempio le svuotature in centro utensile) + local nNotCheck = EgtGetInfo( nNewEntId, 'NotCheckDir', 'i') or 0 + + -- se la nota vale 0 o non ho la nota faccio la verifica + if nNotCheck == 0 then + + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( nNewEntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea + + -- verifico se il percorso è chiuso + if EgtCurveIsClosed( nNewEntId) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + if abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return nNewEntId + end + -- altrimenti non è chiuso + else + -- faccio una copia del percorso + local nNewEntId2 = EgtCopyGlob( nNewEntId, sParnt) + -- chiudo il percorso + if EgtCloseCurveCompo( nNewEntId2) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId2) + EgtErase(nNewEntId2) + if dArea and abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return nNewEntId + end + else + EgtErase(nNewEntId2) + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + if not dArea or abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return nNewEntId + end + end + end + + local frEnt = EgtGetGlobFrame( nNewEntId) + if vtMPlane then + vtMPlane:toGlob(frEnt) + if dArea and dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( nNewEntId) + end + end + end + end + return nNewEntId +end + +----------------------------------------------------------------- +-- *** Seeking Functions *** +----------------------------------------------------------------- +-------------------------------------------------------------------------------- +function MachiningBase.FindEntitiesCompMach( nEntId, tEntList, sMachining, nJoinGeomInMach, nMaxDist, bSameLayer, bSameSecMach) + local List = {} + -- inserisco per prima l'entità passata + table.insert( List, nEntId) + -- acquisisco il padre dell'entità passata + local nParendId = EgtGetParent(nEntId) + -- punto iniziale entità passata + local pIni1 = EgtSP( nEntId, GDB_ID.ROOT) + -- nota correzione in Z per probe + local sKeepProbe = EgtGetInfo( nEntId, 'KeepBackSet') or '0' + local sNoteProbes = EgtGetInfo( nEntId, 'ProbeSide') or '0' + -- se direzione fresa da sotto esco subito + local vtExtr = EgtCurveExtrusion( nEntId, GDB_ID.ROOT) -- recupero versore estrusione + -- parametro link + local nCheckLink = EgtGetInfo( nEntId, 'LinkCode', 'i') or 0 + local bEnablekinkCheck = DGD.OML + + -- -------------------------------------------------------------------------------------- + -- provvisoriamente lascio attiva la gestione del Join anche se ho il parametro LinkCode + -- nel caso si voglia disabilitare il join commentare la linea bEnablekinkCheck = false + -- -------------------------------------------------------------------------------------- + bEnablekinkCheck = false + + -- se non ha codice link, non abilitato, con distanza valida e non diretto verso il basso + if ( nCheckLink == 0 or not bEnablekinkCheck) and nJoinGeomInMach and nJoinGeomInMach > 0 and nMaxDist and nMaxDist > 0 and vtExtr:getZ() > - 0.1 then + for i = 1, #tEntList do + if tEntList[i] and tEntList[i] ~= nEntId then + -- se sono nello stesso layer + if not bSameLayer or EgtGetParent( tEntList[i]) == nParendId then + -- se non ha parametro link + nCheckLink = EgtGetInfo( tEntList[i], 'LinkCode', 'i') or 0 + if ( nCheckLink == 0 or not bEnablekinkCheck) then + local sMachNote = EgtGetInfo( tEntList[i], 'Machining') + -- se hanno la stessa lavorazione + if sMachNote and sMachNote == sMachining then + -- se non è già stata lavorata + local nSecMach = EgtGetInfo( tEntList[i], 'Mach2nd', 'i') or 0 + if bSameSecMach or nSecMach == 0 then + local vtExtr1 = EgtCurveExtrusion( tEntList[i], GDB_ID.ROOT) -- recupero versore estrusione + if AreSameVectorApprox( vtExtr1, vtExtr) then -- se direzioni uguali + local pIni2 = EgtSP( tEntList[i], GDB_ID.ROOT) + local sKeepProbe2 = EgtGetInfo( tEntList[i], 'KeepBackSet') or '0' + local sNoteProbes2 = EgtGetInfo( tEntList[i], 'ProbeSide') or '0' + -- se la distanza tra loro è inferiore della massima + if dist( pIni1, pIni2) <= nMaxDist then + -- se hanno note uguali + if sKeepProbe == sKeepProbe2 or sNoteProbes == sNoteProbes2 then + table.insert( List, tEntList[i]) + -- pIni1 = pIni2 -- diventa il nuovo punto + end + end + end + end + end + end + end + end + end + end + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindEntitiesWithNameFromTab( ListPrev, sName) + local List = {} + if ListPrev then + for i = 1, #ListPrev do + local sEntName = EgtGetName( ListPrev[i]) + if sEntName and sEntName == sName then + table.insert( List, ListPrev[i]) + end + end + end + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindEntitiesWithName( Pz, sName, ListPrev) + local List = {} + local PzIsTab = type(Pz) == 'table' + if ListPrev then + for i = 1, #ListPrev do + table.insert( List, ListPrev[i]) + end + end + local nMaxPz = 1 + if PzIsTab then nMaxPz = #Pz end + for i = 1, nMaxPz do + local nIdPz + if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end + local Ly = EgtGetFirstGroupInGroup( nIdPz) + while Ly do + local Ent = EgtGetFirstNameInGroup( Ly, sName) + while Ent do + table.insert( List, Ent) + Ent = EgtGetNextName( Ent, sName) + end + Ly = EgtGetNextGroup( Ly) + end + end + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindGroupWithPartName( Pz, sNameFind, ListPrev) + local List = {} + local PzIsTab = type(Pz) == 'table' + if ListPrev then + for i = 1, #ListPrev do + table.insert( List, ListPrev[i]) + end + end + local nMaxPz = 1 + if PzIsTab then nMaxPz = #Pz end + for i = 1, nMaxPz do + local nIdPz + if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end + local Ent = EgtGetFirstInGroup( nIdPz) + while Ent do + local sNameEnt = EgtGetName(Ent) + if sNameEnt and string.find( sNameEnt, sNameFind) then + table.insert( List, Ent) + end + Ent = EgtGetNext( Ent) + end + end + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindEntitiesWithPartName( Pz, sNameFind, ListPrev, sInfoName, nInfoValue) + local List = {} + local ListTwo = {} + local PzIsTab = type(Pz) == 'table' + if ListPrev then + for i = 1, #ListPrev do + table.insert( List, ListPrev[i]) + end + end + local nMaxPz = 1 + if PzIsTab then nMaxPz = #Pz end + for i = 1, nMaxPz do + local nIdPz + if PzIsTab then nIdPz = Pz[i] else nIdPz = Pz end + local Ly = EgtGetFirstGroupInGroup( nIdPz) + while Ly do + local Ent = EgtGetFirstInGroup( Ly) + while Ent do + local sNameEnt = EgtGetName(Ent) + if sNameEnt and string.find( sNameEnt, sNameFind) then + -- se note da ricercare + if sInfoName and nInfoValue and #sInfoName > 0 and nInfoValue > 0 then + -- se nota corrisponde + if EgtGetInfo( Ent, sInfoName, 'i') == nInfoValue then + table.insert( ListTwo, Ent) + else + table.insert( List, Ent) + end + else + table.insert( List, Ent) + end + end + Ent = EgtGetNext( Ent) + end + Ly = EgtGetNextGroup( Ly) + end + end + return List, ListTwo +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindEntities( Pz, bSingle) + local List = {} + local Ly = EgtGetFirstInGroup( Pz) + while Ly do + if bSingle then + return Ly -- esco appena ha trovato il primo trovato + else + table.insert( List, Ly) -- inserisco a tabella + end + Ly = EgtGetNext( Ly) + end + + if bSingle then + return nil + else + return List + end +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindGeomWithName( Pz, sName, bSingle, ListPrev) + local List = {} + if ListPrev and not bSingle then + for i = 1, #ListPrev do + table.insert( List, ListPrev[i]) + end + end + local Ly = EgtGetFirstInGroup( Pz) + while Ly do + local Ent = EgtGetName( Ly) + if Ent == sName then + if bSingle then + return Ly -- esco appena ha trovato il primo elemento + else + table.insert( List, Ly) -- inserisco a tabella + end + end + Ly = EgtGetNext( Ly) + end + + if bSingle then + return nil + else + return List + end +end + +-------------------------------------------------------------------------------- +function MachiningBase.FindGeomWithNote( Pz, sNote, sTypeNote, NoteToFind, ListPrev) + local List = {} + if ListPrev then + for i = 1, #ListPrev do + table.insert( List, ListPrev[i]) + end + end + local Ly = EgtGetFirstInGroup( Pz) -- ottengo il primo layer + while Ly do + -- ottengo la prima entità del layer + local Lx = EgtGetFirstInGroup( Ly) + while Lx do + local Ent = EgtGetInfo( Lx, sNote, sTypeNote) + if sTypeNote == 'b' then -- se nota booleana + if Ent then -- se trovata nota boolena + table.insert( List, Lx) -- inserisco a tabella + end + else + if Ent == NoteToFind then + table.insert( List, Lx) -- inserisco a tabella + end + end + Lx = EgtGetNext( Lx) + end + Ly = EgtGetNext( Ly) + end + + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.GetHingesBoxes( Pz, tabOriX) + local List = {} + local Ly = EgtGetFirstGroupInGroup( Pz) + while Ly do + local sName = EgtGetName( Ly) + if sName and string.find( sName, 'Hinge', 1, true) then + local b3Box = EgtGetBBoxGlob( Ly, GDB_BB.STANDARD) + if b3Box then + table.insert( List, b3Box:getMin():getX() - tabOriX) + table.insert( List, b3Box:getMax():getX() - tabOriX) + end + end + Ly = EgtGetNextGroup( Ly) + end + return List +end + +-------------------------------------------------------------------------------- +function MachiningBase.ReorderGroup( EntId, tOrderGrp, nDirToIns) + + local nParendId = EgtGetParent(EntId) + local b3Grp = EgtGetBBoxGlob( nParendId, GDB_BB.STANDARD) + local dRefGrp = EgtIf( nDirToIns > 0, b3Grp:getMin():getX(), b3Grp:getMax():getX()) + + -- controllo dalla nota se non è già stata lavorata prima + local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0 + + -- se già lavorata annullo valore disabilitante + if nSetSide >= 10 then + EgtSetInfo( EntId, 'Mach', 0) + end + + -- se trovato minimo lo assegno in testa + if #tOrderGrp == 0 then + table.insert( tOrderGrp, { nParendId, dRefGrp}) + else + + local bInsert = false + local bfoundGroup = false + for i = 1, #tOrderGrp do + -- se trovato minimo lo inserisco in tabella e ne riloco il gruppo nell'albero + local nIdParTab = tOrderGrp[i] + if nDirToIns > 0 then + if dRefGrp < nIdParTab[2] then + table.insert( tOrderGrp, i,{ nParendId, dRefGrp}) + EgtRelocateGlob( nParendId, nIdParTab[1], GDB_IN.BEFORE) + bInsert = true + break + elseif nParendId == nIdParTab[1] then -- se gruppo già presente esco + bfoundGroup = true + break + end + else + if dRefGrp > nIdParTab[2] then + table.insert( tOrderGrp, i,{ nParendId, dRefGrp}) + EgtRelocateGlob( nParendId, nIdParTab[1], GDB_IN.BEFORE) + bInsert = true + break + elseif nParendId == nIdParTab[1] then -- se gruppo già presente esco + bfoundGroup = true + break + end + end + end + + -- se non inserito lo inserisco in coda senza rilocamento + if not bInsert and not bfoundGroup then + table.insert( tOrderGrp, { nParendId, dRefGrp}) + end + end +end + +-------------------------------------------------------------------------------- +function MachiningBase.GetGroup( tLocMachOrd, ind, nNumGroup, sProperty) + + local tSubGroup = {} + local nIdt = ind + if sProperty and #sProperty > 0 then -- acquisisco tutto il gruppo + for j = ind, #tLocMachOrd do + if tLocMachOrd[j].Group == nNumGroup then + table.insert( tSubGroup, tLocMachOrd[j]) + nIdt = j + else -- se non è più lo stesso gruppo esco + break + end + end + else + table.insert( tSubGroup, tLocMachOrd[nIdt]) -- restituisco solo una linea della tabella + end + return tSubGroup, nIdt +end + +-------------------------------------------------------------------------------- +function MachiningBase.LoadEntitiesFromGroup( tGroup, Pz, sSuffix) + + local EntList + + for j = 1, #tGroup do + EntList = MachiningBase.FindEntitiesWithName( Pz, tGroup[j].Name..sSuffix, EntList) + end + + return EntList +end + +-------------------------------------------------------------------------------- +function MachiningBase.InsZedByTool( TabZMach, tMachining, nInd) + + local bFind = false + local nMaxVal = 0 + + for i = 1, nInd-1 do + if tMachining[nInd][2] == tMachining[i][2] then -- se utensile uguale assegno identico valore + table.insert( TabZMach, TabZMach[i]) -- inserisco lo stesso valore + bFind = true + break -- esco dal ciclo + else + nMaxVal = max( nMaxVal, (TabZMach[i] or 0)) + end + end + + if not bFind then -- se non ho trovato aggiungo nuovo valore alla Z utensile + table.insert( TabZMach, ( nMaxVal+10000)) + end +end + +-------------------------------------------------------------------------------- +function MachiningBase.OrderEnt( tListEntSameMach, EndLastMach, nModeOrder) + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabResult = {} + local dStart = -2000 + + if nModeOrder and nModeOrder == 1 then + dStart = 10000 + end + + for m = 1, #tListEntSameMach do + local ptStart = EgtSP( tListEntSameMach[m], GDB_ID.ROOT ) + if ptStart then + table.insert( TabMill, tListEntSameMach[m]) + table.insert( TabMStEnP, ptStart) + end + end + -- calcolo ordinamento + EgtSpInit() + for m = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[m]:getX(), TabMStEnP[m]:getY(), TabMStEnP[m]:getZ(), 0, 0, + TabMStEnP[m]:getX(), TabMStEnP[m]:getY(), TabMStEnP[m]:getZ(), 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,dStart,0,0,90,90) + end + local vMillOrd + if not nModeOrder or nModeOrder == 0 then + vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + elseif nModeOrder == 1 then + vMillOrd = EgtSpCalculate(SHP_TY.ONEWAY_XP) + else + vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + end + EgtSpTerminate() + -- applico ordinamento calcolato + if vMillOrd and #vMillOrd == #tListEntSameMach then + for m = 1, #vMillOrd do + table.insert( TabResult, TabMill[vMillOrd[m]]) + end + tListEntSameMach = TabResult + end + + return tListEntSameMach +end + +-------------------------------------------------------------------------------- +function MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, nMaxNum) + + -- recupero note percorso + local bCutByBlade = EgtGetInfo( EntId, 'UseBlade', 'b') + local bCutByTwiceBlade = EgtGetInfo( EntId, 'UseTwiceBl', 'b') + + -- se utilizzata lama + if bCutByBlade then + -- se uso doppia lama assegno la seconda lavorazione + if bCutByTwiceBlade then + -- lavorazione 2nd + EgtSetInfo( EntId, 'Mach', nMaxNum) + return nMaxNum + else -- altrimenti leggo altre note + + local sSideApp = EgtGetInfo( EntId, 'SideApp', 's') + local nTypePath = EgtGetInfo( EntId, 'TypePath', 'i') + + if sSideApp and nTypePath then + if sSideApp == 'hinge' or sSideApp == 'lock' then + if bFlipDoor then -- se porta ribaltata + if nTypePath == 1 then -- se percorso antisplint 1 + EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito + return nMaxNum + else -- percorso antisplint 2 + EgtRemoveInfo( EntId, 'Mach') + return 0 + end + else -- non ribaltata + if nTypePath == 1 then -- se percorso antisplint 1 + EgtRemoveInfo( EntId, 'Mach') + return 0 + else -- percorso antisplint 2 + EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito + return nMaxNum + end + end + else + if ( sSideApp == 'top' and nDispType > 0) or ( sSideApp == 'bottom' and nDispType < 0 ) then + if nTypePath == 1 then -- se percorso lato hinge + EgtRemoveInfo( EntId, 'Mach') + return 0 + else -- se percorso lato lock + EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito + return nMaxNum + end + else + if nTypePath == 1 then -- se percorso lato hinge + EgtSetInfo( EntId, 'Mach', nMaxNum) -- eventualmente lo disabilito + return nMaxNum + else -- se percorso lato lock + EgtRemoveInfo( EntId, 'Mach') + return 0 + end + end + end + end + end + else + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + end + + return 0 +end + +----------------------------------------------------------------- +-- *** Machining Functions *** +----------------------------------------------------------------- +----------------------------------------------------------------- +function MachiningBase.ModifyLiLoToExt() + + -- leggo il parametro di lunghezza perpendicolare di ingresso + local dLenIniPerp = EgtGetMachiningParam( MCH_MP.LIPERP) + local sTuuid = EgtGetMachiningParam( MCH_MP.TUUID) + local sTool = EgtTdbGetToolFromUUID( sTuuid) + EgtTdbSetCurrTool( sTool) + local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + + if dLenIniPerp then + if dLenIniPerp > 0 then + dLenIniPerp = -dLenIniPerp + else -- altrimenti è a 0 + dLenIniPerp = -(dDiam*0.55) + end + else -- altrimenti lo calcolo dall'utensile + dLenIniPerp = -(dDiam*0.55) + end + + -- cambio il lead-in a lineare + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) + + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0.762) + + -- setto a 0 la lunghezza tangente ingresso + EgtSetMachiningParam( MCH_MP.LITANG, 0) + + -- setto il valore di distanza perpendicolare uscita come quella dell'ingresso + EgtSetMachiningParam( MCH_MP.LIPERP, dLenIniPerp) + + -- setto a 0 l'elevazione iniziale + EgtSetMachiningParam( MCH_MP.LIELEV, 0) + + -- setto a 0 l'inserimento correttore attacco + EgtSetMachiningParam( MCH_MP.LICOMPLEN , 0) + + -- cambio il lead-out a lineare + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) + + -- 2019/12/20 setto a -0.6 il valore di distanza perpendicolare + -- 2020/05/18 setto a 0 il valore di distanza perpendicolare + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + -- setto a 0 l'allungamento finale +-- EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + + -- setto a 0 il valore tangente finale + EgtSetMachiningParam( MCH_MP.LOTANG, 0) + + -- 2019/12/20 setto a 0 il valore di distanza perpendicolare + EgtSetMachiningParam( MCH_MP.LOPERP, 0) + -- setto il valore di distanza perpendicolare uscita come quella dell'ingresso +-- EgtSetMachiningParam( MCH_MP.LOPERP, dLenIniPerp) + + -- setto a 0 l'elevazione + EgtSetMachiningParam( MCH_MP.LOELEV, 0) + + -- setto a 0 l'inserimento correttore uscita + EgtSetMachiningParam( MCH_MP.LOCOMPLEN , 0) + + -- disabilito eventuale oscillazione + EgtSetMachiningParam( MCH_MP.OSCENABLE, false) + + -- setto a 0 la sovrapposizione 2019/12/20 + EgtSetMachiningParam( MCH_MP.OVERL , 0) +end + +----------------------------------------------------------------- +function MachiningBase.ModifyLiLo( sLeadCode, bRevCode, sPathType, sToolUse, dCalcLead, dPercFeedVal, sDirType) + + -- leggo il parametro di lunghezza perpendicolare di ingresso + local dLenIniPerp = EgtGetMachiningParam( MCH_MP.LIPERP) + -- leggo il parametro feed per moltiplicarlo con il fattore di riduzione per l'ingresso nel pieno + local dFeedVal = EgtGetMachiningParam( MCH_MP.FEED) + + -- cambio il lead-in a lineare + EgtSetMachiningParam( MCH_MP.LEADINTYPE, MCH_MILL_LI.LINEAR) + + if bRevCode and ( sLeadCode == '_NLI' or sLeadCode == '_NLO') then + if sPathType and sPathType == 'NR' and sToolUse then + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) + -- cambio la feed di ingresso con la Feed ricalcolata con il parametro + EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal)) + else + if sDirType == 'INV' then + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) + -- cambio la feed di ingresso con la Feed ricalcolata con il parametro + EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal)) + else + -- setto al valore l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead) + end + end + elseif ( not bRevCode and sLeadCode == '_NLO') then + if sPathType and sPathType == 'NR' and sToolUse then + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) + -- cambio la feed di ingresso con la Feed ricalcolata con il parametro + EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal)) + else + -- setto al valore l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead) + end + elseif ( not bRevCode and sLeadCode == '_NLI') then + if sDirType == 'INV' then + -- setto al valore l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dCalcLead) + else + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) + -- cambio la feed di ingresso con la Feed ricalcolata con il parametro + EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal)) + end + else + -- setto a 0 l'allungamento iniziale + EgtSetMachiningParam( MCH_MP.STARTADDLEN, 0) + -- cambio la feed di ingresso con la Feed ricalcolata con il parametro + EgtSetMachiningParam( MCH_MP.STARTFEED, (dFeedVal*dPercFeedVal)) + end + + -- setto a 0 la lunghezza tangente ingresso + EgtSetMachiningParam( MCH_MP.LITANG, 0) + -- cambio il lead-out a lineare + EgtSetMachiningParam( MCH_MP.LEADOUTTYPE, MCH_MILL_LI.LINEAR) + + if ( bRevCode and sLeadCode == '_NLO') then -- Se percorso REV con niente uscita + if sPathType and sPathType == 'NR' then -- se percorso di andata + -- setto al valore l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead) + else + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + end + elseif ( bRevCode and sLeadCode == '_NLI') then -- Se percorso REV con niente ingresso + if sPathType and sPathType == 'NR' then -- se percorso di andata + if sDirType == 'INV' then + -- setto al valore l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead) + else + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + end + else + -- setto al valore l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead) + end + elseif ( not bRevCode and sLeadCode == '_NLI') then + if sPathType and sPathType == 'NR' and sToolUse then + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + else + if sDirType == 'INV' then + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + else + -- setto al valore l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead) + end + end + elseif ( not bRevCode and sLeadCode == '_NLO') then + if sPathType and sPathType == 'NR' and sToolUse then + -- setto al valore l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dCalcLead) + else + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + end + else + -- setto a 0 l'allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, 0) + end + + -- setto a 0 il valore tangente finale + EgtSetMachiningParam( MCH_MP.LOTANG, 0) + -- setto il valore di distanza perpendicolare uscita come quella dell'ingresso + EgtSetMachiningParam( MCH_MP.LOPERP, dLenIniPerp) +end + +----------------------------------------------------------------- +function MachiningBase.AddAndDelMachining( sName, sMach, tEntId, dOverL, sOriName, + bNotGenMachining, sCodeKeepBackSet, dBladePerpLeadIn, dPercRedFeed, sCodeProbeSide, + sActiveStop, sSetMaxElev, dOverR, bSandFound, dAddLength, + dAddSandLength, bNarrowDoor) + local sEntId = '' + local tParentId = {} + local sNotesMach + local nCheckLink + for t = 1, #tEntId do + if tEntId[t] then + if not bNotGenMachining then + -- load the Link value if exists + if not nCheckLink or nCheckLink == 0 then + nCheckLink = EgtGetInfo( tEntId[t], 'LinkCode', 'i') or 0 + end + -- acquisisco le note Parent delle entità + table.insert( tParentId, EgtGetInfo( tEntId[t], 'Parent', 'i')) + end + sEntId = sEntId .. tEntId[t] .. ',' + end + end + if not sMach or ( sMach and #sMach == 0) then + DGD.ERM = DGD.ERM .. string.format( EgtDoorsMsg[483], sOriName, sEntId) + return 0 -- nome lavorazione vuoto + end + local nMach = EgtAddMachining( sName, sMach) + local sTool + if not nMach then + DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[484], sMach, sOriName, sEntId) + return -1 -- lavorazione mancante o errata + end + if dOverL then -- se c'è un valore, assegno sovramateriale in lunghezza + EgtSetMachiningParam( MCH_MP.OFFSL, dOverL) + end + if dOverR and dOverR > 0 then -- se c'è un valore, assegno offset sul raggio + EgtSetMachiningParam( MCH_MP.OFFSR, dOverR) + end + if sCodeKeepBackSet then -- se c'è un valore, assegno codice correzione in Z + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice + EgtSetMachiningParam( MCH_MP.USERNOTES, sCodeKeepBackSet..';') + else -- altrimenti se non è vuota verifico se c'è o no + -- verifico se c'é già parte iniziale del codice 'CORR_Z_PROBE' settato nel Machining_xvx nella funzione InsertMachiningByMachNum + local sFirst = string.sub( sCodeKeepBackSet, 1, 12) + local nPosFind, _ = sNotesMach:find( sFirst, 1, true) + if nPosFind then -- se ho già la prima parte + if not sNotesMach:find( sCodeKeepBackSet, 1, true) then -- se non ho la stessa nota la sostituisco + sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 14), sCodeKeepBackSet) + end + else -- se non ho la prima parte la aggiungo + sNotesMach = sNotesMach..sCodeKeepBackSet..';' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach) + end + end + end + if sCodeProbeSide then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice + EgtSetMachiningParam( MCH_MP.USERNOTES, sCodeProbeSide..';') + else -- altrimenti se non è vuota verifico se c'è o no + -- verifico se c'é già parte iniziale del codice 'CPBP' settato nel Machining_xvx nella funzione InsertMachiningByMachNum + local sFirst = string.sub( sCodeProbeSide, 1, 4) + local nPosFind, _ = sNotesMach:find( sFirst, 1, true) + if nPosFind then -- se ho già la prima parte + if not sNotesMach:find( sCodeProbeSide, 1, true) then -- se non ho la stessa nota la sostituisco + sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 4), sCodeProbeSide) + end + else -- se non ho la prima parte la aggiungo + sNotesMach = sNotesMach..sCodeProbeSide..';' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach) + end + end + end + if sActiveStop then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice + EgtSetMachiningParam( MCH_MP.USERNOTES, sActiveStop..';') + else -- altrimenti se non è vuota verifico se c'è o no + -- verifico se c'é già parte iniziale del codice 'ActiveStopMach' settato nel Machining_xvx nella funzione InsertMachiningByMachNum + local sFirst = string.sub( sActiveStop, 1, 14) + local nPosFind, _ = sNotesMach:find( sFirst, 1, true) + if nPosFind then -- se ho già la prima parte + if not sNotesMach:find( sActiveStop, 1, true) then -- se non ho la stessa nota la sostituisco + sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 16), sActiveStop) + end + else -- se non ho la prima parte la aggiungo + sNotesMach = sNotesMach..sActiveStop..';' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach) + end + end + end + if sSetMaxElev then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if not sNotesMach or #sNotesMach == 0 then -- se la nota è vuota aggiungo il codice + EgtSetMachiningParam( MCH_MP.USERNOTES, sSetMaxElev..';') + else -- altrimenti se non è vuota verifico se c'è o no + -- verifico se c'é già parte iniziale del codice 'MaxElev' settato nel Machining_xvx nella funzione InsertMachiningByMachNum + local sFirst = string.sub( sSetMaxElev, 1, 7) + local nPosFind, _ = sNotesMach:find( sFirst, 1, true) + if nPosFind then -- se ho già la prima parte + if not sNotesMach:find( sSetMaxElev, 1, true) then -- se non ho la stessa nota la sostituisco + sNotesMach = string.gsub( sNotesMach, string.sub( sNotesMach, nPosFind, 11), sSetMaxElev) + end + else -- se non ho la prima parte la aggiungo + sNotesMach = sNotesMach..sSetMaxElev..';' + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach) + end + end + end + if bSandFound and dAddLength and dAddLength > 0 then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota cerco la lavorazione di profilatura + local sProfFind_LK, _ = sNotesMach:find( 'TRIM_LK', 1, true) + local sProfFind, _ = sNotesMach:find( 'TRIM_', 1, true) + local sProfAdded, _ = sNotesMach:find( 'ADD_EXTENDED', 1, true) + -- se trovata lavorazione trim e non è stata ancora allungata (nella parte finale) + if sProfFind and not sProfAdded then + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach .. 'ADD_EXTENDED'..';') + -- applico l'allungamento se non è percorso lock e non è una porta stretta + if not (sProfFind_LK and bNarrowDoor) then + EgtSetMachiningParam( MCH_MP.ENDADDLEN, dAddLength) + end + end + end + end + if bSandFound and dAddSandLength and dAddSandLength > 0 then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota cerco la lavorazione di profilatura + local sSandFind, _ = sNotesMach:find( 'SAND_', 1, true) + local sProfAdded, _ = sNotesMach:find( 'ADD_EXTENDED', 1, true) + -- se trovata lavorazione sand e non è stata ancora allungata (nella parte iniziale) + if sSandFind and not sProfAdded then + EgtSetMachiningParam( MCH_MP.USERNOTES, sNotesMach .. 'ADD_EXTENDED'..';') + EgtSetMachiningParam( MCH_MP.STARTADDLEN, dAddSandLength) + end + end + end + + local bSetMach = EgtSetMachiningGeometry( tEntId) + -- se creo effettivamente la lavorazione controllo se ho le note per la modifica degli attacchi + if not bNotGenMachining then + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + for t = 1, #tEntId do + if tEntId[t] then + local sPathType = EgtGetInfo( tEntId[t], 'PathType', 's') + local sToolUse = EgtGetInfo( tEntId[t], 'ToolsUse', 's') + local sTypeLead = EgtGetInfo( tEntId[t], 'LeadType', 's') + local sInvDir = EgtGetInfo( tEntId[t], 'InvDir', 's') + local nDirType = EgtGetInfo( tEntId[t], 'RevMach', 'i') + local nStFromExt = EgtGetInfo( tEntId[t], 'StartFromExt', 'i') + + if nDirType and sPathType and sPathType == 'NR' and not sToolUse then -- se percorso REV singolo + -- leggo il lato di lavoro +-- local nWorkSide = EgtGetMachiningParam( MCH_MP.WORKSIDE) +-- if nWorkSide and nWorkSide == MCH_MILL_WS.LEFT then -- se lato sinistro +-- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.RIGHT) +-- elseif nWorkSide and nWorkSide == MCH_MILL_WS.RIGHT then -- se lato destro +-- EgtSetMachiningParam( MCH_MP.WORKSIDE, MCH_MILL_WS.LEFT) +-- end + --inverto il percorso di lavoro + EgtSetMachiningParam( MCH_MP.INVERT, true) + end + + if sTypeLead then -- se ho una nota di lead-in/out + MachiningBase.ModifyLiLo( sTypeLead, nDirType, sPathType, sToolUse, dBladePerpLeadIn, dPercRedFeed, sInvDir) + end + if nStFromExt then -- se ho una nota di lead-in/out dall'esterno + MachiningBase.ModifyLiLoToExt() + end + -- fermo il ciclo + break + end + end + -- se lavorazione ha le note opportune, + -- rifaccio il ciclo sulle entità/lavorazione per applicare la riduzione della lunghezza lavorata + if string.find( sNotesMach, 'HALF_LENGTH') then + for t = 1, #tEntId do + if tEntId[t] then + local dPathLen = EgtCurveLength( tEntId[t]) or 0.0 + if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso + -- setto il valore di riduzione allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -(( dPathLen/2)-1)) + end + end + end + end + local nPosFound = string.find( sNotesMach, 'CUT_LENGTH') + if nPosFound then + local sParz = string.sub( sNotesMach, nPosFound) + nPosFound = string.find( sParz, ';') + local sTrimmed + if nPosFound then + sTrimmed = string.sub( sParz, 1, nPosFound-1) + else + sTrimmed = sParz + end + if sTrimmed and #sTrimmed > 0 then + local sValue = string.sub( sTrimmed, 12) + if sValue and #sTrimmed > 0 then + local dVal = tonumber( sValue) + if dVal and abs(dVal) > GEO.EPS_SMALL then + for t = 1, #tEntId do + if tEntId[t] then + local dPathLen = EgtCurveLength( tEntId[t]) or 0.0 + if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso + -- setto il valore di riduzione allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -( dPathLen - abs(dVal))) + end + end + end + end + end + end + end + -- se non genero la lavorazione leggo comunque le note + else + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + end + local bApplyMach = EgtApplyMachining() + if not bNotGenMachining and ( not bSetMach or not bApplyMach) then + if not bSetMach or not bApplyMach then + local nIdErr, sIdErr = EgtGetLastMachMgrError() + DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[598], sMach, sOriName, sEntId, nIdErr, sIdErr) + else + DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[485], sMach, sOriName, sEntId) + end + return -1 + end + if bNotGenMachining then + EgtRemoveOperation( nMach) + -- ripristino ultima lavorazione rimasta + local nOper = EgtGetLastActiveOperation() or GDB_ID.NULL + local nType = EgtGetOperationType( nOper) + if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then + EgtSetCurrMachining( nOper) + EgtApplyMachining() + end + nMach = nil + else + sTool = EgtGetMachiningParam( MCH_MP.TOOL ) + -- if link value different than 0 write info to machining + if abs(nCheckLink) > 0 then + EgtSetInfo( nMach, 'Link', nCheckLink) + if #tParentId > 0 and tParentId[1] then + EgtSetInfo( nMach, 'Parent', tParentId[1]) + end + -- if link value is negative disable the machining + if nCheckLink < 0 then + EgtSetOperationMode( nMach, false) + end + end +-- sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + end + return 1, nMach, sTool, sNotesMach +end + +-------------------------------------------------------------------------------- +function MachiningBase.AddMachining( sName, sMach, tEntId, dOverL, sOriName) + local sEntId = '' + local sNotesMach + for t = 1, #tEntId do + sEntId = sEntId .. tEntId[t] .. ',' + end + if not sMach or ( sMach and #sMach == 0) then + DGD.ERM = DGD.ERM .. string.format( EgtDoorsMsg[483], sOriName, sEntId) + return true + end + local nMach = EgtAddMachining( sName, sMach) + if not nMach then + DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[484], sMach, sOriName, sEntId) + return false + end + if dOverL then + EgtSetMachiningParam( MCH_MP.OFFSL, dOverL) + end + if not EgtSetMachiningGeometry( tEntId) or not EgtApplyMachining() then + local nIdErr, sIdErr = EgtGetLastMachMgrError() + DGD.EMC = DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[598], sMach, sOriName, sEntId, nIdErr, sIdErr) + return false + end + -- ottengo le note lavorazione + sNotesMach = EgtGetMachiningParam( MCH_MP.USERNOTES) + if string.find( sNotesMach, 'HALF_LENGTH') then + for t = 1, #tEntId do + if tEntId[t] then + local dPathLen = EgtCurveLength( tEntId[t]) or 0.0 + if dPathLen > 0 then -- se nelle note trovata la nota di ridurre il percorso + -- setto il valore di riduzione allungamento finale + EgtSetMachiningParam( MCH_MP.ENDADDLEN, -(( dPathLen/2)-1)) + end + end + end + end + + return true +end + +-------------------------------------------------------------------------------- +function MachiningBase.MakeRoughPaths ( dSideOverMat, dMaxOverMat, dStepOverMat, nIdEnt, bTopBottPart, bFlip, bAlreadyMachSide, dBevelOffs, nScrapMode) + + local bMadeMach = bAlreadyMachSide + + if not bAlreadyMachSide and dMaxOverMat and dSideOverMat > dMaxOverMat then + + -- creo passate di sgrossatura + local nHorStep = ceil(dSideOverMat / dStepOverMat) + -- se modalità remove scrap abilitata setto una sola passata + if nScrapMode and nScrapMode == 1 then + nHorStep = 1 + end + local dHorStep = dStepOverMat + local nPassHor = 1 + local nSideOffs = EgtIf( bFlip, -1, 1) + local nNumEnt1, nNumEnt2 = EgtCurveDomain( nIdEnt) + local bSimpleLine = (nNumEnt2 - nNumEnt1) == 1 + local pIni = EgtSP( nIdEnt) + local pMid = EgtMP( nIdEnt) + local pEnd = EgtEP( nIdEnt) + local nParId = EgtGetParent(nIdEnt) + local dOffsBevel = 0 + if dBevelOffs and dBevelOffs > 0 then -- se profilo bevel + dOffsBevel = dBevelOffs * nSideOffs + end + + while nPassHor <= nHorStep do + + local nLine + if bSimpleLine then + nLine = EgtArc3P( nParId, pIni, pMid, pEnd, GDB_RT.LOC) + else -- faccio la copia del percorso + nLine = EgtCopy( nIdEnt, nParId, GDB_RT.LOC) + EgtModifyCurveExtrusion( nLine, Z_AX(), GDB_RT.LOC) + end + + EgtOffsetCurve( nLine, ( dOffsBevel + ( dHorStep * ( nPassHor-1) * nSideOffs))) + EgtModifyCurveExtrusion( nLine, Z_AX(), GDB_RT.GLOB) + + if nLine then + bMadeMach = true + + if bTopBottPart then + EgtSetName( nLine, 'ROUGH_H_' .. EgtNumToString(nPassHor,0)) + else + EgtSetName( nLine, 'ROUGH_' .. EgtNumToString(nPassHor,0)) + end + end + + nPassHor = nPassHor + 1 + end -- end while + end + + return bMadeMach +end + +----------------------------------------------------------------- +-- *** Adjust Geometries Functions (Operations) *** +----------------------------------------------------------------- +-------------------------------------------------------------------------------- +function MachiningBase.AdjustBevel( EntId, EntName, bFirstStep, bNoVertCurve, bMakeGhostGeom, bNoModifyPath, bSkipOnSecCol) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + local sNewName = EntName + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + -- sposto la curva, inverto l'estrusione + local dTh = EgtCurveThickness( EntId) + -- sposto la curva in basso lungo il versore + EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB) + if not bNoVertCurve then + if not bNoModifyPath then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + end + else + -- sistemo l'estrusione e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, dTh) + EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB) + end + -- inverto la curva + EgtInvertCurve( EntId) + + -- cambio il nome + if EntName == 'BU' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BD'..DGD.GHT) + else + EgtSetName( EntId, 'BD') + end + sNewName = 'BD' + elseif EntName == 'BU_H' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BD_H'..DGD.GHT) + else + EgtSetName( EntId, 'BD_H') + end + sNewName = 'BD' + elseif EntName == 'BU_LK' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BD_LK'..DGD.GHT) + else + EgtSetName( EntId, 'BD_LK') + end + sNewName = 'BD' + elseif EntName == 'BD' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BU'..DGD.GHT) + else + EgtSetName( EntId, 'BU') + end + sNewName = 'BU' + elseif EntName == 'BD_H' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BU_H'..DGD.GHT) + else + EgtSetName( EntId, 'BU_H') + end + sNewName = 'BU' + elseif EntName == 'BD_LK' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BU_LK'..DGD.GHT) + else + EgtSetName( EntId, 'BU_LK') + end + sNewName = 'BU' + elseif EntName then + if string.find( EntName, 'BU_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach')) + end + sNewName = 'BD' + elseif string.find( EntName,'BUEB') then -- bevel con edge break lato serratura + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BUEB', 'BDEB') .. DGD.GHT) + else + EgtSetName( EntId, string.gsub( EntName, 'BUEB', 'BDEB')) + end + sNewName = 'BD' + elseif string.find( EntName, 'BD_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach')) + end + sNewName = 'BU' + elseif string.find( EntName,'BDEB') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BDEB', 'BUEB') .. DGD.GHT) + else + EgtSetName( EntId, string.gsub( EntName, 'BDEB', 'BUEB')) + end + sNewName = 'BU' + end + end + + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + else + -- se devo utilizzare seconda colonna + if bSkipOnSecCol then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + end + end + else + + if not bNoVertCurve and not bNoModifyPath then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + local dTh = EgtCurveThickness( EntId) + EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + end + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + else + -- se devo utilizzare seconda colonna + if bSkipOnSecCol then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + end + end + end + return true, sNewName, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustConeCleanPaths( EntId, bMakeGhostGeom, bKeepDir, nSolidLayer) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + -- prendo il punto medio in Z dall'id del solido passato o dalla geometria stessa + local b3Solid + if not nSolidLayer then + b3Solid = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD) + else + b3Solid = EgtGetBBoxGlob( nSolidLayer, GDB_BB.STANDARD) + end + local ptMidZ = ( b3Solid:getMin():getZ() + b3Solid:getMax():getZ()) /2 + EgtMirror( EntId, Point3d(0,0,ptMidZ), Z_AX(), GDB_ID.ROOT) -- faccio il mirror su asse Z + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustThrouCurve( EntId, bMakeGhostGeom, bKeepDir, bKeepDirZPos, bSkipOnSecCol) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + local dTh = EgtCurveThickness( EntId) + EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB) + EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + if not bKeepDir then + EgtInvertCurve( EntId) + end + else + if bKeepDirZPos then + EgtInvertCurve( EntId) + end + end + + -- se devo utilizzare seconda colonna + if bSkipOnSecCol then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + else + -- nessuna nota + EgtRemoveInfo( EntId, 'Mach') + end + + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjPrfThrouCurveNew( EntId, bMakeGhostGeom, bFoundProperty, bNoVertCurve, bFirstStep, EntName) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local sNewName = EntName + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + -- sposto la curva, inverto l'estrusione + local dTh = EgtCurveThickness( EntId) + -- sposto la curva in basso lungo il versore + EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB) + if not bNoVertCurve then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + else + -- sistemo l'estrusione e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, dTh) + EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB) + end + -- inverto la curva + EgtInvertCurve( EntId) + + -- cambio il nome + if EntName == 'BU' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BD'..DGD.GHT) + else + EgtSetName( EntId, 'BD') + end + sNewName = 'BD' + elseif EntName == 'BD' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BU'..DGD.GHT) + else + EgtSetName( EntId, 'BU') + end + sNewName = 'BU' + elseif EntName then + if string.find( EntName, 'BU_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach')) + end + sNewName = 'BD' + elseif string.find( EntName, 'BD_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach')) + end + sNewName = 'BU' + end + end + else -- se diretto verso l'alto + + if not bNoVertCurve then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + local dTh = EgtCurveThickness( EntId) + EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + end + end + -- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2 + -- disabilito la ricerca perché ho già passato la variabile che indica se è stata trovata la proprietà + local bMatchProp = bFoundProperty + + -- se ho trovato corrispondenza di proprietà + if bMatchProp then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + else + -- nessuna nota + EgtRemoveInfo( EntId, 'Mach') + end + + return true, EntId, sNewName +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjPrfThrouCurve( EntId, bMakeGhostGeom, tsProperties, sFind, bNoVertCurve, bFirstStep, EntName) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local sNewName = EntName + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + -- sposto la curva, inverto l'estrusione + local dTh = EgtCurveThickness( EntId) + -- sposto la curva in basso lungo il versore + EgtMove( EntId, vtExtr * dTh, GDB_RT.GLOB) + if not bNoVertCurve then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, - dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + else + -- sistemo l'estrusione e aggiusto lo spessore di conseguenza + EgtModifyCurveThickness( EntId, dTh) + EgtModifyCurveExtrusion( EntId, -vtExtr, GDB_RT.GLOB) + end + -- inverto la curva + EgtInvertCurve( EntId) + + -- cambio il nome + if EntName == 'BU' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BD'..DGD.GHT) + else + EgtSetName( EntId, 'BD') + end + sNewName = 'BD' + elseif EntName == 'BD' then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, 'BU'..DGD.GHT) + else + EgtSetName( EntId, 'BU') + end + sNewName = 'BU' + elseif EntName then + if string.find( EntName, 'BU_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BU_Mach', 'BD_Mach')) + end + sNewName = 'BD' + elseif string.find( EntName, 'BD_Mach') then + if bMakeGhostGeom or not bFirstStep then + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU'..DGD.GHT..'_Mach')) + else + EgtSetName( EntId, string.gsub( EntName, 'BD_Mach', 'BU_Mach')) + end + sNewName = 'BU' + end + end + else -- se diretto verso l'alto + + if not bNoVertCurve then + -- rendo l'estrusione verticale e aggiusto lo spessore di conseguenza + local dTh = EgtCurveThickness( EntId) + EgtModifyCurveThickness( EntId, dTh * vtExtr:getZ()) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + end + end + -- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2 + local bMatchProp = FindProperty( tsProperties, sFind) + + -- se ho trovato corrispondenza di proprietà + if bMatchProp then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + else + -- nessuna nota + EgtRemoveInfo( EntId, 'Mach') + end + + return true, EntId, sNewName +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustVertCurve( EntId, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + local dTh = EgtCurveThickness( EntId) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + -- lavorazione 2nd + EgtSetInfo( EntId, 'Mach', 2) + else + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustBladeVertCurve( EntId, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se diretto verso il basso + if vtExtr:getZ() < 0 then + local dTh = EgtCurveThickness( EntId) + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + local sPathInfo = EgtGetInfo( EntId, 'PathType', 's') + local sToolsUse = EgtGetInfo( EntId, 'ToolsUse', 's') + if sPathInfo and sPathInfo == 'NR' and not sToolsUse then -- se percorso singolo genero prima colonna + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + else + -- lavorazione 2nd + EgtSetInfo( EntId, 'Mach', 2) + end + -- setto una nota aggiuntiva del parametro mach + EgtSetInfo( EntId, 'RevMach', 1) + else + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustASplintWithBlade( EntId, bMakeGhostGeom, nDispType, bFlipDoor) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, 2) + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustThrouIsle( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom, dExtraThruDepth) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- se passante, aggiunto affondamento + if bTrhu then + -- acquisisco nota per vedere se viene fatta da lama + local bBladeNote = EgtGetInfo( EntId, 'ByBlade', 'b') or false + local dOl = -2 -- valore in mm + if dExtraThruDepth then + dOl = -abs(dExtraThruDepth) + end + if not bBladeNote then -- assegno nota se non ha taglio di lama + EgtSetInfo( EntId, 'OL', dOl) + end + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + -- se versore fresa diretto come Z-, + if vtExtr:getZ() < 0 then + -- se passante, lo cambio in Z+ + if bTrhu then + vtExtr = - vtExtr + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + + if nMach2nd == 0 then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + + if nMach2nd == 0 then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto + EgtSetInfo( EntId, 'Mach', 0) + end + -- altrimenti lo salto + else + -- se non posso lavorare da sotto + if not bWorkUnder then + -- se non era ancora stato escluso, lo escludo sommando 10 al valore + if nLocMach < 10 then + nLocMach = nLocMach + 10 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + nNumSkip = nNumSkip + 1 + else + nLocMach = 2 + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + else + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + if nMach2nd == 0 then + if nLocMach >= 10 then + if nLocMach <= 21 then + nLocMach = nLocMach - 10 + end + elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + local vtMPlane, dDist, dArea + -- verifico se il percorso è chiuso + if EgtCurveIsClosed( EntId) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if abs( dArea) < 1 then + -- verifico se il percroso ha la nota che identifica una doubleline cioè un percorso composto da due linee sovrapposte + if not ( EgtGetInfo( EntId, 'DoubleLine', 'i') == 1) then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + end + -- altrimenti è aperto + else + -- faccio una copia del percorso + local sParnt = EgtGetParent( EntId) + local nNewEntId = EgtCopyGlob( EntId, sParnt) + -- chiudo il percorso + if EgtCloseCurveCompo( nNewEntId) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + EgtErase(nNewEntId) + if dArea and abs( dArea) < 1 then + -- verifico se il percorso originario è una curvecompo + if EgtGetType( EntId) == GDB_TY.CRV_COMPO then + local _, nLast = EgtCurveDomain( EntId) + -- se è composto da una sola entità + if nLast == 1 then + -- rifaccio la copia + nNewEntId = EgtCopyGlob( EntId, sParnt) + -- esplodo e verifico che sia una linea + local nLocalGeom, nLast = EgtExplodeCurveCompo( nNewEntId) + if nLocalGeom and ( nLast > 1 or EgtGetType( nLocalGeom) ~= GDB_TY.CRV_LINE) then + if nLast > 1 then + for i = 1, nLast do + EgtErase( nLocalGeom + i - 1) + end + else + EgtErase( nLocalGeom) + end + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + else + EgtErase( nLocalGeom) + return true, nNumSkip, EntId + end + else + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + elseif EgtGetType( EntId) == GDB_TY.CRV_LINE then + return true, nNumSkip, EntId + else + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + end + else + EgtErase(nNewEntId) + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + end + end + local frEnt = EgtGetGlobFrame( EntId) + if vtMPlane then + vtMPlane:toGlob(frEnt) + if nLocMach ~= 2 then + if dArea and dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + -- cerco se ho la nota OPEN che definisce quale entità è quella aperta per le svuotature + local sNumOpen = EgtGetInfo( EntId, 'OPEN', 'i') + if sNumOpen then + if sNumOpen > 0 then + EgtSetInfo( EntId, 'OPEN', 0) + else + local nNumEnt1, nNumEnt2 = EgtCurveDomain( EntId) + if nNumEnt2 > 1 then + EgtSetInfo( nHint, 'OPEN', nNumEnt2-1) + end + end + end + end + else + if dArea and dArea * ( vtMPlane * vtExtr) < 0 then + EgtInvertCurve( EntId) + -- cerco se ho la nota OPEN che definisce quale entità è quella aperta per le svuotature + local sNumOpen = EgtGetInfo( EntId, 'OPEN', 'i') + if sNumOpen then + if sNumOpen > 0 then + EgtSetInfo( EntId, 'OPEN', 0) + else + local nNumEnt1, nNumEnt2 = EgtCurveDomain( EntId) + if nNumEnt2 > 1 then + EgtSetInfo( nHint, 'OPEN', nNumEnt2-1) + end + end + end + end + end + end +--[[ + local dAreaXY = EgtCurveAreaXY( EntId) + if dAreaXY and abs( dAreaXY) < 1 then + -- provo con EgtCurveArea + local vtV1, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + else + dAreaXY = dArea + end + end + local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT) + if nLocMach ~= 2 then + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then + EgtInvertCurve( EntId) + end + else + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then + EgtInvertCurve( EntId) + end + end +]]-- + end + return true, nNumSkip, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHole( EntId, bMakeGhostGeom, bForceHorizontalDir) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + if bForceHorizontalDir then -- se c'è forzatura orizzontale + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) +-- EgtSetInfo( EntId, 'OL', 0.16) + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + end + + -- impongo senso di rotazione orario relativo alla normale del versore + if abs( dArea) < 1 then + return false + end + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjPreHoleAndPocket( EntId, bMakeGhostGeom, tsProperties, tsFind, bFoundProperty) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + -- impongo senso di rotazione orario relativo alla normale del versore + if abs( dArea) < 1 then + return false + end + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + -- cerco se nella tabella c'è la chiave find, se c'è assegno la nota mach a 2 + local bMatchProp + if tsFind and tsProperties then + for g = 1, #tsFind do + for h = 1, #tsProperties do + if string.lower(tsProperties[h]) == string.lower(tsFind[g]) then + bMatchProp = true + end + end + end + end + -- verifico se la proprietà è già stata trovata (nuovo metodo), + -- è mutuamente esclusivo della ricerca nella tabella proprietà appena qua sopra + if bFoundProperty then + bMatchProp = true + end + + -- se ho trovato corrispondenza di proprietà + if bMatchProp then + -- nota seconda colonna + EgtSetInfo( EntId, 'Mach', 2) + else + -- nessuna nota + EgtRemoveInfo( EntId, 'Mach') + end + + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHead( EntId, nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle) + -- controllo dalla nota se non è già stata lavorata prima + local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0 + + if nSetSide < 10 then + + -- recupero il minimo e massimo valore in X e decido in base ai range dove metterlo + local b3Ent = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD) + local dMin = b3Ent:getMin():getX() + local dMax = b3Ent:getMax():getX() + + -- se ho forzato ad usare uno shuttle, setto a tutte le geometrie lo shuttle disponibile + if nForceUseShuttle and nForceUseShuttle > 0 then + if nForceUseShuttle == 1 then -- se forzo uso shuttle 1 (il valore assegnato a 3 è l'id della MTABLE) + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + else -- altrimenti lo shuttle 2 + nSetSide = 2 -- setto upper + nNumTopGeom = nNumTopGeom + 1 + end + else + -- se il minimo geometria è tutto con lo shuttle superiore ( di destra) + if dMin >= dPosShuttleChange then + nSetSide = 2 -- setto upper + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti sfora o è completamente nella parte dello shuttle inferiore ( di sinistra) + -- se il massimo è oltre il limite lo setto neutro + if dMax > dPosShuttleChange then + nSetSide = 0 -- setto neutro + else + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + end + end + end + + -- se neutro decido da che parte stare in base al numero delle rispettive parti + if nSetSide == 0 then + if nNumTopGeom == 0 then -- se shuttle alto senza assegnazioni lo assegno alto + nSetSide = 2 + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti shuttle alto ha già assegnazioni + if nNumBottomGeom == 0 then -- se shuttle basso senza assegnazioni lo assegno basso + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + else -- altrimenti shuttle basso con già assegnazioni + -- confronto tra quale dei due ha più assegnazioni + if nNumBottomGeom >= nNumTopGeom then -- se shuttle basso ne ha uguali o di più lo assegno alto + nSetSide = 2 + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti shuttle basso ne ha di meno, assegno basso + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + end + end + end + end + + EgtSetInfo( EntId, 'Mach', nSetSide) + end + + return true, nNumTopGeom, nNumBottomGeom, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHeadOnASplint( EntId, nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle, + nDispType, bFlipDoor, nMaxMach) + + -- controllo dalla nota se non è già stata lavorata prima + local nSetSide = EgtGetInfo( EntId, 'Mach', 'i') or 0 + + if nSetSide < 10 then + + -- verifico se è possibile lavorarla + nSetSide = MachiningBase.DefineASplint( EntId, nDispType, bFlipDoor, nMaxMach) + + if nSetSide < 4 then + + nSetSide = 0 + -- recupero il minimo e massimo valore in X e decido in base ai range dove metterlo + local b3Ent = EgtGetBBoxGlob( EntId, GDB_BB.STANDARD) + local dMin = b3Ent:getMin():getX() + local dMax = b3Ent:getMax():getX() + + -- se ho forzato ad usare uno shuttle, setto a tutte le geometrie lo shuttle disponibile + if nForceUseShuttle and nForceUseShuttle > 0 then + if nForceUseShuttle == 1 then -- se forzo uso shuttle 1 (il valore assegnato a 3 è l'id della MTABLE) + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + else -- altrimenti lo shuttle 2 + nSetSide = 2 -- setto upper + nNumTopGeom = nNumTopGeom + 1 + end + else + -- se il minimo geometria è tutto con lo shuttle superiore ( di destra) + if dMin >= dPosShuttleChange then + nSetSide = 2 -- setto upper + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti sfora o è completamente nella parte dello shuttle inferiore ( di sinistra) + -- se il massimo è oltre il limite lo setto neutro + if dMax > dPosShuttleChange then + nSetSide = 0 -- setto neutro + else + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + end + end + end + + -- se neutro decido da che parte stare in base al numero delle rispettive parti + if nSetSide == 0 then + if nNumTopGeom == 0 then -- se shuttle alto senza assegnazioni lo assegno alto + nSetSide = 2 + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti shuttle alto ha già assegnazioni + if nNumBottomGeom == 0 then -- se shuttle basso senza assegnazioni lo assegno basso + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + else -- altrimenti shuttle basso con già assegnazioni + -- confronto tra quale dei due ha più assegnazioni + if nNumBottomGeom >= nNumTopGeom then -- se shuttle basso ne ha uguali o di più lo assegno alto + nSetSide = 2 + nNumTopGeom = nNumTopGeom + 1 + else -- altrimenti shuttle basso ne ha di meno, assegno basso + nSetSide = 3 -- setto lower + nNumBottomGeom = nNumBottomGeom + 1 + end + end + end + end + + EgtSetInfo( EntId, 'Mach', nSetSide) + end + end + + return true, nNumTopGeom, nNumBottomGeom, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHorizDrillX( EntId, bMakeGhostGeom, bSelecExit, nProbeMode) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione/fresa + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- impongo versore fresa orizzontale + if abs( vtExtr:getZ()) > GEO.EPS_ZERO then + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + end + + if bSelecExit then + local bLetExit + -- lavorazione frontale (destra o sinistra) + -- se probemode disabilitato confronto con valore quasi o nullo + if nProbeMode < 2 and abs( vtExtr:getY()) < GEO.EPS_ZERO then + bLetExit = true + -- se ha fallito l'orientamento e sono in probe mode 2 confronto con un valore più grande + elseif nProbeMode == 2 and abs( vtExtr:getY()) < 2 then + bLetExit = true + -- impongo versore Y a 0 + vtExtr:setY( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + + if bLetExit then + -- se diretto verso SX + if vtExtr:getX() < GEO.EPS_ZERO then + EgtRemoveInfo( EntId, 'Mach') + else + -- lavorazione diretta verso DX + EgtSetInfo( EntId, 'Mach', 2) + end + end + end + return true, EntId +end + + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHorizDrillY( EntId, bMakeGhostGeom, bSelecExit, nProbeMode) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione/fresa + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- impongo versore fresa orizzontale + if abs( vtExtr:getZ()) > GEO.EPS_ZERO then + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + end + + if bSelecExit then + local bLetExit + -- lavorazione frontale (dietro o davanti) + -- se probemode disabilitato confronto con valore quasi o nullo + if nProbeMode < 2 and abs( vtExtr:getX()) < GEO.EPS_ZERO then + bLetExit = true + -- se ha fallito l'orientamento e sono in probe mode 2 confronto con un valore più grande + elseif nProbeMode == 2 and abs( vtExtr:getX()) < 2 then + bLetExit = true + -- impongo versore X a 0 + vtExtr:setX( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + + if bLetExit then + -- se diretto verso davanti + if vtExtr:getY() < GEO.EPS_ZERO then + EgtRemoveInfo( EntId, 'Mach') + else + -- lavorazione Dietro + EgtSetInfo( EntId, 'Mach', 2) + end + end + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHorizAS( EntId, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione/fresa + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se orizzontale + if abs( vtExtr:getZ()) < GEO.EPS_ZERO then + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + -- se diretto in su + elseif vtExtr:getZ() > 0 then + -- lavorazione Up + EgtSetInfo( EntId, 'Mach', 2) + -- altrimenti diretto in giù + else + -- lavorazione Dw + EgtSetInfo( EntId, 'Mach', 3) + end + -- impongo versore fresa orizzontale + if abs( vtExtr:getZ()) > GEO.EPS_ZERO then + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHorNegativeAS( EntId, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione/fresa + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + + -- se orizzontale + if abs( vtExtr:getZ()) < GEO.EPS_ZERO then + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + -- se diretto in su + elseif vtExtr:getZ() > 0 then + -- lavorazione Up + EgtSetInfo( EntId, 'Mach', 2) + -- altrimenti diretto in giù + else + -- lavorazione Dw + EgtSetInfo( EntId, 'Mach', 3) + end + -- se è negativo impongo versore fresa orizzontale + if vtExtr:getZ() < GEO.EPS_ZERO then + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + end + return true, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustMortise( EntId, nNumMachSkip, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare, + bForceHorizontalDir) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + -- se orizzontale + if abs( vtExtr:getZ()) < GEO.EPS_ZERO then + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + -- se diretto in su + elseif vtExtr:getZ() > 0 then + -- lavorazione Up a meno che c'è la forzatura orizzontale + if bForceHorizontalDir then -- se c'è forzatura orizzontale + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + else + if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra + EgtSetInfo( EntId, 'Mach', 12) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 2) + end + end + -- altrimenti diretto in giù + else + -- lavorazione Dw a meno che c'è la forzatura orizzontale + if bForceHorizontalDir then -- se c'è forzatura orizzontale + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + EgtSetInfo( EntId, 'OL', 0.16) + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + else + if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra + EgtSetInfo( EntId, 'Mach', 13) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 3) + end + end + end + + if vtMPlane then + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + end + + return true, nNumSkip, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustBevelChisel( EntId, nNumMachSkip, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare, bForceChiselHoriz) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + -- se orizzontale + if abs( vtExtr:getZ()) < GEO.EPS_ZERO then + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + -- se diretto in su + elseif vtExtr:getZ() > 0 then + -- lavorazione Up + if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra + EgtSetInfo( EntId, 'Mach', 12) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 2) + if bForceChiselHoriz then + EgtRemoveInfo( EntId, 'Mach') + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + -- EgtSetInfo( EntId, 'OL', 0.16) + end + end + -- altrimenti diretto in giù + else + -- lavorazione Dw + if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra + EgtSetInfo( EntId, 'Mach', 13) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 3) + if bForceChiselHoriz then + EgtRemoveInfo( EntId, 'Mach') + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + -- EgtSetInfo( EntId, 'OL', 0.16) + end + end + end + + if vtMPlane then + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + end + + return true, nNumSkip, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustHeadChisel( EntId, bMakeGhostGeom, bWorkOnlyHoriz, nNumMachSkip, bNoWorkUpSquare, bNoWorkUnderSquare) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + -- se area piccola esco + if dArea and abs( dArea) < 1 then + return false + end + + -- se valore quasi o nullo + if abs( vtExtr:getX()) < GEO.EPS_ZERO then + -- lavorazione frontale (dietro o davanti) + EgtRemoveInfo( EntId, 'Mach') + -- se abilitata verifica e modifica versore z per lavorazione orizzontale ( non segue il bevel) + if bWorkOnlyHoriz then + -- se non orizzontale impongo versore fresa orizzontale + if abs( vtExtr:getZ()) > GEO.EPS_ZERO then + vtExtr:setZ( 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + -- EgtSetInfo( EntId, 'OL', 0.16) + end + else + -- se diretto in su + if vtExtr:getZ() > 0 then + -- lavorazione Up + if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra + EgtSetInfo( EntId, 'Mach', 11) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 1) + end + -- altrimenti diretto in giù + elseif vtExtr:getZ() < 0 then + -- lavorazione Dw + if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra + EgtSetInfo( EntId, 'Mach', 11) + nNumSkip = nNumSkip + 1 + else + EgtSetInfo( EntId, 'Mach', 1) + end + end + end + -- se diretto verso DX + elseif vtExtr:getX() > 0 then + -- lavorazione DX + EgtSetInfo( EntId, 'Mach', 2) + -- altrimenti diretto s SX + else + -- lavorazione SX + EgtSetInfo( EntId, 'Mach', 3) + end + + -- impongo senso di rotazione orario relativo alla normale del versore + if vtMPlane then + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + end + + return true, EntId, nNumSkip +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustVertHole( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom, dExtraThruDepth) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- se passante, aggiunto affondamento + if bTrhu then + local dOl = -2 -- valore in mm + if dExtraThruDepth then + dOl = -abs(dExtraThruDepth) + end + EgtSetInfo( EntId, 'OL', dOl) + end + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + -- se versore fresa diretto come Z- (da sotto) + if vtExtr:getZ() < 0 then + -- se passante, lo cambio in Z+ + if bTrhu then + vtExtr = - vtExtr + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + + if nMach2nd == 0 then + -- se è una geometria che avevo escluso la riabilito + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + nTypeGeom = 2 + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + + if nMach2nd == 0 then + if nLocMach >= 10 then + if nLocMach <= 21 then + nLocMach = nLocMach - 10 + end + elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + nTypeGeom = 2 + else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto + EgtSetInfo( EntId, 'Mach', 0) + end + -- altrimenti non passante + else + -- se non posso lavorare da sotto + if not bWorkUnder then + -- se non era ancora stato escluso, lo escludo sommando 10 al valore + if nLocMach < 10 then + nLocMach = nLocMach + 10 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + nNumSkip = nNumSkip + 1 + else + nLocMach = 2 + EgtSetInfo( EntId, 'Mach', nLocMach) + end + nTypeGeom = 4 + end + else -- versore Z diretto in Z+ + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + -- leggo la nota Mach2nd che indica se l'entità è già stata lavorata + local nMach2nd = EgtGetInfo( EntId, 'Mach2nd', 'i') or 0 + if nMach2nd == 0 then + if nLocMach >= 10 then + if nLocMach <= 21 then + nLocMach = nLocMach - 10 + end + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + if bTrhu then + nTypeGeom = 1 + else + nTypeGeom = 3 + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + local vtMPlane, dDist, dArea + -- verifico se il percorso è chiuso + if EgtCurveIsClosed( EntId) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + -- altrimenti è aperto + else + -- faccio una copia del percorso + local sParnt = EgtGetParent( EntId) + local nNewEntId = EgtCopyGlob( EntId, sParnt) + -- chiudo il percorso + if EgtCloseCurveCompo( nNewEntId) then + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + EgtErase(nNewEntId) + if dArea and abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + else + EgtErase(nNewEntId) + -- impongo senso di rotazione orario visto da sopra + vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if not dArea or abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + end + end + local frEnt = EgtGetGlobFrame( EntId) + if vtMPlane then + vtMPlane:toGlob(frEnt) + if nLocMach ~= 2 then + if dArea and dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + else + if dArea and dArea * ( vtMPlane * vtExtr) < 0 then + EgtInvertCurve( EntId) + end + end + end +--[[ + -- impongo senso di rotazione orario visto da sopra + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + if not dArea or abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + end + local frEnt = EgtGetGlobFrame( EntId) + vtMPlane:toGlob(frEnt) + if nLocMach ~= 2 then + if dArea * ( vtMPlane * vtExtr) > 0 then + EgtInvertCurve( EntId) + end + else + if dArea * ( vtMPlane * vtExtr) < 0 then + EgtInvertCurve( EntId) + end + end +]]-- +--[[ + local dAreaXY = EgtCurveAreaXY( EntId) + if dAreaXY and abs( dAreaXY) < 1 then + -- provo con EgtCurveArea + local vtV1, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip, EntId + else + dAreaXY = dArea + end + end + local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT) + if nLocMach ~= 2 then + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then + EgtInvertCurve( EntId) + end + else + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then + EgtInvertCurve( EntId) + end + end +]]-- + end + return true, nNumSkip, EntId, nTypeGeom +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustProbeHole( EntId, DimZ, ptMin, ptMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- se passante, aggiunto affondamento + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + -- se versore fresa diretto come Z-, + if vtExtr:getZ() < 0 then + -- se passante, lo cambio in Z+ + if bTrhu then + vtExtr = - vtExtr + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + -- se è una geometria che avevo escluso la riabilito + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo escluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, -vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + end + else -- altrimenti lo salto perché è in una Z diversa da sopra o sotto + EgtSetInfo( EntId, 'Mach', 0) + end + -- altrimenti lo salto + else + -- se non posso lavorare da sotto + if not bWorkUnder then + -- se non era ancora stato escluso, lo escludo sommando 10 al valore + if nLocMach < 10 then + nLocMach = nLocMach + 10 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + nNumSkip = nNumSkip + 1 + else + nLocMach = 2 + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + else + -- in seconda fase controllo la nota mach se devo ristabilirla o escluderla + if not bFirstStep then + if nLocMach >= 10 then + nLocMach = nLocMach - 10 + elseif nLocMach > 0 then -- se è una che non avevo scluso la escludo + nLocMach = nLocMach + 10 + else -- altrimenti la escludo perché è già stata fatta nella fase precedente + nLocMach = 11 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + end + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + -- impongo senso di rotazione orario visto da sopra + local dAreaXY + _ , _ , dAreaXY = EgtCurveArea( EntId) + if dAreaXY and abs( dAreaXY) < 0.1 then + -- Rimando il valore originario in caso avessi skippato la lavorazione + return false, nNumMachSkip + end + local frEnt = EgtFR( EgtGetParent( EntId), GDB_ID.ROOT) + if nLocMach ~= 2 then + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() > 0 then + EgtInvertCurve( EntId) + end + else + if dAreaXY and dAreaXY * frEnt:getVersZ():getZ() < 0 then + EgtInvertCurve( EntId) + end + end + EgtSetInfo( EntId, 'ProbeMachZ', 3) + end + return true, nNumSkip, EntId +end + + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustProbeMill( EntId, DimZ, ptMin, ptMax, nNumMachSkip, + bFirstStep, bNoWorkUnderSquare, bMakeGhostGeom, bNoWorkUpSquare, dThickPrb, + dDepthPrb) + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se versore fresa diretto come Z-, + if vtExtr:getZ() < 0 then + EgtModifyCurveExtrusion( EntId, Z_AX(), GDB_RT.GLOB) + end + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- contatore disabilitazione lavorazione + local nNumSkip = nNumMachSkip + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + local sProfile = EgtGetInfo( EntId, 'ProfSide', 's') or '' + -- verifico direzione lavorazione + local pt1 = EgtSP( EntId, GDB_ID.ROOT) + local pt2 = EgtEP( EntId, GDB_ID.ROOT) + -- calcolo direzione entrante + vtExtr = pt2 - pt1; vtExtr:normalize() + -- se si trova a Z0 lo sposto a quota spessore porta + if abs( pt1:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then + EgtMove( EntId, Point3d( 0, 0, ( ptMax:getZ()-ptMin:getZ())), GDB_RT.GLOB) + end + -- se vettore estrusione è all'interno della tangente di 3° proseguo con la verifica + if abs(vtExtr:getZ()) < 0.0525 then + -- se non sono al primo giro setto profili bevel invertiti + if not bFirstStep and sProfile == 'BD' then + sProfile = 'BU' + elseif not bFirstStep and sProfile == 'BU' then + sProfile = 'BD' + end + if sProfile == 'BD' then + if bNoWorkUnderSquare then -- se non è possibile lavorare sottosquadra + EgtSetInfo( EntId, 'Mach', 13) + nNumSkip = nNumSkip + 1 + EgtModifyCurveThickness( EntId, 0) + else + EgtSetInfo( EntId, 'Mach', 3) + EgtModifyCurveThickness( EntId, -( dThickPrb + dDepthPrb)) + end + elseif sProfile == 'BU' then + if bNoWorkUpSquare then -- se non è possibile lavorare soprasquadra + EgtSetInfo( EntId, 'Mach', 12) + nNumSkip = nNumSkip + 1 + EgtModifyCurveThickness( EntId, 0) + else + EgtSetInfo( EntId, 'Mach', 2) + EgtModifyCurveThickness( EntId, -dDepthPrb) + end + else + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') +-- -- elimino il percorso ProbeSidePoint_ per non lavorarlo in un a fase successiva +-- if bFirstStep then +-- local nPar = EgtGetParent(EntId) +-- local tEnt = MachiningBase.FindGroupWithPartName( nPar, sParzName..'_secure') +-- if tEnt and #tEnt > 0 then +-- for i = 1, #tEnt do +-- EgtErase(tEnt[i]) +-- end +-- end +-- tEnt = MachiningBase.FindGroupWithPartName( nPar, sParzName..'_keyway') +-- if tEnt and #tEnt > 0 then +-- for i = 1, #tEnt do +-- EgtErase(tEnt[i]) +-- end +-- end +-- end + end + -- se diretto verso X+ + if vtExtr:getX() > 0.98 then + EgtSetInfo( EntId, 'ProbeMachXY', 1) -- E101 = 1 + -- altrimenti se diretto verso X- + elseif vtExtr:getX() < -0.98 then + EgtSetInfo( EntId, 'ProbeMachXY', -1) -- E101 = 4 + -- altrimenti se diretto verso Y+ + elseif vtExtr:getY() > 0.98 then + EgtSetInfo( EntId, 'ProbeMachXY', 2) -- E101 = 2 + -- altrimenti se diretto verso Y- + elseif vtExtr:getY() < -0.98 then + EgtSetInfo( EntId, 'ProbeMachXY', -2) -- E101 = 6 + else + EgtSetInfo( EntId, 'Mach', nLocMach + 20) + return false, nNumSkip, EntId + end + else + EgtSetInfo( EntId, 'Mach', nLocMach + 20) + return false, nNumSkip, EntId + end + + return true, nNumSkip, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.AdjustVertAsOnHeads( EntId, bMakeGhostGeom) + if bMakeGhostGeom then + EntId = MachiningBase.MakeGhostCopy( EntId) + end + -- recupero versore estrusione/fresa + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero punti inziale e finale + local pIni = EgtSP( EntId, GDB_ID.ROOT) + local pNewIni = Point3d( pIni) + local pEnd = EgtEP( EntId, GDB_ID.ROOT) + local pNewEnd = Point3d( pEnd) + local bExit = true + + -- se punti diversi + if dist( pIni, pEnd) > GEO.EPS_SMALL then + -- se versore Y verso Y+ (faccia dietro) + if vtExtr:getY() > 0.99 then + -- se punto iniziale ha Y verso Y- + if pIni:getY() < ( pEnd:getY() - GEO.EPS_SMALL) then + -- ricostruisco il percorso tenendo la posizione di Y più interno + pNewEnd = Point3d( pEnd:getX(), pIni:getY(), pEnd:getZ()) + -- se punto iniziale ha Y verso Y+ + elseif pIni:getY() > ( pEnd:getY() + GEO.EPS_SMALL) then + -- ricostruisco il percorso tenendo la posizione di Y più interno + pNewIni = Point3d( pIni:getX(), pEnd:getY(), pIni:getZ()) + end + -- se versore Y verso Y+ (faccia dietro) + elseif vtExtr:getY() < -0.99 then + -- se punto iniziale ha Y verso Y- + if pIni:getY() < ( pEnd:getY() - GEO.EPS_SMALL) then + -- ricostruisco il percorso tenendo la posizione di Y più interno + pNewIni = Point3d( pIni:getX(), pEnd:getY(), pIni:getZ()) + -- se punto iniziale ha Y verso Y+ + elseif pIni:getY() > ( pEnd:getY() + GEO.EPS_SMALL) then + -- ricostruisco il percorso tenendo la posizione di Y più interno + pNewEnd = Point3d( pEnd:getX(), pIni:getY(), pEnd:getZ()) + end + end + + -- se ho cambiato almeno 1 punto ricotruisco il percorso + if not AreSamePointExact( pIni, pNewIni) or not AreSamePointExact( pEnd, pNewEnd) then + nParent = EgtGetParent( EntId) + local sName = EgtGetName( EntId) + EgtErase (EntId) + EntId = EgtLine( nParent, pNewIni, pNewEnd, GDB_RT.GLOB) + EgtSetName( EntId, sName) + EgtModifyCurveThickness( EntId, 0) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_ID.ROOT) + EgtSetStatus( EntId, GDB_ST.OFF) + end + else + bExit = false + end + + -- lavorazione standard + EgtRemoveInfo( EntId, 'Mach') + + return bExit, EntId +end + +-------------------------------------------------------------------------------- +function MachiningBase.InvertGeom( EntId) + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- recupero flag di lavorazione + local nLocMach = EgtGetInfo( EntId, 'Mach', 'i') or 1 + + vtExtr = - vtExtr + -- se da lavorare ora + if nLocMach > 0 and nLocMach < 10 then + EgtMove( EntId, vtExtr * abs(dTh), GDB_RT.GLOB) + EgtModifyCurveExtrusion( EntId, vtExtr, GDB_RT.GLOB) + + if nLocMach == 1 then +-- nLocMach = nLocMach + 10 + 1 + nLocMach = 2 + elseif nLocMach == 2 then +-- nLocMach = nLocMach + 10 - 1 + nLocMach = 1 +-- else -- altrimenti la escludo perché è già stata fatta nella fase precedente +-- nLocMach = nLocMach + 10 + end + EgtSetInfo( EntId, 'Mach', nLocMach) + end + return true +end + +----------------------------------------------------------------- +-- *** Test Functions *** +----------------------------------------------------------------- +-------------------------------------------------------------------------------- +function MachiningBase.TestThrouIsle( EntId, DimZ, ptMin, ptMax, bWorkUnder) + -- skip geometria, con spessore passante e geometria valida restituisce 0 perché è neutro + -- restituisce +1 se è sotto, restituisce -1 se è sopra + local nSkipGeom + local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se versore fresa diretto come Z-, + if vtExtr:getZ() < 0 then + -- se passante, lo cambio in Z+ + if bTrhu then + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto + nSkipGeom = 0 + nTypeGeom = 2 + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra + nSkipGeom = 0 + nTypeGeom = 2 + end + -- altrimenti lo salto + else + if not bWorkUnder then + nSkipGeom = 1 + else + nSkipGeom = 0 + end + nTypeGeom = 4 + end + else -- altrimenti versore fresa diretto come Z+ + if bTrhu then + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto + nSkipGeom = 0 + nTypeGeom = 1 + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra + nSkipGeom = 0 + nTypeGeom = 1 + end + -- altrimenti lo salto + else + nSkipGeom = -1 + nTypeGeom = 3 + end + end + + -- verifico se il percorso è chiuso + if EgtCurveIsClosed( EntId) then + -- verifico se area è troppo piccola + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if abs( dArea) < 1 then + return false + end + -- altrimenti è aperto + else + -- faccio una copia del percorso + local sParnt = EgtGetParent( EntId) + local nNewEntId = EgtCopyGlob( EntId, sParnt) + -- chiudo il percorso + if EgtCloseCurveCompo( nNewEntId) then + local vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + -- cancello percorso copia + EgtErase(nNewEntId) + if dArea and abs( dArea) < 1 then + return false + end + else + -- cancello percorso copia + EgtErase(nNewEntId) + -- verifico se area è troppo piccola + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + return false + end + end + end + +--[[ + local dAreaXY = EgtCurveAreaXY( EntId) + if dAreaXY and abs( dAreaXY) < 1 then + -- provo con EgtCurveArea + local vtV1, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + return false + else + dAreaXY = dArea + end + end +]]-- + return true, nSkipGeom, nTypeGeom +end + +-------------------------------------------------------------------------------- +function MachiningBase.TestVertHole( EntId, DimZ, ptMin, ptMax, bWorkUnder) + -- skip geometria, con spessore passante e geometria valida restituisce 0 perché è neutro + -- restituisce +1 se è sotto, restituisce -1 se è sopra + local nSkipGeom + local nTypeGeom = 0 -- 1: passante up, 2: passante dw, 3: cieca up, 4: cieca dw + -- recupero spessore e verifico se passante + local dTh = EgtCurveThickness( EntId) + local bTrhu = ( abs( dTh) > DimZ - GEO.EPS_SMALL) + -- recupero versore estrusione + local vtExtr = EgtCurveExtrusion( EntId, GDB_ID.ROOT) + -- se versore fresa diretto come Z-, + if vtExtr:getZ() < 0 then + -- se passante, lo cambio in Z+ + if bTrhu then + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sotto + nSkipGeom = 0 + nTypeGeom = 2 + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se il foro parte sulla faccia sopra + nSkipGeom = 0 + nTypeGeom = 2 + end + -- altrimenti lo salto + else + if not bWorkUnder then + nSkipGeom = 1 + else + nSkipGeom = 0 + end + nTypeGeom = 4 + end + else -- altrimenti versore fresa diretto come Z+ + if bTrhu then + local pIni = EgtSP( EntId, GDB_ID.ROOT) + if abs( pIni:getZ() - ptMin:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sotto + nSkipGeom = 0 + nTypeGeom = 1 + elseif abs( pIni:getZ() - ptMax:getZ()) < GEO.EPS_SMALL then -- se geometria è sulla faccia sopra + nSkipGeom = 0 + nTypeGeom = 1 + end + -- altrimenti lo salto + else + nSkipGeom = -1 + nTypeGeom = 3 + end + end + + -- verifico se il percorso è chiuso + if EgtCurveIsClosed( EntId) then + -- verifico se area è troppo piccola + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if abs( dArea) < 1 then + return false + end + -- altrimenti è aperto + else + -- faccio una copia del percorso + local sParnt = EgtGetParent( EntId) + local nNewEntId = EgtCopyGlob( EntId, sParnt) + -- chiudo il percorso + if EgtCloseCurveCompo( nNewEntId) then + local vtMPlane, dDist, dArea = EgtCurveArea( nNewEntId) + -- cancello percorso copia + EgtErase(nNewEntId) + if dArea and abs( dArea) < 1 then + return false + end + else + -- cancello percorso copia + EgtErase(nNewEntId) + -- verifico se area è troppo piccola + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + if not dArea or abs( dArea) < 1 then + return false + end + end + end +--[[ + -- verifico se area è troppo piccola + local vtMPlane, dDist, dArea = EgtCurveArea( EntId) + + if not dArea or abs( dArea) < 1 then + return false + end +]]-- +--[[ + local dAreaXY = EgtCurveAreaXY( EntId) + if dAreaXY and abs( dAreaXY) < 1 then + -- provo con EgtCurveArea + local vtV1, dDist, dArea = EgtCurveArea( EntId) + if dArea and abs( dArea) < 1 then + return false + else + dAreaXY = dArea + end + end +]]-- + return true, nSkipGeom, nTypeGeom +end + +-------------------------------------------------------------------------------- +function MachiningBase.TestMachining( sMach, EntId, bCheckPos) + -- verifico inserimento e applicazione della lavorazione alla geometria + if not sMach or ( sMach and #sMach == 0) then + return false, sMach + end + local nMach = EgtAddMachining( 'Dummy', sMach) + if not nMach then + return false + end + local bOk = EgtSetMachiningGeometry( EntId) and EgtApplyMachining() + local bBoxMach + if bOk and bCheckPos then + bBoxMach = EgtGetBBoxGlob ( nMach, GDB_BB.STANDARD) + end + EgtRemoveOperation( nMach) + -- ripristino ultima lavorazione rimasta + local nOper = EgtGetLastActiveOperation() or GDB_ID.NULL + local nType = EgtGetOperationType( nOper) + if nType ~= MCH_OY.NONE and nType ~= MCH_OY.DISP then + EgtSetCurrMachining( nOper) + EgtApplyMachining() + end + return bOk, sMach, bBoxMach +end + +----------------------------------------------------------------- +-- *** MachTable Functions *** +----------------------------------------------------------------- +-------------------------------------------------------------------------------- +function MachiningBase.GetToolDiamFromAttrib( sName, nInd) + +--[[ + local sCamData = 'CurrCamInfo' + local mCamData = require( sCamData) + + local MachiningsTable = mCamData[DGD.MCC].MachiningsTable + local MachName = mCamData[DGD.MCC].MachName + local sLocMachname + + local MTable = require( MachiningsTable) +]]-- + + -- prendo dalle note il nome tabella e poi da questa le macchine indicate + -- devo cercare per ogni macchina, che esiste + -- cerco nella tabella le associazioni che siano abilitate, che abbiano la macchina compatibile, + -- che ci sia il nome geometria corrispondente + local MachiningsTable = EgtGetInfo( DGD.PZ, 'MTable') + local MachiningsPath = EgtGetInfo( DGD.PZ, 'MTablePath') + + -- se tavola non trovata esco subito + if not MachiningsTable or not MachiningsPath then return -8 end + + local M = dofile( MachiningsPath..MachiningsTable..'.mtl') + local MTable = M.MTable + local MachinesName = M.MMachineData + local sLocMachId + local sMachine + + -- per ogni macchina faccio il giro della tabella + for j = 1, #MachinesName do + + sMachine = MachinesName[j].MachName + -- imposto la macchina corrente + if sMachine and EgtSetCurrMachine( sMachine) then + + for i = 1, #MTable do + + if MTable[i].On ~= 0 then + + -- se non presente il nome macchina di default setto l'associazione per la macchina 1 + sLocMachId = MTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if string.lower(MTable[i].Name) == string.lower(sName) and sLocMachId == j then + -- recupero il nome della lavorazione + local sMach + if nInd == 2 then + sMach = MTable[i].MachUp + elseif nInd == 3 then + sMach = MTable[i].MachDw + else + sMach = MTable[i].Mach + end + if not sMach then return -1 end -- errore su lavorazione non trovata + -- imposto la lavorazione come corrente + if not EgtMdbSetCurrMachining( sMach) then return -2, nil, sMach end + -- recupero l'utensile della lavorazione + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if not sTuuid then return -3, nil, sMach end + local sTool = EgtTdbGetToolFromUUID( sTuuid) + if not sTool then return -4, nil, sMach end + EgtTdbSetCurrTool( sTool) + local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + if not dDiam then return -5, nil, sMach end + return dDiam, nil, sMach + end + end + end + end + end + return - 6 +end + +-------------------------------------------------------------------------------- +function MachiningBase.GetToolDataFromAttrib( sName, nInd, bReadNotes, bForceReadThick) + + -- prendo dalle note il nome tabella e poi da questa le macchine indicate + -- devo cercare per ogni macchina, che esiste + -- cerco nella tabella le associazioni che siano abilitate, che abbiano la macchina compatibile, + -- che ci sia il nome geometria corrispondente + local MachiningsTable = EgtGetInfo( DGD.PZ, 'MTable') + local MachiningsPath = EgtGetInfo( DGD.PZ, 'MTablePath') + + -- se tavola non trovata esco subito + if not MachiningsTable or not MachiningsPath then return -8 end + + local M = dofile( MachiningsPath..MachiningsTable..'.mtl') + local MTable = M.MTable + local MachinesName = M.MMachineData + local sLocMachId + local sMachine + + -- per ogni macchina faccio il giro della tabella + for j = 1, #MachinesName do + + sMachine = MachinesName[j].MachName + -- imposto la macchina corrente + if sMachine and EgtSetCurrMachine( sMachine) then + + for i = 1, #MTable do + + if MTable[i].On ~= 0 then + + -- se non presente il nome macchina di default setto l'associazione per la macchina 1 + sLocMachId = MTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if string.lower(MTable[i].Name) == string.lower(sName) and sLocMachId == j then + -- recupero il nome della lavorazione + local sMach + if nInd == 2 then + sMach = MTable[i].MachUp + elseif nInd == 3 then + sMach = MTable[i].MachDw + else + sMach = MTable[i].Mach + end + if not sMach then return -1 end + -- imposto la lavorazione come corrente + if not EgtMdbSetCurrMachining( sMach) then return -2, nil, sMach end + -- recupero l'eventuale nota + local sMachNotes = '' + if bReadNotes then + sMachNotes = EgtMdbGetCurrMachiningParam( MCH_MP.USERNOTES) + end + -- recupero l'utensile della lavorazione + local sTuuid = EgtMdbGetCurrMachiningParam( MCH_MP.TUUID) + if not sTuuid then return -3, nil, sMach end + local sTool = EgtTdbGetToolFromUUID( sTuuid) + if not sTool then return -4, nil, sMach end + EgtTdbSetCurrTool( sTool) + local dDiam = EgtTdbGetCurrToolParam( MCH_TP.DIAM) + if not dDiam then return -5, nil, sMach end -- se non trovato diametro esco + local dHWork = EgtTdbGetCurrToolParam( MCH_TP.MAXMAT) + if not dHWork then return -7, nil, sMach end -- se non trovato massimo materiale esco + local dHType = EgtTdbGetCurrToolParam( MCH_TP.TYPE) + local dThBlade + -- se forzata lettura spessore lama + if bForceReadThick then + -- se tipo utensile lama + if dHType == MCH_TY.SAW_STD or dHType == MCH_TY.SAW_FLAT then + dThBlade = EgtTdbGetCurrToolParam( MCH_TP.THICK) + -- se è tipo fresa allaora lo spessore lama setto uguale all'altezza tagliente + elseif dHType == MCH_TY.MILL_STD or dHType == MCH_TY.MILL_NOTIP then + dThBlade = dHWork + end + -- se utensile lama + elseif dHType == MCH_TY.SAW_STD or dHType == MCH_TY.SAW_FLAT then + dThBlade = EgtTdbGetCurrToolParam( MCH_TP.THICK) + end + -- ritorno i valori diametro utensile e lunghezza massima + return dDiam, dHWork, sMach, dThBlade, sMachNotes + end + end + end + end + end + return - 6 +end + +return MachiningBase diff --git a/LuaLibs/MailSlot.lua b/LuaLibs/MailSlot.lua new file mode 100644 index 0000000..bcc10db --- /dev/null +++ b/LuaLibs/MailSlot.lua @@ -0,0 +1,493 @@ +-- +-- 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 +-- +-- MailSlot.lua by EgalWare s.r.l. 2016.07.05 +-- Autore: Filippo Monchi +-- Mail SLot dati i valori 'L' e 'T' e con nome attributo e dati dei fori + +-- 2016.07.05 V1.000 FM First version +-- 2019.10.02 V1.001 FM Manage steel option (disable generation of some geometries) +-- 2019.10.17 V1.002 FM Manage cut by saw and steel option (for this component it doesn't anything) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.04.29 V2.001 FM Update for aluminum material +-- 2022.07.27 V2.002 FM Modification to use compiled code + +-- Tavola per definizione modulo (serve ma non usata) +local MailSlot = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 4. -- valore minimo lato + +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 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor(nCircle2, cColor2) + end + end + + return nLine +end + +-- Funzione di sistemazione parametri +function MailSlot.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local sMchngName0 + local nThBl0 + + -- Assegno parametri da ddf + if DGD.LENGTH then + tMhPar.L = DGD.LENGTH + end + tMhPar.T = DGD.dT + + if tMhPar.IL then + tMhPar.IL = tMhPar.IL + DGD.LENGTH + end + + if tMhPar.DD then + if tMhPar.DD == -0.5 then + tMhPar.DD = DGD.dT / 2 + elseif tMhPar.DD == -1 then + tMhPar.DD = DGD.dT + end + end + + -- disattivo la lama se la cava è più profonda di una certa quota + if tMhPar.MaxBd and tMhPar.T and tMhPar.T > tMhPar.MaxBd then + tMhPar.bl = false + dNumLog = -1394 + dNumMessage = 674 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.MaxBd)) + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLBM + local nLBMi = 1 + local dMaxCutBladeLen = 0 + + -- se porta steel o aluminum + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.est = true + else + tMhPar.est = nil + end + + if tMhPar.LBM then -- geometria con lama + sLBM = tMhPar.LBM + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + if sLBM and tMhPar.bl and tMhPar.d3 then + nTempT0, dMaxMat0, sMchngName0, nThBl0 = MB.GetToolDataFromAttrib( sLBM, nLBMi) + end + + if tMhPar.d3 and nTempT0 and nTempT0 <= 0 then -- lama + if DGD.bProoduce and tMhPar.bl then -- se utilizzo la lama + dNumLog = -1399 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLBM, nLBMi, tMhPar.d3, dNumLog, sMchngName0) + end + elseif nTempT0 then + tMhPar.d3 = nTempT0 + if nThBl0 and nThBl0 > 0 then tMhPar.thb = nThBl0 end + end + + -- se lo spessore porta è maggiore della capacità lama disabilito la lama ed emetto un warning + if tMhPar.bl and tMhPar.T and dMaxMat0 and tMhPar.T >= dMaxMat0 then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1397 + dNumMessage = 672 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) + end + + -- se il blade è attivo calcolo se passa la lama nella sfinestratura + if tMhPar.bl and tMhPar.d3 and tMhPar.L and tMhPar.W then + + -- calcolo la massima impronta lama + local dBladeRadius = tMhPar.d3 / 2 + dMaxCutBladeLen = sqrt( (dBladeRadius * dBladeRadius) - ( ( dBladeRadius - tMhPar.T) * ( dBladeRadius - tMhPar.T))) + + -- se l'impronta lama è maggiore della lunghezza o larghezza escludo la lama e do messaggio di warning + if (2*dMaxCutBladeLen) >= tMhPar.L or (2*dMaxCutBladeLen) >= tMhPar.W then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1395 + dNumMessage = 673 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0) + end + end + + -- se il blade è attivo e utensile lama e c'è il clean corner, lo ricalcolo in funzione del raggio lama + if tMhPar.bl and tMhPar.thb and tMhPar.thb > 0 and tMhPar.clc and tMhPar.clc > 0 then + if dMaxCutBladeLen > tMhPar.clc then + tMhPar.clc = dMaxCutBladeLen + end + end + + if tMhPar.CL and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.W or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CL then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function MailSlot.Draw( tMlSlPar, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni + local L = tMlSlPar.L + local W = tMlSlPar.W + local T = tMlSlPar.T + local clc = tMlSlPar.clc + local ccr = tMlSlPar.ccr + local bl = tMlSlPar.bl + local d3 = tMlSlPar.d3 -- blade diameter + local est = tMlSlPar.est + -- Assegno parametri fori + local ms = tMlSlPar.ms + local DS = tMlSlPar.DS + local DD = tMlSlPar.DD + local IL = tMlSlPar.IL + local IW = tMlSlPar.IW + -- Assegno i nomi + local LG = tMlSlPar.LG + local LM = tMlSlPar.LM + local SCU = tMlSlPar.SCU + local CL = tMlSlPar.CL + local LBM = tMlSlPar.LBM -- nome lavorazione con lama + -- variabili per messaggi e settaggi vari + local sCompoName = tMlSlPar.Nome + local nCompoNPar = tMlSlPar.Npar + local sCompoPath = tMlSlPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tMlSlPar.nCod + local sCodAdj = tMlSlPar.sCod + -- variabili per messaggi e settaggi vari + local sNamePar1 = tMlSlPar.N1 or 'L' + local sNamePar2 = tMlSlPar.N2 or 'H' + local sNamePar3 = tMlSlPar.N3 or 'T' + local sNamePar4 = tMlSlPar.N4 or 'clc' + local sNamePar5 = tMlSlPar.N5 or 'ccr' + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1300 + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if L < DimMin then + EC = 1 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'L' deve essere > DimMin + D = DimMin + elseif W < DimMin then + EC = 2 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'H' deve essere > DimMin + W = DimMin + elseif CL and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 3 + EM = string.format(EgtDoorsMsg[407],sNamePar4,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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + local GId, MId, hint_1, hint_2, hint_3, hint_4 + local bSingleMode = true + + -- Costruzione della geometria + GId = EgtRectangle2P( Lg, Point3d( -(W/2), 0, T), Point3d( (W/2), L, T), GDB_RT.GLOB) + EgtModifyCurveThickness( GId, -T) + EgtInvertCurve( GId) + EgtSetName( GId, LG) + EgtSetInfo( GId,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( Lg, GId, bSingleMode) + + if ms then -- se devo fare le viti + + if DS and DD and IL and IW then + + -- se dimensioni foro vite idonee + if DS > 0 and DD ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_1 = EgtCircle( Lg, Point3d( -(IW/2),-((IL-L)/2),T), DS/2 , GDB_RT.LOC) + hint_2 = EgtCircle( Lg, Point3d( -(IW/2),(L+((IL-L)/2)),T), DS/2 , GDB_RT.LOC) + hint_3 = EgtCircle( Lg, Point3d( (IW/2),(L+((IL-L)/2)),T), DS/2 , GDB_RT.LOC) + hint_4 = EgtCircle( Lg, Point3d( (IW/2),-((IL-L)/2),T), DS/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_1, -DD) + EgtModifyCurveThickness(hint_2, -DD) + EgtModifyCurveThickness(hint_3, -DD) + EgtModifyCurveThickness(hint_4, -DD) + EgtSetName(hint_1,SCU) + EgtSetName(hint_2,SCU) + EgtSetName(hint_3,SCU) + EgtSetName(hint_4,SCU) + EgtSetInfo(hint_1,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_2,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_3,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_4,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( Lg, hint_1, bSingleMode) + AddSurfTmByExtrusion( Lg, hint_2, bSingleMode) + AddSurfTmByExtrusion( Lg, hint_3, bSingleMode) + AddSurfTmByExtrusion( Lg, hint_4, bSingleMode) + end + end + end + + -- Costruzione della geometria clean corner + if nDrawMach >= 0 then -- se abilitata geometria + -- se ci sono i parametri per i percorsi clean corner + if CL and clc and clc > 0 and clc < W and clc < L then + -- angolo x-y+ + local CLC1 = MakeClcPath( clc, ccr, CL, Lg, -T) + EgtMove( CLC1, Point3d(-(W/2),L,T) - ORIG()) + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(-(W/2),L,0), Z_AX(), -90) + EgtMove( CLC2, Point3d(W,0,0) - ORIG()) + -- angolo x+y- + CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(-(W/2),L,0), Z_AX(), 180) + EgtMove( CLC2, Point3d(W,-L,0) - ORIG()) + -- angolo x-y- + CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(-(W/2),L,0), Z_AX(), 90) + EgtMove( CLC2, Point3d(0,-L,0) - ORIG()) + end + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + -- Costruzione della geometria + MId = EgtRectangle2P( Lg, Point3d( -(W/2), 0, T), Point3d( (W/2), L, T), GDB_RT.GLOB) + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, 0, T), GDB_RT.GLOB) + EgtModifyCurveThickness( MId, -T) + EgtInvertCurve( MId) + if bl then + EgtSetName( MId, LBM) + EgtSetInfo( MId, 'ByBlade', bl) + else + EgtSetName( MId, LM) + end + EgtSetInfo( MId,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if GId then + EgtSetColor( GId or GDB_ID.NULL, AQUA()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, AQUA()) + end + if hint_1 then + EgtSetColor( hint_1 or GDB_ID.NULL, AQUA()) + end + if hint_2 then + EgtSetColor( hint_2 or GDB_ID.NULL, AQUA()) + end + if hint_3 then + EgtSetColor( hint_3 or GDB_ID.NULL, AQUA()) + end + if hint_4 then + EgtSetColor( hint_4 or GDB_ID.NULL, AQUA()) + end + else + if GId then + EgtSetColor( GId or GDB_ID.NULL, ORANGE()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, ORANGE()) + end + if hint_1 then + EgtSetColor( hint_1 or GDB_ID.NULL, ORANGE()) + end + if hint_2 then + EgtSetColor( hint_2 or GDB_ID.NULL, ORANGE()) + end + if hint_3 then + EgtSetColor( hint_3 or GDB_ID.NULL, ORANGE()) + end + if hint_4 then + EgtSetColor( hint_4 or GDB_ID.NULL, ORANGE()) + end + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview then + + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNPar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'MailSlot') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'ms' ,ms) + EgtSetInfo(Lg,'clc' ,clc) + EgtSetInfo(Lg,'ccr' ,ccr) + EgtSetInfo(Lg,'bl' ,bl) + EgtSetInfo(Lg,'d3' ,d3) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'DS' ,DS) + EgtSetInfo(Lg,'DD' ,DD) + EgtSetInfo(Lg,'IL' ,IL) + EgtSetInfo(Lg,'IW' ,IW) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'SCU' ,SCU) + EgtSetInfo(Lg,'LBM' ,LBM) + 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 MailSlot diff --git a/LuaLibs/Main_Assemb_I.lua b/LuaLibs/Main_Assemb_I.lua new file mode 100644 index 0000000..d6ed51f --- /dev/null +++ b/LuaLibs/Main_Assemb_I.lua @@ -0,0 +1,55 @@ +-- +-- 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 +-- +-- Main_Assemb_l.lua by EgalWare s.r.l. 2016.05.28 +-- Main disposizione assemblato a raggruppamento + +-- Intestazioni +EgtEnableDebug( false) + +----------------------------------------------------------------- +local function InteractiveChoice() + + -- chiedo dato all'iutente + local tsDisp = EgtDialogBox( ' 0 = dispose, 1 = assembled, 2 = explode', {'disp mode:', '0'}) + local sDisp = '0' + local nDisposeMain = 0 + + if tsDisp then + sDisp = tsDisp[1] + end + + if sDisp ~= nil then + if sDisp == '0' then nDisposeMain = 0 + elseif sDisp == '1' then nDisposeMain = 1 + elseif sDisp == '2' then nDisposeMain = 2 + else nDisposeMain = 0 end + end + + local sRequireCompoName = '_AssemblyDisp' + -- lancio il componente base + local MHgen = require( sRequireCompoName) + local bOkD = MHgen.AssemblyDispose( nDisposeMain) + + return bOkD +end + +----------------------------------------------------------------- +-- *** Main function *** +----------------------------------------------------------------- +local sNgeFile = EgtGetCurrFilePath() + +InteractiveChoice() +EgtDraw() +EgtSaveFile( sNgeFile) + +return true diff --git a/LuaLibs/Main_Assembly.lua b/LuaLibs/Main_Assembly.lua new file mode 100644 index 0000000..81534b8 --- /dev/null +++ b/LuaLibs/Main_Assembly.lua @@ -0,0 +1,47 @@ +-- +-- 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 +-- +-- Main_Assemply.lua by EgalWare s.r.l. 2016.05.28 +-- Main disposizione assemblato a raggruppamento + +-- 2022.07.27 V1.002 FM Modification to use compiled code + +-- Tavola per definizione modulo (serve ma non usata) +local Main_Assembly = {} + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') + +----------------------------------------------------------------- +-- *** Main function *** +----------------------------------------------------------------- +function Main_Assembly.main( nDisposeMain) + + local sNgeFile = EgtGetCurrFilePath() + local sRequireCompoName = '_AssemblyDisp' + + -- lancio il componente base + local MHgen = require( sRequireCompoName) + local bOkD = MHgen.AssemblyDispose( nDisposeMain) + EgtDraw() + EgtSaveFile( sNgeFile) + + return true +end + +return Main_Assembly + diff --git a/LuaLibs/MortiseHinge.lua b/LuaLibs/MortiseHinge.lua new file mode 100644 index 0000000..088f3d8 --- /dev/null +++ b/LuaLibs/MortiseHinge.lua @@ -0,0 +1,1955 @@ +-- +-- 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 diff --git a/LuaLibs/OverHead.lua b/LuaLibs/OverHead.lua new file mode 100644 index 0000000..e67472c --- /dev/null +++ b/LuaLibs/OverHead.lua @@ -0,0 +1,812 @@ +-- +-- 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 +-- +-- OverHead.lua by EgalWare s.r.l. 2016.06.29 +-- Autore: Filippo Monchi +-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi + +-- 2016.09.21 V1.0a1 FM Add warning messages +-- 2018.04.05 V1.0a2 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.0a3 FM Add parameter to show into message 402 +-- 2018.11.15 V1.0a4 FM Manage latch strike option +-- 2018.11.15 V1.0a4 FM Manage Y shift from door side +-- 2018.11.15 V1.0a4 FM Manage face thru the thickness (only when it strike) and double anti-splint paths +-- 2018.12.10 V1.0a5 FM Manage geometry for calculate box without Arm volume (when strike) +-- 2019.10.16 V1.0a6 FM Manage steel option (disable generation of some geometries) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.30 V2.001 FM Add clean corner geometries +-- 2020.04.29 V2.002 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.11.24 V3.001 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.002 FM Modification to use compiled code + +-- Tavola per definizione modulo (serve ma non usata) +local OverHead = {} + +-- 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 function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function OverHead.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + + tMhPar.fht = 0 -- setto il face h top a 0 + tMhPar.fhb = 0 -- setto il face h bottom a 0 + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then + tMhPar.sf = tMhPar.T + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso del chisel + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se non c'è la variabile che indica al face di sbordare + if tMhPar.ls == nil then + tMhPar.ls = true + end + + -- se altezza cava maggiore o uguale dello spessore porta la risetto come spessore porta + -- e disabilito il chisel e il clean corner + tMhPar.bETh = false + if ( tMhPar.H - DGD.dT) >= GEO.EPS_SMALL then + tMhPar.H = DGD.dT + tMhPar.ech = false -- disattivo il chisel + tMhPar.rf = 0 -- disattivo il radius face + tMhPar.bETh = true + tMhPar.ls = true + tMhPar.clc = nil + tMhPar.CLC = nil + -- do errore se altezza cava maggiore o uguale dello spessore porta + -- return tMhPar, 2399, string.format(EgtDoorsMsg[432], tMhPar.Nome, tMhPar.H, DGD.dT, tMhPar.Path) + end + + if not tMhPar.DY or tMhPar.DY == 0 then -- se non c'è il parametro spostamento o è a 0 + tMhPar.DY = 0 + if not tMhPar.ls and tMhPar.H then -- se non sborda (latch strike) lo setto per stare in centro allo spessore porta + tMhPar.DY = (DGD.dT - tMhPar.H) / 2 + end + end + + -- Assegno parametri da ddf + if DGD.ARMLENGTH then + tMhPar.L = DGD.ARMLENGTH + end + + if DGD.ARMPOS then + tMhPar.DS = 0 + end + + if DGD.POCKLENGTH then + tMhPar.L2 = DGD.POCKLENGTH + end + + if DGD.POCKPOS then + tMhPar.DS2 = 0 + end + + if DGD.POCKET_OFFSET then -- se esiste offset in Z ne prendo il valore assoluto + DGD.POCKET_OFFSET = abs(DGD.POCKET_OFFSET) + end + + if DGD.ARMPOS <= GEO.EPS_SMALL and tMhPar.DS <= GEO.EPS_SMALL then + + if DGD.Lock == 'L' then + tMhPar.OS = 1 + else + tMhPar.OS = -1 + end + + -- inverto il valore perché il bordo a filo si trova dal lato opposto + if DGD.Push then + tMhPar.OS = - tMhPar.OS + end + else + tMhPar.OS = 0 + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLMM + local nLMMi = 1 + local sLG + local nLGi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + tMhPar.LGM = nil + tMhPar.LMM = nil + else + tMhPar.est = 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 -- geometria arm + sLM = tMhPar.LM + if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + end + if tMhPar.LA then -- geometria antischeggia arm + sLA = tMhPar.LA + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end + end + if tMhPar.LMM then -- geometria pocket + sLMM = tMhPar.LMM + if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMM, nLMMi) end + end + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) 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 = -2394 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -2396 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + dNumLog = -2396 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then + dNumLog = -2396 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMM, nLMMi, tMhPar.d3, dNumLog, sMchngName3) + elseif not tMhPar.est and nTempT3 then + tMhPar.d3 = nTempT3 + end + end + + -- Regola applicazione chiseling: + -- se ho impostato un raccordo, anche se poi viene annullato perchè inferiore del raggio fresa + -- disabilito il chiseling perchè implica che 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.CLC = 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 + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + end + + -- se la profondità della arm 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 = -2393 + 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 arm è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then + dNumLog = -2398 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + -- se la profondità antischeggia della arm è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then + dNumLog = -2397 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 - 0.05 -- tolgo 0.05 per permettere la lavorazione + end + + if tMhPar.T and tMhPar.T > 0 and tMhPar.ls then + tMhPar.fht = tMhPar.T + tMhPar.fhb = tMhPar.fht + end + + -- se la profondità della pocket è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then + dNumLog = -2395 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3)) + tMhPar.T2 = dMaxMat3 + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function OverHead.Draw( tOHead, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni + local L = tOHead.L + local H = tOHead.H + local T = tOHead.T + local R = tOHead.rf + local clc = tOHead.clc + local ccr = tOHead.ccr + local d = tOHead.d + local p = tOHead.p + local sf = tOHead.sf + local d2 = tOHead.d2 + local DS = tOHead.DS + local OS = tOHead.OS + local L2 = tOHead.L2 + local H2 = tOHead.H2 + local T2 = tOHead.T2 + local d3 = tOHead.d3 + local p3 = tOHead.p3 + local s = tOHead.s + local DS2 = tOHead.DS2 + local ech = tOHead.ech -- abilitazione chisel + local bEqualTh = tOHead.bETh + local ls = tOHead.ls + local fht = tOHead.fht + local fhb = tOHead.fhb + local est = tOHead.est + local kbs = tOHead.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tOHead.pbs + local DY = tOHead.DY + local cl = 0 + local invG = 1 + -- Assegno i nomi geometrie + local LG = tOHead.LG -- nome geometria arm + local LM = tOHead.LM -- nome lavorazione arm + local LA = tOHead.LA -- nome geometria antischeggia + local LGM = tOHead.LGM -- nome geometria pocket + local LMM = tOHead.LMM -- nome lavorazione pocket + local CH = tOHead.CH -- nome suffisso lavorazione chisel + local CLC = tOHead.CLC -- nome geometria clean corner + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHead.Nome + local nCompoNpar = tOHead.Npar + local sCompoPath = tOHead.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tOHead.nCod + local sCodAdj = tOHead.sCod + -- nomi parametri per messaggi + local sNamePar1 = tOHead.N1 or 'L' + local sNamePar2 = tOHead.N2 or 'H' + local sNamePar3 = tOHead.N3 or 'T' + local sNamePar4 = tOHead.N4 or 'd' + local sNamePar5 = tOHead.N5 or 'p' + local sNamePar6 = tOHead.N6 or 'd2' + local sNamePar7 = tOHead.N7 or 'DS' + local sNamePar8 = tOHead.N8 or 'OS' + local sNamePar9 = tOHead.N9 or 'sf' + local sNamePar10 = tOHead.N10 or 'L2' + local sNamePar11 = tOHead.N11 or 'H2' + local sNamePar12 = tOHead.N12 or 'T2' + local sNamePar13 = tOHead.N13 or 'd3' + local sNamePar14 = tOHead.N14 or 'p3' + local sNamePar15 = tOHead.N15 or 's' + local sNamePar16 = tOHead.N16 or 'DS2' + local sNamePar17 = tOHead.N17 or 'R' + local sNamePar18 = tOHead.N18 or 'clc' + local sNamePar19 = tOHead.N19 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2300 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + -- variabili dei percorsi geometrici + local nGeom1, nGeom2, nAS1, nAS2 + local nPkToJoin1, nPkToJoin2, nPkToJoin, nIdSideBoxUp + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + -- o setto la disabilitazione della creazione di alcune geometrie + if not L or not H then + bMakeFaceGeom = false + clc = nil + CLC = nil + end + + if not T then + T = 0 + end + + -- se non sborda + if not ls then + DY = DY + H/2 -- compenso lo spostamento della metà cava + -- se c'è un raccordo setto per raccordare tutti gli angoli + if R and R > 0 then + cl = 3 + end + end + + if est or not L2 or not H2 then + bMakeMortGeom = false + end + + if not T2 then + T2 = 0 + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + LG = LG .. CH + tOHead.LG = LG + tOHead.smr = 1 -- inserisco i raccordini per non fare il chisel + -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel + if nDrawMach == 1 then + nForceMakeFace = 2 + end + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeFaceGeom and 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 bMakeFaceGeom and H <= 0 then + EC = 3 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif bMakeFaceGeom and nDrawMach > 0 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 d + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and d2 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 d2 + L = d2 + 0.002 + else + d2 = L - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 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 bMakeFaceGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeFaceGeom and L <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d + elseif bMakeFaceGeom and OS ~= 0 and OS ~= 1 and OS ~= -1 then + EC = 9 + EM = string.format(EgtDoorsMsg[417],sNamePar8,OS, sCompoPath) -- il parametro 'OS' accetta solo valore: 0, 1 o -1 + OS = 0 + elseif bMakeFaceGeom and DS < 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[404],sNamePar7,EgtToUiUnits(DS), sCompoPath) -- il parametro 'DS' deve essere > 0 + DS = 0 + elseif bMakeMortGeom and nDrawMach > 0 and d3 < DgMin then + EC = 11 + EM = string.format(EgtDoorsMsg[400],sNamePar13,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif bMakeMortGeom and H2 <= 0 then + EC = 12 + EM = string.format(EgtDoorsMsg[401],sNamePar11,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 + H2 = d3/2 + elseif bMakeMortGeom and nDrawMach > 0 and L2 <= d3 then + if DGD.bProoduce then + EC = 13 + EM = string.format(EgtDoorsMsg[402],sNamePar10,EgtToUiUnits(L2),sNamePar13,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile d3 + L2 = d3 + 0.002 + else + d3 = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and ( p3 < PtMin or p3 > PtMax) then + EC = 14 + EM = string.format(EgtDoorsMsg[403],sNamePar14,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeMortGeom and T2 < 0 then + EC = 15 + EM = string.format(EgtDoorsMsg[404],sNamePar12,EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere >= 0 + T2 = 0 + elseif bMakeMortGeom and L2 <= 0 then + EC = 16 + EM = string.format(EgtDoorsMsg[401],sNamePar10,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L' deve essere > 0 + L2 = d3 + 0.002 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar9,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + EC = 17 + sf = d + elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar15,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + EC = 18 + s = d3 + elseif bMakeMortGeom and DS2 < 0 then + EC = 19 + EM = string.format(EgtDoorsMsg[404],sNamePar16,EgtToUiUnits(DS2), sCompoPath) -- il parametro 'DS2' deve essere > 0 + DS2 = 0 + elseif bMakeFaceGeom and ls and R < 0 then + EC = 20 + EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(R), sCompoPath) -- il parametro 'R' deve essere >= 0 + R = d/2 + elseif bMakeFaceGeom and R and L <= R*2 then + EC = 21 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(R),sNamePar1..'/2',EgtToUiUnits(L/2), sCompoPath) -- il parametro 'R' deve essere < 'L/2' + L = (R*2)+1 + elseif bMakeFaceGeom and ls and R >= H then + EC = 22 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(R),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'R' deve essere < H + R = d/2 + elseif bMakeFaceGeom and not ls and H < d then + if DGD.bProoduce then + EC = 23 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore o uguale del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeFaceGeom and not ls and R and H <= R*2 then + EC = 24 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(R),sNamePar2..'/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'R' deve essere < H/2 + R = H/2 + elseif bMakeFaceGeom and not ls and cl > 0 and R and R < 0 then + EC = 25 + EM = string.format(EgtDoorsMsg[404],sNamePar17,EgtToUiUnits(R), sCompoPath) -- il parametro 'R' deve essere >= 0 + R = H/2 + elseif bMakeFaceGeom and not ls and cl > 0 and R and abs(R - (H/2)) < GEO.EPS_SMALL and L <= H then + EC = 26 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + L = H+5 + elseif bMakeFaceGeom and not ls and cl > 0 and R and R < (H/2) and L <= (R*2) then + EC = 27 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar17..'*2',EgtToUiUnits(R*2), sCompoPath) -- il parametro 'L' deve essere > 'R*2' + L = (R*2)+5 + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 28 + EM = string.format(EgtDoorsMsg[407],sNamePar18,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + end + + if not bPreview and EC ~= 0 then + return (ErrorBase+EC), EM + end + + -- Se Preview cancello tutto + if bPreview then + EgtNewFile() + EgtSetDefaultMaterial( BLACK()) + end + + -- Pezzo e Layer + local Pz + + if bPreview then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + else + if not RC then + Pz = EgtGetCurrPart() -- pezzo corrente + end + if not Pz then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + end + end + + local Lg, Dm + local sRequireCompoName + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + if ls then -- se latch strike lancio il componente standard + sRequireCompoName = '_OverHeadArm' + else + sRequireCompoName = '_Latch' + tOHead.cl = cl + tOHead.invG = invG + tOHead.DY = -DY + tOHead.smr = 0 + end + + if bMakeFaceGeom then + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1, nAS1, nAS2, nIdSideBoxUp = MHgen.Draw( EC, EM, tOHead, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor, 'OH') + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + local CLC1 + if CLC and clc and clc > 0 and clc < H and clc < L then + CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T) + if CLC1 then + -- se mantiene lato anche su face + if kbs and kbs > 0 then + local sKeepMode = 'n' -- setto di default per mantenere il lato narrow + if bEqualTh or not ls then -- se spessore passante o in centro allo spessore + 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 + EgtSetInfo( CLC1,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( CLC1,'DeltaPos' ,( L+(2*DS))) + + if ls then -- se latch string + if OS <= 0 then -- se cava non aperta a destra + -- 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()) + -- muovo ulteriormente le geometrie + EgtMove( CLC2, Point3d(-((L/2)+DS),0,0) - ORIG()) + end + if OS >= 0 then -- se cava non aperta a sinistra + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L/2),-H,0) - ORIG()) + -- muovo ulteriormente le geometrie + EgtMove( CLC1, Point3d(-((L/2)+DS),0,0) - ORIG()) + else + EgtErase(CLC1) + end + else -- altrimenti non latch strike + if OS <= 0 then -- se cava non aperta a destra + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + EgtMove( CLC2, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + EgtMove( CLC3, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + end + if OS >= 0 then -- se cava non aperta a sinistra + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + -- muovo ulteriormente le geometrie + EgtMove( CLC1, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + EgtMove( CLC4, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + else + EgtErase(CLC1) + end + end + end + end + end + end + + if bMakeMortGeom then + tOHead.smr = 0 + -- lancio il secondo componente base + MHgen = require('_OverHeadPocket') + nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, tOHead, bPreview, bRunByCompo, nDrawMach, Pz, Lg) + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della geometria + EgtSetInfo(Lg,'Type' ,'OverHead') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'sf' ,sf) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'DS' ,DS) + EgtSetInfo(Lg,'OS' ,OS) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'ls' ,ls) + EgtSetInfo(Lg,'bEqualTh' ,bEqualTh) + EgtSetInfo(Lg,'DY' ,DY) + EgtSetInfo(Lg,'L2' ,L2) + EgtSetInfo(Lg,'H2' ,H2) + EgtSetInfo(Lg,'T2' ,T2) + EgtSetInfo(Lg,'d3' ,d3) + EgtSetInfo(Lg,'p3' ,p3) + EgtSetInfo(Lg,'s' ,s) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'DS2' ,DS2) + EgtSetInfo(Lg,'fht' ,fht) + EgtSetInfo(Lg,'fhb' ,fhb) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LGM' ,LGM) + EgtSetInfo(Lg,'LMM' ,LMM) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + +return OverHead diff --git a/LuaLibs/OverHeadArm.lua b/LuaLibs/OverHeadArm.lua new file mode 100644 index 0000000..29de8b2 --- /dev/null +++ b/LuaLibs/OverHeadArm.lua @@ -0,0 +1,1370 @@ +-- +-- 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 +-- +-- OverHeadArm.lua by EgalWare s.r.l. 2016.06.29 +-- Autore: Filippo Monchi +-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi + +-- 2016.09.21 V1.0a1 FM Add warning messages +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.04.05 V1.0a3 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.0a4 FM Add parameter to show into message 402 +-- 2018.11.15 V1.0a5 FM Manage latch strike option +-- 2018.11.15 V1.0a5 FM Manage Y shift from door side +-- 2018.11.15 V1.0a5 FM Manage face thru the thickness (only when it strike) and double anti-splint paths +-- 2018.12.10 V1.0a6 FM Manage geometry for calculate box without Arm volume (when strike) +-- 2019.10.16 V1.0a7 FM Manage steel option (disable generation of some geometries, make some closed path instead of open ones) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.30 V2.001 FM Add clean corner geometries +-- 2019.12.17 V2.002 FM Fix error not initialize a DGD variable in case arm is used as single item (not by aggregator) +-- 2020.04.29 V2.003 FM Update for aluminum material +-- 2020.05.25 V2.004 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.07.01 V2.005 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 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 + +-- Tavola per definizione modulo (serve ma non usata) +local OverHeadArm = {} + +-- 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 dExtraL = 1.0 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' + +-- tipologia hardware +local nTypeHdw = 2 + +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, D10, + dParH, PY10, T10, RP10, AR10, + RCI10, kbs, bEqualTh, HB10, ls, + dws, pbs) + + local pIni, pEnd, pCen + local hint3, hint5 + local tPath = {} + local tPathPok = {} + + if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti + + pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0) + DrawAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0) + DrawAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + 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 all'interasse + if RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale + + EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione + local nStep = ceil(T10/RP10) -- numero di passate + local dStep = (T10/nStep) -- passo ricalcolato + local nPass = 1 + local dZedStart = 0 + local dZedWork + local nInv = 1 + + pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart) + + while nPass <= nStep do + + dZedWork = dZedStart - (dStep/2) + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + dZedWork = dZedStart - dStep + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + 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+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) + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + else + EgtSetName( hint3, EBH10) + end + elseif EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + -- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso) + if AR10 ~= 0 and RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +-- Funzione di sistemazione parametri +function OverHeadArm.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 + local nPosDef + + -- parametro disposizione frame su lato wide (se = nil è sulla porta, se = true disposizione frame sul lato wide, se false disposzione su lato narrow) + tMhPar.Dws = DGD.Dws + tMhPar.dThF = DGD.dT + + if DGD.nTypePz == 3 or DGD.nTypePz == 4 then + tMhPar.dThD = DGD.dW + tMhPar.TTP = DGD.dW -- setto come valore iniziale, poi se è abilitata le generazione si setta con il giusto valore + elseif DGD.nTypePz == 5 or DGD.nTypePz == 6 then + tMhPar.dThD = DGD.dH + tMhPar.TTP = DGD.dH -- setto come valore iniziale, poi se è abilitata le generazione si setta con il giusto valore + elseif DGD.nTypePz <= 2 then + tMhPar.dThD = DGD.dT + tMhPar.TTP = DGD.dT + end + + tMhPar.TyP = DGD.nTypePz + tMhPar.fht = 0 -- setto il face h top a 0 + tMhPar.fhb = 0 -- setto il face h bottom a 0 + tMhPar.sopp = ( DGD.Lock == 'L' and DGD.Push) or ( DGD.Lock == 'R' and not DGD.Push) + tMhPar.fopp = 1 + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se non c'è la variabile DS + if not tMhPar.DS then + tMhPar.DS = 0 + end + + -- se vecchia versione e non c'è la variabile che indica al face di sbordare + if not tMhPar.nw and tMhPar.ls == nil then + tMhPar.ls = true + end + + -- se altezza cava maggiore o uguale dello spessore porta la ri-setto come spessore porta + -- e disabilito il chisel e il clean corner + tMhPar.bETh = false + if tMhPar.H and ( tMhPar.H - DGD.dT) >= GEO.EPS_SMALL then + tMhPar.H = DGD.dT + tMhPar.ech = false -- disattivo il chisel + tMhPar.rf = 0 -- disattivo il radius face + tMhPar.bETh = true + tMhPar.ls = true + tMhPar.clc = nil + tMhPar.CLC = nil + -- do errore se altezza cava maggiore o uguale dello spessore porta + -- return tMhPar, 2249, string.format(EgtDoorsMsg[432], tMhPar.Nome, tMhPar.H, DGD.dT, tMhPar.Path) + end + + if not tMhPar.DY or tMhPar.DY == 0 then -- se non c'è il parametro spostamento o è a 0 + tMhPar.DY = 0 + if not tMhPar.ls and tMhPar.H then -- se non sborda (latch strike) lo setto per stare in centro allo spessore porta + tMhPar.DY = (DGD.dT - tMhPar.H) / 2 + end + end + + -- setto il verso di spostamento dell'arm in caso sia lanciato da un aggregatore + DGD.PosDir = -1 + if not DGD.PosXItem then DGD.PosXItem = 0 end + + -- sommo il valore della posizione(da ddf) con quello della posizione aggregatore + nPosDef = DGD.POSITION + ( DGD.PosXItem * DGD.PosDir) + + if nPosDef <= GEO.EPS_SMALL and tMhPar.DS <= GEO.EPS_SMALL then + + if DGD.Lock == 'L' then + tMhPar.OS = 1 + else + tMhPar.OS = -1 + end + + -- inverto il valore perché il bordo a filo si trova dal lato opposto + if DGD.Push then + tMhPar.OS = - tMhPar.OS + end + else + tMhPar.OS = 0 + end + + -- setto parametro riferimento profondità roller + tMhPar.drf = DGD.dT/6 + + if DGD.sFrame then -- se è un assemblato + tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato + tMhPar.sopp = not tMhPar.sopp + tMhPar.fopp = -tMhPar.fopp + 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 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 + 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 + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) 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 = -2245 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -2246 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + dNumLog = -2246 + 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è implica che 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.CLC = 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 + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + 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 = -2244 + 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 = -2248 + 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 = -2247 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 + end + + local sPieceName + if tMhPar.Dws then + -- setto un valore di poco inferiore allo spessore per non fresare le ventose + tMhPar.TTP = tMhPar.dThD - DGD.Spd + -- setto i nomi frame per i messaggi + 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 = -2243 + 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 and tMhPar.ls then + tMhPar.fht = tMhPar.T + tMhPar.fhb = tMhPar.fht + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC 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 + + -- extra bores + if tMhPar.T10 then + if tMhPar.T10 == -0.5 then + tMhPar.T10 = tMhPar.dThF / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > tMhPar.dThF then + tMhPar.T10 = tMhPar.dThF + end + end + + if tMhPar.T11 then + if tMhPar.T11 == -0.5 then + tMhPar.T11 = tMhPar.dThF / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > tMhPar.dThF then + tMhPar.T11 = tMhPar.dThF + end + end + + if tMhPar.T12 then + if tMhPar.T12 == -0.5 then + tMhPar.T12 = tMhPar.dThF / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > tMhPar.dThF then + tMhPar.T12 = tMhPar.dThF + end + end + + if tMhPar.T13 then + if tMhPar.T13 == -0.5 then + tMhPar.T13 = tMhPar.dThF / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > tMhPar.dThF then + tMhPar.T13 = tMhPar.dThF + end + end + + if tMhPar.T14 then + if tMhPar.T14 == -0.5 then + tMhPar.T14 = tMhPar.dThF / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > tMhPar.dThF then + tMhPar.T14 = tMhPar.dThF + end + end + + if tMhPar.T15 then + if tMhPar.T15 == -0.5 then + tMhPar.T15 = tMhPar.dThF / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > tMhPar.dThF then + tMhPar.T15 = tMhPar.dThF + end + end + + if tMhPar.T16 then + if tMhPar.T16 == -0.5 then + tMhPar.T16 = tMhPar.dThF / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > tMhPar.dThF then + tMhPar.T16 = tMhPar.dThF + end + end + + if tMhPar.T17 then + if tMhPar.T17 == -0.5 then + tMhPar.T17 = tMhPar.dThF / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > tMhPar.dThF then + tMhPar.T17 = tMhPar.dThF + end + end + + if tMhPar.T18 then + if tMhPar.T18 == -0.5 then + tMhPar.T18 = tMhPar.dThF / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > tMhPar.dThF then + tMhPar.T18 = tMhPar.dThF + end + end + + if tMhPar.T19 then + if tMhPar.T19 == -0.5 then + tMhPar.T19 = tMhPar.dThF / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > tMhPar.dThF then + tMhPar.T19 = tMhPar.dThF + end + end + + if tMhPar.T20 then + if tMhPar.T20 == -0.5 then + tMhPar.T20 = tMhPar.dThF / 2 + elseif tMhPar.T20 == -1 or tMhPar.T20 > tMhPar.dThF then + tMhPar.T20 = tMhPar.dThF + end + end + + if tMhPar.T21 then + if tMhPar.T21 == -0.5 then + tMhPar.T21 = tMhPar.dThF / 2 + elseif tMhPar.T21 == -1 or tMhPar.T21 > tMhPar.dThF then + tMhPar.T21 = tMhPar.dThF + end + end + + if tMhPar.T22 then + if tMhPar.T22 == -0.5 then + tMhPar.T22 = tMhPar.dThF / 2 + elseif tMhPar.T22 == -1 or tMhPar.T22 > tMhPar.dThF then + tMhPar.T22 = tMhPar.dThF + end + end + + if tMhPar.T23 then + if tMhPar.T23 == -0.5 then + tMhPar.T23 = tMhPar.dThF / 2 + elseif tMhPar.T23 == -1 or tMhPar.T23 > tMhPar.dThF then + tMhPar.T23 = tMhPar.dThF + end + end + + if tMhPar.T24 then + if tMhPar.T24 == -0.5 then + tMhPar.T24 = tMhPar.dThF / 2 + elseif tMhPar.T24 == -1 or tMhPar.T24 > tMhPar.dThF then + tMhPar.T24 = tMhPar.dThF + end + end + + if tMhPar.T25 then + if tMhPar.T25 == -0.5 then + tMhPar.T25 = tMhPar.dThF / 2 + elseif tMhPar.T25 == -1 or tMhPar.T25 > tMhPar.dThF then + tMhPar.T25 = tMhPar.dThF + end + end + + if tMhPar.T26 then + if tMhPar.T26 == -0.5 then + tMhPar.T26 = tMhPar.dThF / 2 + elseif tMhPar.T26 == -1 or tMhPar.T26 > tMhPar.dThF then + tMhPar.T26 = tMhPar.dThF + end + end + + if tMhPar.T27 then + if tMhPar.T27 == -0.5 then + tMhPar.T27 = tMhPar.dThF / 2 + elseif tMhPar.T27 == -1 or tMhPar.T27 > tMhPar.dThF then + tMhPar.T27 = tMhPar.dThF + end + end + + if tMhPar.T28 then + if tMhPar.T28 == -0.5 then + tMhPar.T28 = tMhPar.dThF / 2 + elseif tMhPar.T28 == -1 or tMhPar.T28 > tMhPar.dThF then + tMhPar.T28 = tMhPar.dThF + end + end + + if tMhPar.T29 then + if tMhPar.T29 == -0.5 then + tMhPar.T29 = tMhPar.dThF / 2 + elseif tMhPar.T29 == -1 or tMhPar.T29 > tMhPar.dThF then + tMhPar.T29 = tMhPar.dThF + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function OverHeadArm.Draw( tOHArm, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni + local L = tOHArm.L + local H = tOHArm.H + local T = tOHArm.T + local R = tOHArm.rf + local clc = tOHArm.clc + local ccr = tOHArm.ccr + local d = tOHArm.d + local p = tOHArm.p + local sf = tOHArm.sf + local d2 = tOHArm.d2 + local DS = tOHArm.DS + local OS = tOHArm.OS + local ech = tOHArm.ech -- abilitazione chisel + local bEqualTh = tOHArm.bETh + local ls = tOHArm.ls + local fht = tOHArm.fht + local fhb = tOHArm.fhb + local est = tOHArm.est + local kbs = tOHArm.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tOHArm.pbs + local DY = tOHArm.DY + local cl = 0 + local invG = 1 + local sopp = tOHArm.sopp + local fopp = tOHArm.fopp + local dws = tOHArm.Dws + local dthd = tOHArm.dThD + local ttp = tOHArm.TTP + local typ = tOHArm.TyP + -- tabelle per i fori sullo spessore e di lato + local tExtraBore = {} + local tExtraSHBore = {} + -- inserimento dati nella tabella fori di lato + table.insert( tExtraSHBore, { tOHArm.D3, tOHArm.T3, tOHArm.I3, tOHArm.PX3, tOHArm.PY3, tOHArm.EB3, tOHArm.HB3}) + table.insert( tExtraSHBore, { tOHArm.D4, tOHArm.IY4, tOHArm.T4, tOHArm.I4, tOHArm.PX4, tOHArm.PY4, tOHArm.RP4, tOHArm.EB4, tOHArm.EBH4, tOHArm.HB4, tOHArm.AR4, tOHArm.RCI4}) + table.insert( tExtraSHBore, { tOHArm.D5, tOHArm.IY5, tOHArm.T5, tOHArm.I5, tOHArm.PX5, tOHArm.PY5, tOHArm.RP5, tOHArm.EB5, tOHArm.EBH5, tOHArm.HB5, tOHArm.AR5, tOHArm.RCI5}) + table.insert( tExtraSHBore, { tOHArm.D6, tOHArm.IY6, tOHArm.T6, tOHArm.I6, tOHArm.PX6, tOHArm.PY6, tOHArm.RP6, tOHArm.EB6, tOHArm.EBH6, tOHArm.HB6, tOHArm.AR6, tOHArm.RCI6}) + -- inserimento dati nella tabella fori sullo spessore lato Keyway + table.insert( tExtraBore, { tOHArm.D10, tOHArm.T10, tOHArm.PX10, tOHArm.PY10, tOHArm.EB10}) + table.insert( tExtraBore, { tOHArm.D11, tOHArm.T11, tOHArm.PX11, tOHArm.PY11, tOHArm.EB11}) + table.insert( tExtraBore, { tOHArm.D12, tOHArm.T12, tOHArm.PX12, tOHArm.PY12, tOHArm.EB12}) + table.insert( tExtraBore, { tOHArm.D13, tOHArm.T13, tOHArm.PX13, tOHArm.PY13, tOHArm.EB13}) + table.insert( tExtraBore, { tOHArm.D14, tOHArm.T14, tOHArm.PX14, tOHArm.PY14, tOHArm.EB14}) + table.insert( tExtraBore, { tOHArm.D15, tOHArm.T15, tOHArm.PX15, tOHArm.PY15, tOHArm.EB15}) + table.insert( tExtraBore, { tOHArm.D16, tOHArm.T16, tOHArm.PX16, tOHArm.PY16, tOHArm.EB16}) + table.insert( tExtraBore, { tOHArm.D17, tOHArm.T17, tOHArm.PX17, tOHArm.PY17, tOHArm.EB17}) + table.insert( tExtraBore, { tOHArm.D18, tOHArm.T18, tOHArm.PX18, tOHArm.PY18, tOHArm.EB18}) + table.insert( tExtraBore, { tOHArm.D19, tOHArm.T19, tOHArm.PX19, tOHArm.PY19, tOHArm.EB19}) + -- inserimento dati nella tabella fori sullo spessore lato Secure + table.insert( tExtraBore, { tOHArm.D20, tOHArm.T20, tOHArm.PX20, tOHArm.PY20, tOHArm.EB20}) + table.insert( tExtraBore, { tOHArm.D21, tOHArm.T21, tOHArm.PX21, tOHArm.PY21, tOHArm.EB21}) + table.insert( tExtraBore, { tOHArm.D22, tOHArm.T22, tOHArm.PX22, tOHArm.PY22, tOHArm.EB22}) + table.insert( tExtraBore, { tOHArm.D23, tOHArm.T23, tOHArm.PX23, tOHArm.PY23, tOHArm.EB23}) + table.insert( tExtraBore, { tOHArm.D24, tOHArm.T24, tOHArm.PX24, tOHArm.PY24, tOHArm.EB24}) + table.insert( tExtraBore, { tOHArm.D25, tOHArm.T25, tOHArm.PX25, tOHArm.PY25, tOHArm.EB25}) + table.insert( tExtraBore, { tOHArm.D26, tOHArm.T26, tOHArm.PX26, tOHArm.PY26, tOHArm.EB26}) + table.insert( tExtraBore, { tOHArm.D27, tOHArm.T27, tOHArm.PX27, tOHArm.PY27, tOHArm.EB27}) + table.insert( tExtraBore, { tOHArm.D28, tOHArm.T28, tOHArm.PX28, tOHArm.PY28, tOHArm.EB28}) + table.insert( tExtraBore, { tOHArm.D29, tOHArm.T29, tOHArm.PX29, tOHArm.PY29, tOHArm.EB29}) + + -- Assegno i nomi geometrie + local LG = tOHArm.LG + local LM = tOHArm.LM + local LA = tOHArm.LA + local CH = tOHArm.CH -- nome suffisso lavorazione chisel + local CLC = tOHArm.CLC -- nome geometria clean corner + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHArm.Nome + local nCompoNpar = tOHArm.Npar + local sCompoPath = tOHArm.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tOHArm.nCod + local sCodAdj = tOHArm.sCod + -- nomi parametri per messaggi + local sNamePar1 = tOHArm.N1 or 'L' + local sNamePar2 = tOHArm.N2 or 'H' + local sNamePar3 = tOHArm.N3 or 'T' + local sNamePar4 = tOHArm.N4 or 'd' + local sNamePar5 = tOHArm.N5 or 'p' + local sNamePar6 = tOHArm.N6 or 'd2' + local sNamePar7 = tOHArm.N7 or 'DS' + local sNamePar8 = tOHArm.N8 or 'OS' + local sNamePar9 = tOHArm.N9 or 'sf' + local sNamePar10 = tOHArm.N10 or 'R' + local sNamePar11 = tOHArm.N11 or 'clc' + local sNamePar12 = tOHArm.N12 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 = 2200 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + -- variabili dei percorsi geometrici + local nGeom1, nAS1, nAS2 + local nPkToJoin1, nIdSideBoxUp + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + -- o setto la disabilitazione della creazione di alcune geometrie + if not L or not H then + bMakeFaceGeom = false + clc = nil + CLC = nil + end + + if not T then + T = 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 R or R <= GEO.EPS_SMALL then + R = 0 + end + + -- se non sborda + if H and not ls then + DY = DY + H/2 -- compenso lo spostamento della metà cava + -- se c'è un raccordo setto per raccordare tutti gli angoli + if R and R > 0 then + cl = 3 + end + 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 + tOHArm.LG = LG + tOHArm.smr = 1 -- inserisco i raccordini per non fare il chisel + -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel + if nDrawMach == 1 then + nForceMakeFace = 2 + end + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeFaceGeom and 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 bMakeFaceGeom and H <= 0 then + EC = 3 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif bMakeFaceGeom and nDrawMach > 0 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 d + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and d2 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 d2 + L = d2 + 0.002 + else + d2 = L - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 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 bMakeFaceGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeFaceGeom and L <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d + elseif bMakeFaceGeom and OS ~= 0 and OS ~= 1 and OS ~= -1 then + EC = 9 + EM = string.format(EgtDoorsMsg[417],sNamePar8,OS, sCompoPath) -- il parametro 'OS' accetta solo valore: 0, 1 o -1 + OS = 0 + elseif bMakeFaceGeom and DS < 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[404],sNamePar7,EgtToUiUnits(DS), sCompoPath) -- il parametro 'DS' deve essere > 0 + DS = 0 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 11 + EM = string.format(EgtDoorsMsg[401],sNamePar9,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMakeFaceGeom and R and L <= R*2 then + EC = 12 + EM = string.format(EgtDoorsMsg[406],sNamePar10,EgtToUiUnits(R),sNamePar1..'/2',EgtToUiUnits(L/2), sCompoPath) -- il parametro 'R' deve essere < L/2 + L = (R*2)+1 + elseif bMakeFaceGeom and ls and R >= H then + EC = 13 + EM = string.format(EgtDoorsMsg[406],sNamePar10,EgtToUiUnits(R),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'R' deve essere < H + R = d/2 + elseif bMakeFaceGeom and not ls and H < d then + if DGD.bProoduce then + EC = 14 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore o uguale del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeFaceGeom and not ls and R and H <= R*2 then + EC = 15 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(R),sNamePar2..'/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'R' deve essere < H/2 + R = H/2 + elseif bMakeFaceGeom and not ls and cl > 0 and R and abs(R - (H/2)) < GEO.EPS_SMALL and L <= H then + EC = 16 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + L = H+5 + elseif bMakeFaceGeom and not ls and cl > 0 and R and R < (H/2) and L <= (R*2) then + EC = 17 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar17..'*2',EgtToUiUnits(R*2), sCompoPath) -- il parametro 'L' deve essere > 'R*2' + L = (R*2)+5 + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 18 + EM = string.format(EgtDoorsMsg[407],sNamePar11,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, Dor + local Lg, Dm + local sRequireCompoName + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName( Lg, sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + if ls then -- se latch strike lancio il componente standard + sRequireCompoName = '_OverHeadArm' + else + sRequireCompoName = '_Latch' + tOHArm.cl = cl + tOHArm.invG = invG + tOHArm.DY = -DY + tOHArm.smr = 0 + end + + if bMakeFaceGeom then + + -- riassegno alla tabelle eventuali valori modificati nei controlli + tOHArm.L = L + tOHArm.H = H + tOHArm.T = T + tOHArm.rf = R + tOHArm.d = d + tOHArm.p = p + tOHArm.sf = sf + tOHArm.d2 = d2 + tOHArm.DS = DS + tOHArm.OS = OS + + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1, nAS1, nAS2, nIdSideBoxUp = MHgen.Draw( EC, EM, tOHArm, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor, 'OH') + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + local CLC1 + if CLC and clc and clc > 0 and clc < H and clc < L then + CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T) + if CLC1 then + -- se mantiene lato anche su face + if kbs and kbs > 0 then + local sKeepMode = 'n' -- setto di default per mantenere il lato narrow + if bEqualTh or not ls then -- se spessore passante o in centro allo spessore + 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 + EgtSetInfo( CLC1,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( CLC1,'DeltaPos' ,( L+(2*DS))) + + if ls then -- se latch string + if OS <= 0 then -- se cava non aperta a destra + -- 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()) + -- muovo ulteriormente le geometrie + EgtMove( CLC2, Point3d(-((L/2)+DS),0,0) - ORIG()) + end + if OS >= 0 then -- se cava non aperta a sinistra + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L/2),-H,0) - ORIG()) + -- muovo ulteriormente le geometrie + EgtMove( CLC1, Point3d(-((L/2)+DS),0,0) - ORIG()) + else + EgtErase(CLC1) + end + else -- altrimenti non latch strike + if OS <= 0 then -- se cava non aperta a destra + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + EgtMove( CLC2, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + EgtMove( CLC3, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + end + if OS >= 0 then -- se cava non aperta a sinistra + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + -- muovo ulteriormente le geometrie + EgtMove( CLC1, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + EgtMove( CLC4, Point3d(-((L/2)+DS),-(dThickDoor/2),0) - ORIG()) + else + EgtErase(CLC1) + end + end + end + end + end + end + + if EC == 0 and nDrawMach >= 0 then + + if not bMakeFaceGeom then + L = 0 + end + + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + local AR10 + local RCI10 + + if k == 1 then + D10 = tExtraSHBore[k][1] + T10 = tExtraSHBore[k][2] + I10 = tExtraSHBore[k][3] + PX10 = tExtraSHBore[k][4] + PY10 = tExtraSHBore[k][5] + EB10 = tExtraSHBore[k][6] + HB10 = tExtraSHBore[k][7] + else + D10 = tExtraSHBore[k][1] + IY10 = tExtraSHBore[k][2] + T10 = tExtraSHBore[k][3] + I10 = tExtraSHBore[k][4] + PX10 = tExtraSHBore[k][5] + PY10 = tExtraSHBore[k][6] + RP10 = tExtraSHBore[k][7] + EB10 = tExtraSHBore[k][8] + EBH10 = tExtraSHBore[k][9] + HB10 = tExtraSHBore[k][10] + AR10 = tExtraSHBore[k][11] + RCI10 = tExtraSHBore[k][12] + end + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + if D10 and T10 and ( EB10 or EBH10) then + if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then + + if not IY10 then IY10 = 0 end + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + if not AR10 then AR10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) - ( (L/2) + DS) + local dPosY10 = -PY10 + if bEqualTh or not ls then +-- dPosY10 = ( dPosY10 - (dThickDoor/2)) * fopp + dPosY10 = ( dPosY10 - (dThickDoor/2)) + end + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, D10, 0, dPosY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, not(bEqualTh or not ls), dws, pbs) + + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, D10, 0, dPosY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, not(bEqualTh or not ls), dws, pbs) + end + end + end + end + + -- Costruzione della geometria KEYWAY + -- Extra bores Keyway + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] + local PY10 = tExtraBore[k][4] + local EB10 = tExtraBore[k][5] + + if not dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + -- se dimensioni foro idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) - ( (L/2) + DS) + local dPosY10 = EgtIf( typ <= 2, EgtIf( DGD.Push, PY10, -(PY10 + dThickDoor)), EgtIf( DGD.Push, -(PY10 + dThickDoor), PY10)) + local hint_13 = EgtCircle( Lg, Point3d( dPosX10, dPosY10, 0), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -T10) + EgtSetName( hint_13, EB10) + EgtSetInfo( hint_13, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + if typ <= 2 then + if DGD.Push then + EgtRotate( hint_13, ORIG(), X_AX(), -90 ) -- ruoto in X per posizionarlo sullo spessore porta ( con swing RH) + else + EgtRotate( hint_13, Point3d( 0, -dThickDoor, 0), X_AX(), 90 ) -- ruoto in Y per posizionarlo isullo spessore porta ( con swing RHR) + end + else + if DGD.Push then + EgtRotate( hint_13, Point3d( 0, -dThickDoor, 0), X_AX(), 90 ) -- ruoto in X per posizionarlo sullo spessore porta ( con swing RH) + else + EgtRotate( hint_13, ORIG(), X_AX(), -90 ) -- ruoto in Y per posizionarlo isullo spessore porta ( con swing RHR) + end + end + end + end + end + + -- Costruzione della geometria SECURE + -- Extra bores Secure + for k = 11, 20 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] + local PY10 = tExtraBore[k][4] + local EB10 = tExtraBore[k][5] + + if not dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) - ( (L/2) + DS) + local dPosY10 = EgtIf( typ <= 2, EgtIf( DGD.Push, -(PY10 + dThickDoor), PY10), EgtIf( DGD.Push, PY10, -(PY10 + dThickDoor))) + local hint_13 = EgtCircle( Lg, Point3d( dPosX10, dPosY10, 0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_13, -T10) + EgtSetName( hint_13, EB10) + EgtSetInfo( hint_13, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + if typ <= 2 then + if DGD.Push then + EgtRotate( hint_13, Point3d( 0, -dThickDoor, 0), X_AX(), 90 ) -- ruoto in X per posizionarlo sullo spessore porta ( con swing RH) + else + EgtRotate( hint_13, ORIG(), X_AX(), -90 ) -- ruoto in Y per posizionarlo isullo spessore porta ( con swing RHR) + end + else + if DGD.Push then + EgtRotate( hint_13, ORIG(), X_AX(), -90 ) -- ruoto in X per posizionarlo sullo spessore porta ( con swing RH) + else + EgtRotate( hint_13, Point3d( 0, -dThickDoor, 0), X_AX(), 90 ) -- ruoto in Y per posizionarlo isullo spessore porta ( con swing RHR) + end + end + end + end + end + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'OverHeadArm') + 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,'sf' ,sf) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'ls' ,ls) + EgtSetInfo(Lg,'bEqualTh' ,bEqualTh) + EgtSetInfo(Lg,'DY' ,DY) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'DS' ,DS) + EgtSetInfo(Lg,'OS' ,OS) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'fht' ,fht) + EgtSetInfo(Lg,'fhb' ,fhb) + EgtSetInfo(Lg,'sopp' ,sopp) + EgtSetInfo(Lg,'fopp' ,fopp) + 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,'CH' ,CH) + EgtSetInfo(Lg,'CLC' ,CLC) + EgtSetInfo(Lg,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(Lg,'DeltaPos' ,( L+(2*DS))) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg, nTypeHdw +end + +return OverHeadArm diff --git a/LuaLibs/OverHeadPocket.lua b/LuaLibs/OverHeadPocket.lua new file mode 100644 index 0000000..4ebe79c --- /dev/null +++ b/LuaLibs/OverHeadPocket.lua @@ -0,0 +1,1115 @@ +-- +-- EEEEEEEEEE GGGGGG wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwww wwww +-- EEEE GGGG GGGG wwww wwww wwww +-- EEEE GGGG wwww wwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEE GGGG GGGG wwww wwwwwwww wwww +-- EEEE GGGG GGGG wwww wwww wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww +-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww +-- +-- OverHeadPocket.lua by EgalWare s.r.l. 2016.06.30 +-- Autore: Filippo Monchi +-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi + +-- 2016.09.21 V1.0a1 FM Add warning messages +-- 2018.04.05 V1.0a2 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.0a3 FM Add parameter to show into message 402 +-- 2018.12.10 V1.0a4 FM Add notes InserPoint and DeltaPos on any geometries +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.04.29 V2.001 FM Update for aluminum material +-- 2020.05.07 V2.002 FM Add Extra bores and manage geometries for Frames +-- 2020.05.25 V2.003 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.07.01 V2.004 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2020.12.18 V2.005 FM Fix error on compare variables for errors that has their geometry disabled +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.03.09 V3.001 FM Add missing function DrawAddCircleDrawCircle +-- 2021.03.12 V3.002 FM Manage rotation parameters on extra bores/buttonhole +-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.004 FM Modification to use compiled code +-- 2024.07.19 V3.005 FM Set note 'NotCheckDir' to pocketing paths + +-- Tavola per definizione modulo (serve ma non usata) +local OverHeadPocket = {} + +-- 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 + +-- tipologia hardware +local nTypeHdw = 1 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, + nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine +end + +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, D10, + dParH, PY10, T10, RP10, AR10, + RCI10, kbs, bEqualTh, HB10, dws, + pbs) + + local pIni, pEnd, pCen + local hint3, hint5 + local tPath = {} + local tPathPok = {} + + if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti + + pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0) + DrawAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0) + DrawAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + 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 all'interasse + if RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale + + EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione + local nStep = ceil(T10/RP10) -- numero di passate + local dStep = (T10/nStep) -- passo ricalcolato + local nPass = 1 + local dZedStart = 0 + local dZedWork + local nInv = 1 + + pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart) + + while nPass <= nStep do + + dZedWork = dZedStart - (dStep/2) + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + dZedWork = dZedStart - dStep + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + 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+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) + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + else + EgtSetName( hint3, EBH10) + end + elseif EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + -- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso) + if AR10 ~= 0 and RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +-- Funzione di sistemazione parametri +function OverHeadPocket.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat1 + local dMaxMat2 -- per foro o foro profondo + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT1 + local nTempT3 + local sMchngName1 + local sMchngName3 + + -- 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 + 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 + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi + local sLGH -- bore machining + local nLGHi + + -- se porta steel o aluminum disabilito tutto tranne il foro + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then +-- tMhPar.LG = nil -- lascio la geometria di contorno + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + else + tMhPar.est = nil + end + + tMhPar.sopp = ( DGD.Lock == 'L' and DGD.Push) or ( DGD.Lock == 'R' and not DGD.Push) + tMhPar.fopp = 1 + + if tMhPar.LM then + sLM = tMhPar.LM + nLMi = 1 + if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + end + + -- foro o foro profondo + if tMhPar.mh and tMhPar.LGH then + sLGH = tMhPar.LGH + nLGHi = 1 + if DGD.MachEn > 0 then nTempT3, dMaxMat2, sMchngName3 = MB.GetToolDataFromAttrib( sLGH, nLGHi) 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.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -2292 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif nTempT1 then + tMhPar.d = nTempT1 + end + + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per foro profondo + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat2 then + dNumLog = -2298 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLGH, nLGHi, nil, dNumLog, sMchngName3) + 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 = -2299 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 + end + + -- se foro e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and dMaxMat2 and tMhPar.TB2 and tMhPar.TB2 > dMaxMat2 then + dNumLog = -2297 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(dMaxMat2)) + tMhPar.TB2 = 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 = -2296 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.TB2 and abs(tMhPar.TB2) > tMhPar.TTP then + dNumLog = -2296 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'TB2', EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.TB2 = tMhPar.TTP + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function OverHeadPocket.Draw( tOHPkt, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni + local L = tOHPkt.L + local H = tOHPkt.H + local T = tOHPkt.T + local d = tOHPkt.d + local p = tOHPkt.p + local s = tOHPkt.s + local DS = tOHPkt.DS + local est = tOHPkt.est + local kbs = tOHPkt.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tOHPkt.pbs + local mh = tOHPkt.mh + local HB2 = tOHPkt.HB2 + local TB2 = tOHPkt.TB2 + local sopp = tOHPkt.sopp + local fopp = tOHPkt.fopp + local dws = tOHPkt.Dws + local dthd = tOHPkt.dThD + local ttp = tOHPkt.TTP + local tExtraBore = {} + table.insert( tExtraBore, { tOHPkt.D3, tOHPkt.T3, tOHPkt.I3, tOHPkt.PX3, tOHPkt.PY3, tOHPkt.EB3, tOHPkt.HB3}) + table.insert( tExtraBore, { tOHPkt.D4, tOHPkt.IY4, tOHPkt.T4, tOHPkt.I4, tOHPkt.PX4, tOHPkt.PY4, tOHPkt.RP4, tOHPkt.EB4, tOHPkt.EBH4, tOHPkt.HB4, tOHPkt.AR4, tOHPkt.RCI4}) + table.insert( tExtraBore, { tOHPkt.D5, tOHPkt.IY5, tOHPkt.T5, tOHPkt.I5, tOHPkt.PX5, tOHPkt.PY5, tOHPkt.RP5, tOHPkt.EB5, tOHPkt.EBH5, tOHPkt.HB5, tOHPkt.AR5, tOHPkt.RCI5}) + table.insert( tExtraBore, { tOHPkt.D6, tOHPkt.IY6, tOHPkt.T6, tOHPkt.I6, tOHPkt.PX6, tOHPkt.PY6, tOHPkt.RP6, tOHPkt.EB6, tOHPkt.EBH6, tOHPkt.HB6, tOHPkt.AR6, tOHPkt.RCI6}) + -- Assegno i nomi geometrie + local LG = tOHPkt.LG + local LM = tOHPkt.LM + local LGH = tOHPkt.LGH -- nome geometria horizontal bore + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHPkt.Nome + local nCompoNpar = tOHPkt.Npar + local sCompoPath = tOHPkt.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tOHPkt.nCod + local sCodAdj = tOHPkt.sCod + -- nomi parametri per messaggi + local sNamePar1 = tOHPkt.N1 or 'L' + local sNamePar2 = tOHPkt.N2 or 'H' + local sNamePar3 = tOHPkt.N3 or 'T' + local sNamePar4 = tOHPkt.N4 or 'd' + local sNamePar5 = tOHPkt.N5 or 'p' + local sNamePar6 = tOHPkt.N6 or 's' + local sNamePar7 = tOHPkt.N7 or 'DS' + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2250 + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + -- variabili che abilitano la creazione della geometria + local bMakeMortGeom = true + local bMakeBoreGeom = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + +-- if est or not L or not H then -- permetto con materiale steel e aluminum + if not L or not H then + bMakeMortGeom = false + end + + if not DS then + DS = 0 + end + + if ( not HB2 or not TB2) or not mh then + bMakeBoreGeom = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if nDrawMach > 0 and bMakeMortGeom 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 bMakeMortGeom and H <= 0 then + EC = 2 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif nDrawMach > 0 and bMakeMortGeom and L <= d then + if DGD.bProoduce then + EC = 3 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile d + L = d + 0.002 + else + d = L - 0.002 + end + elseif nDrawMach > 0 and bMakeMortGeom and ( p < PtMin or p > PtMax) then + EC = 4 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and T < 0 then + EC = 5 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and L <= 0 then + EC = 6 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d + elseif nDrawMach > 0 and bMakeMortGeom and s <= 0 then + EM = string.format(EgtDoorsMsg[401],sNamePar6,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + EC = 7 + s = d + elseif bMakeMortGeom and DS < 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[404],sNamePar7,EgtToUiUnits(DS), sCompoPath) -- il parametro 'DS' deve essere > 0 + DS = 0 + 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, Dor + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName( Lg, sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + Dor = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante l'origine + EgtSetName( Dor, DM) + end + + local hint1, hint2, hint3, hint4, hint5, hint6, hint, hintPk, hintH + + -- disegno cerchio origine + if Dor then + local dDiamCircle + if d then + dDiamCircle = d + else + dDiamCircle = 10 + end + local nCircleOri = EgtCircle( Dor, Point3d(0,0,0), dDiamCircle/4 , GDB_RT.LOC) + EgtSetColor( nCircleOri, NAVY()) + end + + if nDrawMach ~= 1 and LG and bMakeMortGeom then -- se abilitata geometria esterna + + hint1 = DrawAddLineDrawCircle( Point3d(0,H/2,0), Point3d(L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint2 = DrawAddLineDrawCircle( Point3d(L/2,H/2,0), Point3d(L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint3 = DrawAddLineDrawCircle( Point3d(L/2,-(H/2),0), Point3d(-L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint4 = DrawAddLineDrawCircle( Point3d(-L/2,-(H/2),0), Point3d(-L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint5 = DrawAddLineDrawCircle( Point3d(-L/2,H/2,0), Point3d(0,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) + EgtModifyCurveThickness(hint, -T) + EgtSetName(hint,LG) + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( hint, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hint,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint,'DeltaPos' ,( L+(2*DS))) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint, 'ProbeSide', '1') + end + end + + if bMakeBoreGeom then -- se foro orizzontale abilitato + -- se parametri secondo foro + if HB2 and TB2 and abs(HB2) > 0 and abs(TB2) > 0 then + hintH = EgtCircle( Lg, Point3d(0,0,0), abs(HB2/2) , GDB_RT.LOC) + EgtModifyCurveThickness(hintH, -abs(TB2)) + EgtSetName(hintH,LGH) + EgtSetInfo( hintH,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + -- muovo la geometria verso sinistra del valore di L/2 (o HB2/2) + DS + if L and L > 0 then + EgtMove( hintH, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintH, 'DeltaPos',( L+(2*DS))) + else + EgtMove( hintH, Point3d(-((HB2/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintH, 'DeltaPos',( HB2+(2*DS))) + end + + if kbs and kbs > 0 then + EgtSetInfo( hintH, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintH, 'ProbeSide', '1') + end + end + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 and LM and bMakeMortGeom then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + --------------------------------------- + -- geometria svuotatura giro interno + --------------------------------------- + local tPocket = {} + local pIni + local pEnd + local pEnd2 + local nStep + local dStep + local dPerim + local nDirVers + local nPass + local dZedStart = 0 + local dZedWork = -T + + -- individuo in che caso sono + local nCase + if abs(H-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H-d) > ( d*0.98)) and ( (H-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (H-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag + nCase = 4 + end + + dPerim = 2*( H + L -(2*d)) + nStep = ceil(T/s) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + + local nDoubleStep = nStep * 2 + + while nPass <= nDoubleStep do + + -- primo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = dZedStart - ((dStep * nPass)/2) + if nPass == nDoubleStep then + dZedWork = -T + end + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = -T + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- Uscita in Z0 + pIni = pEnd + dZedWork = 0 + + if ( nDeltaMovX > (L-d)) then + nDeltaMovX = (L-d) + end + pEnd = Point3d((-nDirVers*((L-d)/2)-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H-d)/dPerim)) + end + pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H+L-(2*d))/dPerim)) + end + pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*H)+L-(3*d))/dPerim)) + end + pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + end + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + -- prima linea contorno + pIni = pEnd + pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + + -- settima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = -1 + local nDistYcentr = (d*p) + local nPosYcentr = ((H-d)/2) - nDistYcentr + local bContinue = nPosYcentr > -((H-d)/2) + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + + -- ciclo passate svuotatura + while bContinue do + + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + + -- linea passata in X + pIni = pEnd + pEnd = Point3d((nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -((H-d)/2) + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + nDirVers = -nDirVers + -- ricalcolo punti per linea successiva + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + -- Uscita in Z0 + pIni = pEnd + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + + -- trasformo in geometria composita il percorso di svuotatura + if ( #tPocket > 0) then + hintPk = EgtCurveCompo( Lg, tPocket, true) + if hintPk then + EgtModifyCurveThickness( hintPk, 0) + EgtSetName( hintPk, LM) + EgtSetInfo( hintPk, 'NotCheckDir', '1') + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( hintPk, Point3d(-((L/2)+DS),0,0) - ORIG()) + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( Dm, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintPk,'InserPoint', 'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( Dm,'InserPoint', 'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintPk,'DeltaPos', ( L+(2*DS))) + EgtSetInfo( Dm,'DeltaPos', ( L+(2*DS))) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPk, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk, 'ProbeSide', '1') + end + else + EC = ErrorBase + 11 + EM = string.format(EgtDoorsMsg[427], sCompoPath) + end + end + end + + if EC == 0 and nDrawMach >= 0 then + + if not ( LG and bMakeMortGeom) then + L = 0 + end + + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + local AR10 + local RCI10 + + if k == 1 then + D10 = tExtraBore[k][1] + T10 = tExtraBore[k][2] + I10 = tExtraBore[k][3] + PX10 = tExtraBore[k][4] + PY10 = tExtraBore[k][5] + EB10 = tExtraBore[k][6] + HB10 = tExtraBore[k][7] + else + D10 = tExtraBore[k][1] + IY10 = tExtraBore[k][2] + T10 = tExtraBore[k][3] + I10 = tExtraBore[k][4] + PX10 = tExtraBore[k][5] + PY10 = tExtraBore[k][6] + RP10 = tExtraBore[k][7] + EB10 = tExtraBore[k][8] + EBH10 = tExtraBore[k][9] + HB10 = tExtraBore[k][10] + AR10 = tExtraBore[k][11] + RCI10 = tExtraBore[k][12] + end + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + if D10 and T10 and ( EB10 or EBH10) then + if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then + + if not IY10 then IY10 = 0 end + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + if not AR10 then AR10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) - ( (L/2) + DS) +-- local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) - L+(2*DS) +-- local dPosX10 = ( PX10 * EgtIf( sopp, 1, -1)) + local dPosY10 = -PY10 +-- if bEqualTh or not ls then +-- dPosY10 = ( dPosY10 - (dThickDoor/2)) +-- end + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, D10, 0, dPosY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs) + + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, D10, 0, dPosY10, T10, RP10, AR10, RCI10, kbs, bEqualTh, HB10, dws, pbs) + end + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hintH then + nIdSideBoxUp = EgtCopyGlob( hintH, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint then + EgtSetColor(hint,AQUA()) + end + if hintH then + EgtSetColor(hintH,AQUA()) + end + if hintPk then + EgtSetColor(hintPk,AQUA()) + end + else + if hint then + EgtSetColor(hint,ORANGE()) + end + if hintH then + EgtSetColor(hintH,ORANGE()) + end + if hintPk then + EgtSetColor(hintPk,ORANGE()) + end + end + else -- altrimenti non Preview + + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + + if Dor then + EgtErase(Dor) + end + + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'OverHeadPocket') + EgtSetInfo(Lg,'Nome' ,sCompoName) + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'DS' ,DS) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'HB2' ,HB2) + EgtSetInfo(Lg,'TB2' ,TB2) + EgtSetInfo(Lg,'sopp' ,sopp) + EgtSetInfo(Lg,'fopp' ,fopp) + EgtSetInfo(Lg,'dws' ,dws) + EgtSetInfo(Lg,'dthd' ,dthd) + EgtSetInfo(Lg,'ttp' ,ttp) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LGH' ,LGH) + EgtSetInfo(Lg,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + if L then + EgtSetInfo(Lg,'DeltaPos' ,( L+(2*DS))) + elseif HB2 then + EgtSetInfo(Lg,'DeltaPos' ,( HB2+(2*DS))) + end + EgtSetInfo(Lg,'Path' ,sCompoPath) + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg, nTypeHdw +end + +return OverHeadPocket diff --git a/LuaLibs/Pivot.lua b/LuaLibs/Pivot.lua new file mode 100644 index 0000000..f987931 --- /dev/null +++ b/LuaLibs/Pivot.lua @@ -0,0 +1,3024 @@ +-- +-- EEEEEEEEEE GGGGGG wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwww wwww +-- EEEE GGGG GGGG wwww wwww wwww +-- EEEE GGGG wwww wwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEE GGGG GGGG wwww wwwwwwww wwww +-- EEEE GGGG GGGG wwww wwww wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww +-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww +-- +-- Pivot.lua by EgalWare s.r.l. 2016.07.14 +-- Autore: Filippo Monchi +-- Pivot + +-- 2016.09.21 V1.011 FM Add warning messages +-- 2016.09.21 V1.012 FM not use reverse geometries '_R' on calculate tool diameter, it must have same diameter than not reverse geometries +-- 2017.12.08 V1.013 FM Manage offset position on probe geometry and duplicate it for manage probe when door is placed on left or right position +-- 2017.12.22 V1.014 FM Manage new backset application point +-- 2018.01.08 V1.015 FM Manage new R1 parameter to add a fillet on single corner +-- 2018.01.12 V1.016 FM Manage new anti splint position path when side pivot correspond to side door (on offset and offsetintermediate type) +-- 2018.02.22 V1.017 FM fix problem on calculate side distance: before into calculation was ignored the offset parameter tMhPar.D_XE define into model lua file +-- 2018.04.06 V1.018 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.05.23 V1.019 FM Manage disposition reference point by .rp parameter for Offsetintermediate pivot +-- 2018.10.17 V1.01a FM Add parameter to show into message 402 +-- 2018.10.19 V1.01b FM Manage T shape also for Offset Pivot +-- 2018.10.19 V1.01b FM Manage disposition reference point by .rp parameter also for Offset pivot +-- 2018.10.22 V1.01c FM Manage better the big radius fillet parameter +-- 2019.07.29 V1.01d FM Manage new differents pivot models and submodels: Centerhung pivot with submodel (1), Offset pivot with submodel (1) 2 3 4, +-- OffsetInpermediate with submodel (1) 3 4 +-- the defalult and old one is submodel (1) for all model +-- For new Intermediate submodel 4 use _PivotL component instead of _Mortise component +-- Manage better the probe geometry disposition: calculate when there is not enough space to insert probe geometry +-- 2019.08.27 V1.01e FM Manage new parameter HB to not rotate the horizontal bore of Intermediate Pivot +-- 2019.08.27 V1.01e FM Modify the bore depth in case edge is bevel and HB parameter is true +-- 2019.09.16 V1.01f FM Fix set wrong parameter into call CheckTool for chisel tool +-- 2019.09.30 V1.020 FM Manage Rectangular shape on standard intermediate pivot (by L3 = 0) +-- 2019.10.01 V1.021 FM Manage better the position in Z when backset is set to 0 (into center door thickness) +-- 2019.10.07 V1.022 FM Allow machine convex profile only with intermediate pivot subtype 1 +-- 2019.10.08 V1.023 FM Manage steel option (disable to generate pocket paths, mortise and not horizontal bore) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.21 V2.001 FM Modify the closed path start point for steel material +-- 2019.10.25 V2.002 FM Add clean corner geometries +-- 2019.12.06 V2.003 FM fix a bug to assign to variable H instead of tMhPar.H at CenterHung section +-- 2019.12.18 V2.004 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.005 FM fix a bug on clean corner direction path in case main path turn reverse +-- 2020.04.29 V2.006 FM Update for aluminum material +-- 2020.05.04 V2.006 FM Manage extra bores on type 1, 2, 3 and only subtype 1 (standard model) +-- 2020.05.25 V2.007 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.07.01 V2.008 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2020.10.14 V2.009 FM Fix error on missing parameter for CheckTool function +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.01.25 V3.001 FM Fix error when variable posp is not defined (disabled from hardware manager) +-- 2021.03.12 V3.002 FM Manage rotation parameters on extra bores/buttonhole +-- 2021.03.12 V3.002 FM Add missing functions DrawLocAddLineDrawCircle and DrawLocAddCircleDrawCircle +-- 2021.08.26 V3.003 FM Compare better the wide knuckle (L3) with face tool diameter and anti-splint tool diameter +-- 2021.11.24 V3.004 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.005 FM Modification to use compiled code +-- 2023.03.31 V3.006 FM Manage better knuckle disabling, now it checks if L3 = 0 or H3 = 0 too +-- 2024.04.29 V3.007 FM Allow mortise to be bigger than face, but join (jn) parameter (to join face and mortise) will se to false +-- 2024.07.19 V3.008 FM Set note 'NotCheckDir' to pocketing, antisplint and buttonhole pocketing paths +-- 2024.10.29 V3.009 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local Pivot = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DgMin = 4. -- valore minimo diametro utensile +local PtMin = 0.1 +local PtMax = 1.0 +local bShiftBackSetPos = true -- da richiesta MDC +local dMinDistIntpiv = 0.762 +local dMinDistOffspiv = 0.5 +local MB = require( 'MachiningBase') +local dExtraH = 0.5 + +local function DrawLocAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, + nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine +end + +local function DrawLocAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + + if idTable then + table.insert( idTable, nCircle) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumCircle = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nCircle, nNumCircle, sMVar +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione creazione foro o asola o rampa per asola +local function MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, PX10, Int10, D10, + dParH, PY10, T10, RP10, AR10, + RCI10, kbs, HB10, ptype, dws, + pbs) + + local pIni, pEnd, pCen + local hint3, hint5 + local tPath = {} + local tPathPok = {} + + if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti + + pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + hint3 = EgtCurveCompo( Lg, tPath, true) + EgtModifyCurveThickness( hint3, -T10) + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale + + EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione + local nStep = ceil(T10/RP10) -- numero di passate + local dStep = (T10/nStep) -- passo ricalcolato + local nPass = 1 + local dZedStart = 0 + local dZedWork + local nInv = 1 + + pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart) + + while nPass <= nStep do + + dZedWork = dZedStart - (dStep/2) + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + dZedWork = dZedStart - dStep + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + -- se ho altri passi scendo in z + if nPass < nStep then + dZedStart = dZedWork + end + nPass = nPass + 1 + end + -- faccio passata di ritorno + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),-T10) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + + hint5 = EgtCurveCompo( Lg, tPathPok, true) + EgtModifyCurveThickness( hint5, 0) + EgtSetName( hint5, EBH10) + EgtSetInfo( hint5, 'NotCheckDir', '1') + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + else + EgtSetName( hint3, EBH10) + end + elseif EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + -- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso) + if AR10 ~= 0 and RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +local function CheckTool( bCheck1, bJoinCheck, nTypeCompare, dDiamTool, sNamePar, + nCodePar, sLocalMess, dThick, nNumMsg, nNumWrng, + bSetAsMaxMat, n2ndTypeCompare, dNumLog, dMaxMat, bCheck2, + sName, EgtDoorsMsg) + + local nTempT1 + local dMaxMat1 + local sMchngName1 + local nLocalLog = 0 + local dDiamReturn = dDiamTool + + if bCheck1 then + + nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sNamePar, nCodePar) + + if nTypeCompare == 1 then + if dDiamTool and nTempT1 <= 0 then + if DGD.bProoduce and bJoinCheck then + nLocalLog = -2192 + sLocalMess = sLocalMess .. '\n'.. GetMachToolErrorMessage( nTempT1, sNamePar, nCodePar, dDiamTool, nLocalLog, sMchngName1) + end + else + dDiamReturn = nTempT1 + end + elseif nTypeCompare == 2 then + if DGD.bProoduce and not dMaxMat1 then + nLocalLog = -2191 + sLocalMess = sLocalMess .. '\n'.. GetMachToolErrorMessage( nTempT1, sNamePar, nCodePar, nil, nLocalLog, sMchngName1) + end + end + end + + if n2ndTypeCompare == 1 then + -- se la profondità è maggiore della capacità utensile limito la profondità ed emetto un warning + if dThick and dMaxMat1 and dThick > dMaxMat1 then + nLocalLog = nNumWrng + dNumMessage = nNumMsg + sLocalMess = sLocalMess .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], nLocalLog, sName, EgtToUiUnits(dThick), EgtToUiUnits(dMaxMat1)) + if bSetAsMaxMat then + dThick = dMaxMat1 + else + dThick = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat1 + end + end + elseif n2ndTypeCompare == 2 then + -- se foro abilitato e la profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if bCheck2 and dThick and dMaxMat1 and dThick > dMaxMat1 then + nLocalLog = nNumWrng + dNumMessage = nNumMsg + sLocalMess = sLocalMess .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], nLocalLog, sName, EgtToUiUnits(dThick), EgtToUiUnits(dMaxMat1)) + if bSetAsMaxMat then + dThick = dMaxMat1 + else + dThick = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat1 + end + end + end + + if nLocalLog == 0 and dNumLog ~= 0 then + nLocalLog = dNumLog + end + + return dDiamReturn, nLocalLog, sLocalMess, dThick, dMaxMat +end + + +-- Funzione di sistemazione parametri +function Pivot.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat + local dMaxMat0 + local nTempT0 + local dNumLog = 0 + local sMessToOut = '' + + -- se non è definito setto tipo setto per default la forma standard a L + if not tMhPar.stype then tMhPar.stype = 1 end + + tMhPar.back = DGD.BACK_SET + tMhPar.oriback = DGD.BACK_SET + tMhPar.posiz = DGD.POSITION + tMhPar.rad = DGD.RADIUS + tMhPar.dhei = DGD.dOH or DGD.dH + tMhPar.invG = 1 + tMhPar.fht = 0 -- setto il face h top a 0 + tMhPar.fhb = 0 -- setto il face h bottom a 0 + tMhPar.mkrev = false + tMhPar.stn = false -- setto il flag di pivot tangente bordo porta + tMhPar.bETh = false -- extra thickness per i sottotipi dove il knuckle è passante sullo spessore porta + + -- setto parametro riferimento profondità pivot + tMhPar.drf = DGD.dT/6 + + if DGD.sFrame then -- se è un assemblato + tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato + end + + if DGD.DEPTH_F then + if string.lower(DGD.TYPE) ~= 'centerhung' then + if tMhPar.stype == 1 then + tMhPar.T = DGD.DEPTH_F + end + else + tMhPar.T = DGD.DEPTH_F + end + end + + -- parametro disposizione frame su lato wide (se = nil è sulla porta, se true dispsizione frame sul lato wide, se false dispsozione su lato narrow) + tMhPar.Dws = DGD.Dws + local sPieceName + + if tMhPar.Dws then + if DGD.nTypePz == 3 or DGD.nTypePz == 4 then + tMhPar.dThD = DGD.dW + elseif DGD.nTypePz == 5 or DGD.nTypePz == 6 then + tMhPar.dThD = DGD.dH + end + -- setto un valore di poco inferiore allo spessore per non fresare le ventose + tMhPar.TTP = tMhPar.dThD - DGD.Spd + if DGD.nTypePz == 3 then sPieceName = 'left Jamb' + elseif DGD.nTypePz == 4 then sPieceName = 'right Jamb' + elseif DGD.nTypePz == 5 then sPieceName = 'Frame header' + else sPieceName = 'Threshold' end + end + + -- controllo se le profondità delle geometrie non superano lo spessore frame + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.stype == 1 and tMhPar.T and abs(tMhPar.T) > tMhPar.TTP then + dNumLog = -2186 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.stype == 1 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -2186 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + + if tMhPar.tb and tMhPar.mh then + tMhPar.T2 = tMhPar.T + end + + -- se non ho il parametro radius lo setto a 0 + if not tMhPar.rad then + tMhPar.rad = 0 + end + + -- se non ho il parametro raccordo su singolo angolo lo setto a 0 + if not tMhPar.R1 then +-- tMhPar.R1 = tMhPar.rad + tMhPar.R1 = 0 + end + + -- per face con knuckle in centro assegno il valore del raggio alla variabile di raggio interno + tMhPar.R1i = tMhPar.R1 + + -- se non esiste il valore della distanza del knuckle la setto a 0 + if not tMhPar.D_SK then + tMhPar.D_SK = 0 + end + + -- prendo il valore assoluto + tMhPar.D_SK = abs(tMhPar.D_SK) + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.sf or abs(tMhPar.sf) < GEO.EPS_SMALL then + tMhPar.sf = tMhPar.T + end + + -- se non ho il parametro D_X lo setto a 0 + if not tMhPar.D_X then + tMhPar.D_X = 0 + end + + -- se non ho il parametro D_XE lo setto a 0 + if not tMhPar.D_XE then + tMhPar.D_XE = 0 + end + + -- se ho il raggio disabilito eventuale chiseling + if not tMhPar.ech or tMhPar.rad > 0 then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- Assegno parametri da dati utensili in macchina + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLG + local nLGi = 1 + local sLMM + local nLMMi = 1 + local sLGH + local nLGHi = 1 + local sLGV + local nLGVi = 1 + local sLMV + local nLMVi = 1 + local sLAV + local nLAVi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.LMM = nil + tMhPar.LGV = nil + tMhPar.LMV = nil + tMhPar.LAV = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + if string.lower(DGD.TYPE) == 'offsetintermediate' and tMhPar.mh and not tMhPar.HB then + tMhPar.d3 = nil + tMhPar.mh = false + end + else + tMhPar.est = nil + end + + if tMhPar.stype == 1 then -- se sottotipo standard + + if tMhPar.est and tMhPar.LG then + sLG = tMhPar.LG + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + end + if tMhPar.LM then + sLM = tMhPar.LM + end + if tMhPar.LA then + sLA = tMhPar.LA + end + if tMhPar.LMM then + sLMM = tMhPar.LMM + end + if tMhPar.LGH then + sLGH = tMhPar.LGH + end + else -- atri sottotipi + + -- elimino il cleancorner + tMhPar.clc = nil + tMhPar.ccr = nil + tMhPar.CLC = nil + tMhPar.CLH = nil + + if string.lower(DGD.TYPE) == 'offset' then + + if tMhPar.est and tMhPar.LG then + sLG = tMhPar.LG + end + + if tMhPar.stype == 4 then + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + end + end + if tMhPar.LM then + sLM = tMhPar.LM + end + if tMhPar.LA then + sLA = tMhPar.LA + end + if tMhPar.ech and tMhPar.LGV then -- se chisel abilitato + sLGV = tMhPar.LGV .. tMhPar.CH + tMhPar.d0 = 0 + end + if tMhPar.LMV then + sLMV = tMhPar.LMV + end + if tMhPar.LAV then + sLAV = tMhPar.LAV + end + elseif string.lower(DGD.TYPE) == 'offsetintermediate' then + + if tMhPar.est and tMhPar.LG then + sLG = tMhPar.LG + end + + if tMhPar.stype == 4 then + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + end + end + if tMhPar.LM then + sLM = tMhPar.LM + end + if tMhPar.LA then + sLA = tMhPar.LA + end + if tMhPar.LMM then + sLMM = tMhPar.LMM + end + if tMhPar.LMV then + sLMV = tMhPar.LMV + end + if tMhPar.LAV then + sLAV = tMhPar.LAV + end + if tMhPar.stype == 3 then + if tMhPar.ech and tMhPar.LGV then -- se chisel abilitato + sLGV = tMhPar.LGV .. tMhPar.CH + tMhPar.d0 = 0 + end + end + end + end + + if string.lower(DGD.TYPE) == 'centerhung' then + + -- do errore se profilo tipo bevel + if DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or + DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + return tMhPar, 2199, string.format(EgtDoorsMsg[464], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) + end + + if bShiftBackSetPos and tMhPar.H then + tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017 + elseif tMhPar.H then + tMhPar.H3 = tMhPar.back + ( tMhPar.H /2) + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + if tMhPar.rf > tMhPar.H/2 then + tMhPar.rf = tMhPar.H/2 + end + + tMhPar.type = 3 -- 1: offset type, 2: intermediate type, 3: center hung + + if tMhPar.cl and ( tMhPar.cl == 2 or tMhPar.cl == 1) then + tMhPar.D_XT = -( tMhPar.L-(tMhPar.rf))/2 -- calcolo per spostare la geometria in modo che il centro del semicerchio sia sullo 0 + elseif tMhPar.cl and tMhPar.cl == 0 then + tMhPar.D_XT = -( tMhPar.L/2) -- calcolo per spostare la geometria, bordo dx a 0 + else + tMhPar.cl = 3 + tMhPar.D_XT = -( tMhPar.L-tMhPar.H)/2 -- calcolo per spostare la geometria in modo che il centro del semicerchio sia sullo 0 + end + + -- se raggio su tutti gli angoli e raggio esistente annullo il clean corner + if tMhPar.cl == 3 and tMhPar.rf > 0 then + tMhPar.clc = 0 + end + + -- trovo se invertire il senso di lavorazione + if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if not DGD.Push then tMhPar.invG = -tMhPar.invG end + + elseif string.lower(DGD.TYPE) == 'offsetintermediate' then + + if tMhPar.T and tMhPar.T > 0 then + tMhPar.fht = tMhPar.T + end + + -- 2019.12.18 inserito controllo che permette di mettere il pivot di tipo 1 su qualsiasi tipo di profilo + -- 2019.10.07 tolto dal confronto il profilo convex ma solo se è di sottotipo 1 +-- -- do errore se profilo tipo bullnose e convesso +-- if DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or +-- DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or +-- DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or +-- DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B' or +-- DGD.tProfs.hingeedge.trimming == 'CV' then + -- do errore se profilo tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.hingeedge.trimming == 'CV' or + DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or + DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or + DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or + DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B') then + + if tMhPar.stype == 1 then + if tMhPar.stype == 1 then + return tMhPar, 2198, string.format(EgtDoorsMsg[669], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) + else + return tMhPar, 2198, string.format(EgtDoorsMsg[465], tMhPar.Nome, DGD.tProfs.hingeedge.trimming) + end + end + elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or + DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + + if tMhPar.stype > 2 then + return tMhPar, 2199, string.format(EgtDoorsMsg[658], tMhPar.Nome, DGD.TYPE, tMhPar.stype, DGD.tProfs.hingeedge.trimming) + else + + tMhPar.mkrev = true -- assegno flag per creare percorso inverso + + -- se profilo cerniere bevel up + if DGD.tProfs.hingeedge.trimming == 'BU' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + nLMi = 2 + nLAi = 2 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale + nLMMi = 2 + if tMhPar.ech then nLGi = 2 end + elseif DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BDEB' then -- se profilo cerniere bevel down + -- sLM = sLM ..'_R' -- disattivati perché si utilizza sempre la lavorazione oraria e non quella inversa + nLMi = 3 + -- sLA = sLA ..'_R' -- disattivati perché si utilizza sempre la lavorazione oraria e non quella inversa + nLAi = 3 -- l'antischeggia avrà le tre lavorazioni identiche perché l'utensile è su aggregato orizzontale + nLMMi = 3 + if tMhPar.ech then nLGi = 3 end + end + end + if tMhPar.T and tMhPar.T > 0 then + tMhPar.fht = tMhPar.T / cos(3) + end + tMhPar.bev = true + end + + tMhPar.fhb = tMhPar.fht + tMhPar.type = 2 -- 1: offset type, 2: intermediate type, 3: center hung + tMhPar.D_XT = 0 -- setto a 0 il parametro per spostare la geometria in modo che il centro del semicerchio sia sullo 0 + tMhPar.cl = 0 -- corners without fillet, not necessary on this type + + -- se manca il parametro che definisce il riferimento del pivot da posizionare + if not tMhPar.rp then + tMhPar.rp = 's' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side) + end + + local dDistToSub = 0 + + if not tMhPar.B_SK then tMhPar.B_SK = false end + + if tMhPar.B_SK then -- se knuckle sulla faccia opposta + tMhPar.D_SK2 = tMhPar.D_SK + tMhPar.D_SK = tMhPar.L - tMhPar.L3 - tMhPar.D_SK + else + if tMhPar.D_SK > 0 then + tMhPar.D_SK2 = tMhPar.L - tMhPar.L3 - tMhPar.D_SK + end + end + + if tMhPar.L3 then + if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle + if tMhPar.B_SK then -- se knuckle sulla faccia opposta + dDistToSub = tMhPar.L3/2 + tMhPar.D_SK2 + else + dDistToSub = tMhPar.L3/2 + tMhPar.D_SK + end + elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle + if tMhPar.B_SK then -- se knuckle sulla faccia opposta + dDistToSub = tMhPar.D_SK2 + else + dDistToSub = tMhPar.D_SK + end + end + end + + -- se pivot è adiacente al fianco top porta annullo il valore del raggio singolo + -- e setto il flag per modifica geometria pivot + if not tMhPar.B_SK then + if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistIntpiv then + tMhPar.R1 = 0 + tMhPar.stn = true + end + else -- se è opposto + if ( DGD.dH - (DGD.POSITION + dDistToSub + tMhPar.D_XE)) <= dMinDistIntpiv then + tMhPar.R1 = 0 + tMhPar.stn = true + end + end + + if tMhPar.stype == 1 or tMhPar.stype == 4 then + if bShiftBackSetPos and tMhPar.H then + -- se backset nullo o negativo lo ricalcolo per ottenere il centro spessore + if tMhPar.back <= 0 then + tMhPar.back = ( DGD.dT - tMhPar.H) /2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017 + elseif tMhPar.H then + if tMhPar.back <= 0 then + tMhPar.back = DGD.dT/2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + ( tMhPar.H /2) + end + end + + if tMhPar.stype == 4 then + + tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0 + -- calcolo lo spostamento in X + local dExtraDim = 0 + if tMhPar.B_SK then + tPiPar.D_X = -(tPiPar.L - tPiPar.L3 + dExtraDim) / 2 + else + tPiPar.D_X = (tPiPar.L - tPiPar.L3 + dExtraDim) / 2 + end + -- calcolo l'altezza della mortasa e lo spostamento in Y + tMhPar.D = (tMhPar.H2 - tMhPar.H)/2 + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s or abs(tMhPar.s) < GEO.EPS_SMALL then + tMhPar.s = tMhPar.T2 + end + elseif tMhPar.stype == 3 then + tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0 + tMhPar.jn = false -- forzo di non collegare il face con la mortasa + tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta + tMhPar.bETh = true -- setto spessore passante + tMhPar.stnb = tMhPar.stn + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then + tMhPar.s3 = tMhPar.T3 + end + end + + -- calcolo la posizione del centro foro sullo spessore porta + if bShiftBackSetPos then + if tMhPar.stype == 3 then -- se sottotipo 3 + tMhPar.posh = 0 -- 27/12/2017 New MDC request + elseif tMhPar.H then + if abs(tMhPar.oriback) <= 0.001 then + -- se non ruota su profilo bevel o non è bevel + if DGC.Fpd or not tMhPar.bev then + tMhPar.posh = tMhPar.back + ( tMhPar.H/2) - (DGD.dT/2) -- 27/12/2017 New MDC request + else + tMhPar.posh = ( ( tMhPar.back + ( tMhPar.H/2)) * cos( 3)) - (DGD.dT/2) -- 27/12/2017 New MDC request + end + else + -- se non ruota su profilo bevel o non è bevel + if DGC.Fpd or not tMhPar.bev then + tMhPar.posh = tMhPar.back + (( tMhPar.H - DGC.Ew) / 2) - (DGD.dT/2) -- 27/12/2017 New MDC request + else + tMhPar.posh = ( (tMhPar.back + (( tMhPar.H - DGC.Ew) / 2)) * cos( 3)) - (DGD.dT/2) -- 27/12/2017 New MDC request + end + end + end + else + if tMhPar.stype == 3 then -- se sottotipo 3 + tMhPar.posh = 0 + else + -- se non ruota su profilo bevel o non è bevel + if DGC.Fpd or not tMhPar.bev then + tMhPar.posh = tMhPar.back - (DGD.dT/2) + else + tMhPar.posh = ( tMhPar.back * cos( 3)) - (DGD.dT/2) + end + end + end + + -- trovo se invertire il senso di lavorazione + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if DGD.Push then tMhPar.invG = -tMhPar.invG end + else -- tipo offset + + tMhPar.type = 1 -- 1: offset type, 2: intermediate type, 3: center hung + tMhPar.D_XT = 0 -- setto a 0 il parametro per spostare la geometria in modo che il centro del semicerchio sia sullo 0 + tMhPar.cl = 0 -- corners without fillet, not necessary on this type + + -- se sottotipo 1:top/bottom door o 2:top/bottom-back door + if tMhPar.stype == 1 or tMhPar.stype == 2 then + + if tMhPar.T and tMhPar.T > 0 then + tMhPar.fht = tMhPar.T + end + + if ( DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or + DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB') and + tMhPar.T and tMhPar.T > 0 then + tMhPar.fht = tMhPar.T / cos(3) + end + + -- se manca il parametro che definisce il riferimento del pivot da posizionare + if not tMhPar.rp then + tMhPar.rp = 'c' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side) + end + + tMhPar.fhb = tMhPar.fht + local dDistToSub = 0 + + if tMhPar.L3 then + if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle + dDistToSub = tMhPar.L3/2 + tMhPar.D_SK + elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle + dDistToSub = tMhPar.D_SK + end + end + + -- se pivot è adiacente al fianco porta annullo il valore del raggio singolo + -- e setto il flag per modifica geometria pivot + if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then + tMhPar.R1 = 0 + tMhPar.stn = true + end + + if tMhPar.stype == 2 then + tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0 + tMhPar.jn = false -- forzo di non collegare il face con la mortasa + tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta + tMhPar.bETh = true -- setto spessore passante + tMhPar.stnb = tMhPar.stn + if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then + tMhPar.s3 = tMhPar.T3 + end + else + + if tMhPar.D_SK > 0 then + tMhPar.D_SK2 = tMhPar.L - tMhPar.L3 - tMhPar.D_SK + end + + if bShiftBackSetPos and tMhPar.H then + -- se backset nullo o negativo lo ricalcolo per ottenere il centro spessore + if tMhPar.back <= 0 then + tMhPar.back = ( DGD.dT - tMhPar.H) /2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + tMhPar.H - ( DGC.Ew / 2) -- new MDC request 22/12/2017 + elseif tMhPar.H then + if tMhPar.back <= 0 then + tMhPar.back = DGD.dT/2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + ( tMhPar.H /2) + end + end + + -- trovo se invertire il senso di lavorazione + if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if not DGD.Push then tMhPar.invG = -tMhPar.invG end + elseif tMhPar.stype == 3 then -- se sotto tipo 3 top/bottom-back door + + -- se manca il parametro che definisce il riferimento del pivot da posizionare + if not tMhPar.rp then + tMhPar.rp = 'c' -- setto il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side) + end + + local dDistToSub = 0 + + if tMhPar.L3 then + if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle + dDistToSub = tMhPar.L3/2 + tMhPar.D_SK + elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle + dDistToSub = tMhPar.D_SK + end + end + + -- se pivot è adiacente al fianco porta annullo il valore del raggio singolo + -- e setto il flag per modifica geometria pivot + if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then + tMhPar.stn = true + end + + -- controlli e settaggi aggiuntivi se larghezza corpo pivot è differente + -- Se larghezza + dDistToSub = 0 + if tMhPar.AsKn then -- se larghezza body come knuckle, verifico se c'è + -- se non c'è o lunghezza nulla prendo la misura locale + if not tMhPar.L3 or ( tMhPar.L3 and abs(tMhPar.L3) < GEO.EPS_SMALL) then + if tMhPar.H then + if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle + dDistToSub = tMhPar.H/2 + tMhPar.D_SK + elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle + dDistToSub = tMhPar.D_SK + end + end + -- se pivot è adiacente al fianco porta annullo il valore del raggio singolo + -- e setto il flag per modifica geometria pivot + if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then + tMhPar.stnb = true + end + else -- se larghezza valida + tMhPar.H = tMhPar.L3 + tMhPar.stnb = tMhPar.stn + end + else -- se larghezza diversa + if tMhPar.H then + if tMhPar.rp == 'c' then -- se riferimento in centro al knuckle + dDistToSub = tMhPar.H/2 + tMhPar.D_SK + elseif tMhPar.rp == 's' then -- se riferimento sul bordo knuckle + if tMhPar.L3 then + dDistToSub = tMhPar.D_SK+((tMhPar.H-tMhPar.L3)/2) + else + dDistToSub = tMhPar.D_SK + end + end + end + -- se pivot è adiacente al fianco porta annullo il valore del raggio singolo + -- e setto il flag per modifica geometria pivot + if ( DGD.POSITION - dDistToSub - tMhPar.D_XE) <= dMinDistOffspiv then + tMhPar.stnb = true + end + end + + tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0 + tMhPar.jn = false -- forzo di non collegare il face con la mortasa + tMhPar.H3 = DGD.dT/2 -- setto H3 come spessore porta + tMhPar.bETh = true -- setto spessore passante + if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then + tMhPar.s3 = tMhPar.T3 + end + + -- trovo se invertire il senso di lavorazione + if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if not DGD.Push then tMhPar.invG = -tMhPar.invG end + elseif tMhPar.stype == 4 then -- se sotto tipo 4 top/bottom-side door + + -- do errore se profilo tipo bevel + if DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or + DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + return tMhPar, 2199, string.format(EgtDoorsMsg[658], tMhPar.Nome, DGD.TYPE, tMhPar.stype, DGD.tProfs.hingeedge.trimming) + end + + -- forzo il tipo ad essere adiacente al bordo porta + tMhPar.stn = true + tMhPar.R1 = 0 -- forzo in ogni caso il R1 a 0 + tMhPar.rp = 's' -- forzo il valore di default ('s'=knuckle side, 'c'=knuckle center, 'f'= face side) + tMhPar.jn = false -- forzo di non collegare il face con la mortasa + if not tMhPar.T3 then tMhPar.T3 = tMhPar.T end + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s3 or abs(tMhPar.s3) < GEO.EPS_SMALL then + tMhPar.s3 = tMhPar.T3 + end + + if bShiftBackSetPos and tMhPar.H then + -- se backset è nullo o negativo ricalcolo per far stare la parte body in centro allo spessore + if tMhPar.back <= 0 then + tMhPar.back = ( DGD.dT - tMhPar.H) /2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + tMhPar.H -- new MDC request 22/12/2017 + if tMhPar.back <= dMinDistOffspiv then + tMhPar.stnb = true + end + elseif tMhPar.H then + -- se backset è nullo o negativo ricalcolo per far stare la parte body in centro allo spessore + if tMhPar.back <= 0 then + tMhPar.back = DGD.dT/2 + DGD.BACK_SET = tMhPar.back + end + tMhPar.H3 = tMhPar.back + ( tMhPar.H /2) + if tMhPar.back - ( tMhPar.H /2) <= dMinDistOffspiv then + tMhPar.stnb = true + end + end + + -- trovo se invertire il senso di lavorazione + if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + if not DGD.Push then tMhPar.invG = -tMhPar.invG end + end + end + + -- se arrotondo entrambe le estremità disabilito il chisel + if tMhPar.cl == 3 then + tMhPar.ech = false + end + + -- se raggio nullo lo azzero + if not tMhPar.rf then tMhPar.rf = 0 end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + if ( tMhPar.CLC or tMhPar.CLH) and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC and not tMhPar.CLH then + tMhPar.clc = nil + end + + -- se sono pivot standard + if ( tMhPar.type <= 2 and tMhPar.stype == 1) or tMhPar.type == 3 then + + -- geometria face + if tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLG, + nLGi, sMessToOut, tMhPar.T, 460, -2197, + false, 1, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- svuotatura face + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLM, + nLMi, sMessToOut, tMhPar.T, 460, -2197, + false, 1, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- antisplint face + if not tMhPar.est then + tMhPar.d2, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLA, + nLAi, sMessToOut, tMhPar.T, 462, -2196, + false, 1, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- svuotatura mortise concatenata + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d, (not tMhPar.jn), 1, tMhPar.d, sLM, + nLMi, sMessToOut, tMhPar.T2, 461, -2194, + true, 2, dNumLog, dMaxMat, (tMhPar.jn and not tMhPar.mh), + tMhPar.Nome, EgtDoorsMsg) + end + + -- foro (solo controllo profondità) + if not tMhPar.est or ( tMhPar.est and tMhPar.HB) then + _, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( (tMhPar.mh and tMhPar.LGH), true, 2, tMhPar.d3, sLGH, + nLGHi, sMessToOut, tMhPar.T2, 463, -2195, + true, 2, dNumLog, dMaxMat, tMhPar.mh, + tMhPar.Nome, EgtDoorsMsg) + end + + -- svuotatura mortise disgiunta + if not tMhPar.est then + tMhPar.d3, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLMM, + nLMMi, sMessToOut, tMhPar.T2, 461, -2193, + true, 2, dNumLog, dMaxMat, (not tMhPar.jn and not tMhPar.mh), + tMhPar.Nome, EgtDoorsMsg) + end + + -- chisel (solo controllo diametro utensile) + if not tMhPar.est then + tMhPar.d0, dNumLog, sMessToOut, dMaxMat0, dMaxMat = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG, + nLGi, sMessToOut, tMhPar.T, 460, -2192, + false, 3, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- se ho altro materiale modifico i raccordi se sono più piccoli del raggio utensile + if tMhPar.est then + if tMhPar.type == 3 then -- tipo centerhung + if tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + elseif tMhPar.type == 2 then -- tipo intermediate + if tMhPar.D_SK > 0 and tMhPar.D_SK2 > 0 then -- se ho knuckle centrato azzero solo i raggi interni + if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then + tMhPar.rad = 0 + end + else + if tMhPar.L3 and tMhPar.L3 > 0 then -- se a forma di L + if tMhPar.R1 and tMhPar.R1 > 0 and tMhPar.d and tMhPar.R1 < ((tMhPar.d/2)+0.02) then + tMhPar.R1 = 0 + tMhPar.R1i = 0 + end + end + if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then + tMhPar.rad = 0 + end + end + elseif tMhPar.type == 1 then -- tipo offset + if tMhPar.D_SK == 0 or tMhPar.D_SK2 == 0 then -- se a forma di L + if tMhPar.R1 and tMhPar.R1 > 0 and tMhPar.d and tMhPar.R1 < ((tMhPar.d/2)+0.02) then + tMhPar.R1 = 0 + tMhPar.R1i = 0 + end + end + if tMhPar.rad and tMhPar.rad > 0 and tMhPar.d and tMhPar.rad < ((tMhPar.d/2)+0.02) then + tMhPar.rad = 0 + end + end + end + +-- vecchio controllo +--[[ + + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local dNumMessage + + if tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end -- svuotatura face + if tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end -- antischeggia + if tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMM, nLMMi) end -- svuotatura mortise + if tMhPar.mh and tMhPar.LGH then nTempT4, dMaxMat3, sMchngName4 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end -- foro + if tMhPar.ech and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end -- chisel su face + + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and tMhPar.d and nTempT1 <= 0 then + dNumLog = -2192 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif DGD.bProoduce then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and tMhPar.d2 and nTempT2 <= 0 then + dNumLog = -2192 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif DGD.bProoduce then + tMhPar.d2 = nTempT2 + end + + if tMhPar.d3 and nTempT3 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -2192 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMM, nLMMi, tMhPar.d3, dNumLog, sMchngName3) + end + else + tMhPar.d3 = nTempT3 + end + + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat3 then + dNumLog = -2191 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLGH, nLGHi, nil, dNumLog, sMchngName4) + end + + -- chiseling +-- if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then +-- tMhPar.d0 = nTempT0 +-- end + + -- se la profondità della face è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then + dNumLog = -2197 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat1 + end + + -- se la profondità antischeggia della face è maggiore della capacità utensile limito la profondità ed emetto un warning + -- if not tMhPar.mh and tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then + if tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then + dNumLog = -2196 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat2 + end + + -- se foro abilitato e la profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then + dNumLog = -2195 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3)) + tMhPar.T2 = dMaxMat3 + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and not tMhPar.mh and + tMhPar.T2 and dMaxMat and tMhPar.T2 > dMaxMat then + dNumLog = -2194 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat)) + tMhPar.T2 = dMaxMat + end + + -- se la mortise non è concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and not tMhPar.mh and + tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then + dNumLog = -2193 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3)) + tMhPar.T2 = dMaxMat3 + end +]]-- + -- pivot offset speciale + elseif tMhPar.type == 1 then -- tipo offset + + -- check utensile svuotatura knuckle + if not tMhPar.est then + tMhPar.d3, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLM, + nLMi, sMessToOut, tMhPar.T3, 654, -2191, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- check utensile antischeggia knuckle + if not tMhPar.est then + tMhPar.d4, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d4, true, 1, tMhPar.d4, sLA, + nLAi, sMessToOut, tMhPar.T3, 656, -2190, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + if tMhPar.stype == 4 then + -- chisel (solo controllo diametro utensile) + if not tMhPar.est then + tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG, + nLGi, sMessToOut, tMhPar.T3, 460, -2187, + false, 3, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + end + + -- check utensile svuotatura body + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLMV, + nLMVi, sMessToOut, tMhPar.T, 655, -2189, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- check utensile antischeggia body + if not tMhPar.est then + tMhPar.d2, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLAV, + nLAVi, sMessToOut, tMhPar.T, 657, -2190, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- chisel (solo controllo diametro utensile) + if not tMhPar.est then + tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLGV, + nLGVi, sMessToOut, tMhPar.T, 460, -2188, + false, 3, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + -- pivot intermediate speciale + elseif tMhPar.type == 2 then -- tipo OffsetIntermediate + + if tMhPar.stype == 4 then -- geometria simile al sottotipo 1 + + -- svuotatura mortise concatenata + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d, (not tMhPar.jn), 1, tMhPar.d, sLM, + nLMi, sMessToOut, tMhPar.T2, 461, -2194, + true, 2, dNumLog, dMaxMat, tMhPar.jn, + tMhPar.Nome, EgtDoorsMsg) + end + + -- svuotatura mortise disgiunta + if not tMhPar.est then + tMhPar.d3, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLMM, + nLMMi, sMessToOut, tMhPar.T2, 461, -2193, + true, 2, dNumLog, dMaxMat, (not tMhPar.jn), + tMhPar.Nome, EgtDoorsMsg) + end + + -- check utensile antischeggia face concatenato a mortise + if not tMhPar.est then + tMhPar.d2, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d2, (not tMhPar.jn), 1, tMhPar.d2, sLA, + nLAi, sMessToOut, tMhPar.T2, 462, -2196, + true, 1, dNumLog, dMaxMat, tMhPar.jn, + tMhPar.Nome, EgtDoorsMsg) + end + + -- check utensile antischeggia face disgiunto a mortise + if not tMhPar.est then + tMhPar.d2, dNumLog, sMessToOut, tMhPar.T2, dMaxMat = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLA, + nLAi, sMessToOut, tMhPar.T2, 462, -2196, + true, 1, dNumLog, dMaxMat, (not tMhPar.jn), + tMhPar.Nome, EgtDoorsMsg) + end + + -- check utensile svuotatura face + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T, dMaxMat = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLM, + nLMi, sMessToOut, tMhPar.T, 460, -2197, + true, 1, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + + -- chisel (solo controllo diametro utensile) + if not tMhPar.est then + tMhPar.d0, dNumLog, sMessToOut, dMaxMat0, dMaxMat = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLG, + nLGi, sMessToOut, tMhPar.T, 460, -2192, + false, 3, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + else -- sottotipo 3 simile al sottotipo 2 del tipo Offset + + -- check utensile svuotatura knuckle + if not tMhPar.est then + tMhPar.d3, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d3, true, 1, tMhPar.d3, sLM, + nLMi, sMessToOut, tMhPar.T3, 654, -2191, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + -- check utensile antischeggia knuckle + if not tMhPar.est then + tMhPar.d4, dNumLog, sMessToOut, tMhPar.T3 = CheckTool( tMhPar.d4, true, 1, tMhPar.d4, sLA, + nLAi, sMessToOut, tMhPar.T3, 656, -2190, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + -- check utensile svuotatura body + if not tMhPar.est then + tMhPar.d, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d, true, 1, tMhPar.d, sLMV, + nLMVi, sMessToOut, tMhPar.T, 655, -2189, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + -- check utensile antischeggia body + if not tMhPar.est then + tMhPar.d2, dNumLog, sMessToOut, tMhPar.T = CheckTool( tMhPar.d2, true, 1, tMhPar.d2, sLAV, + nLAVi, sMessToOut, tMhPar.T, 657, -2190, + true, 1, dNumLog, nil, nil, + tMhPar.Nome, EgtDoorsMsg) + end + -- chisel (solo controllo diametro utensile) + if not tMhPar.est then + tMhPar.d0, dNumLog, sMessToOut, dMaxMat0 = CheckTool( (tMhPar.ech and tMhPar.d0), false, 1, tMhPar.d0, sLGV, + nLGVi, sMessToOut, tMhPar.T, 460, -2188, + false, 3, dNumLog, dMaxMat, nil, + tMhPar.Nome, EgtDoorsMsg) + end + end + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function Pivot.Draw( tPivotParam, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni, parametri utensili e settaggi + local L = tPivotParam.L -- lunghezza face + local H = tPivotParam.H -- larghezza face + local T = tPivotParam.T -- spessore face + local L3 = tPivotParam.L3 -- lunghezza Knuckle a forma di L + local H3 = tPivotParam.H3 -- altezza Knuckle a forma di L + local T3 = tPivotParam.T3 -- spessore Knuckle disgiunto + local radius = tPivotParam.rad -- raggio arrotondamento face a forma di L + local R1 = tPivotParam.R1 -- raggio arrotondamento face su singolo corner + local R1i = tPivotParam.R1i -- raggio interno per face con knockle centrale + local D_SK = tPivotParam.D_SK -- distanza partenza knuckle + local D_SK2 = tPivotParam.D_SK2 -- distanza rimanente da knuckle + local B_SK = tPivotParam.B_SK -- flag che indica il knuckle è opposto ( D_SK risulta già modificato) + local mkrev = tPivotParam.mkrev -- flag che indica se devono essere fatti anche percorsi inversi (cioè quando intermediate pivot è applicato su profilo bevel) + local d = tPivotParam.d -- diametro utensile face + local p = tPivotParam.p -- percentuale uso utensile face + local sf = tPivotParam.sf -- passo affondamento per face + local cl = tPivotParam.cl -- arrotondamento per face non a forma di L + local rf = tPivotParam.rf -- raggio arrotondamento per face non a forma di L + local clc = tPivotParam.clc -- lunghezza lato clean corner + local ccr = tPivotParam.ccr -- raggio su angolo cleancorner + local d2 = tPivotParam.d2 -- diametro utensile antischeggia per face + local mh = tPivotParam.mh -- abilitazione creazione mortasa/foro + local HB = tPivotParam.HB -- forzo foro a rimanere orizzontale + local stn = tPivotParam.stn -- pivot tipo offset adiacente al bordo porta + local stnb = tPivotParam.stnb -- pivot tipo offset adiacente al bordo porta + local tb = tPivotParam.tb -- abilitazione forza profondità foro come spessore face + local L2 = tPivotParam.L2 -- lunghezza mortise + local H2 = tPivotParam.H2 -- larghezza mortise + local T2 = tPivotParam.T2 -- spessore mortise + local d3 = tPivotParam.d3 -- diametro utensile per mortise o per knuckle singolo + local p3 = tPivotParam.p3 -- percentuale uso utensile per mortise + local s = tPivotParam.s -- passo affondamento per mortise + local posh = tPivotParam.posh -- posizione in Y del foro di tastatura + local posp = tPivotParam.posp -- posizione in X del foro di tastatura + local ptype = tPivotParam.type -- type of Pivot + local subtype = tPivotParam.stype -- sub type Pivot (1:top/bottom door, 2:top/bottom-back door, 3:top/bottom-back door, 4:top/bottom-side door) + local jn = tPivotParam.jn -- flag join paths, means use 'same tool' for face and mortise + local D = tPivotParam.D -- distance to edge per mortise, usato con face a forma di L + local D_X = tPivotParam.D_X -- delta on X pos on mortaise rispetto al centro face + local D_XT = tPivotParam.D_XT -- delta on X pos for all geometries + local D_XE = tPivotParam.D_XE -- Extra delta on X pos for all geometries + local invG = tPivotParam.invG -- flag per invertire il senso dei percorsi di lavorazione + local ech = tPivotParam.ech -- abilitazione chisel + local est = tPivotParam.est -- abilitazione materiale steel + local kbs = tPivotParam.kbs -- keep backset/thicknesss (0: none, 1: only face, 2: all) + local pbs = tPivotParam.pbs + local rp = tPivotParam.rp -- reference pivot + local backset = tPivotParam.back -- valore backset da ddf + local oribackset = tPivotParam.oriback + local posiz = tPivotParam.posiz -- valore posizione da ddf + local dhei = tPivotParam.dhei -- altezza porta + local fht = tPivotParam.fht + local fhb = tPivotParam.fhb + local drf = tPivotParam.drf + local dws = tPivotParam.Dws + local dthd = tPivotParam.dThD + local ttp = tPivotParam.TTP + local tExtraBore = {} + table.insert( tExtraBore, { tPivotParam.D4, tPivotParam.T4, tPivotParam.I4, tPivotParam.PX4, tPivotParam.PY4, tPivotParam.EB4, tPivotParam.HB4}) + table.insert( tExtraBore, { tPivotParam.D5, tPivotParam.IY5, tPivotParam.T5, tPivotParam.I5, tPivotParam.PX5, tPivotParam.PY5, tPivotParam.RP5, tPivotParam.EB5, tPivotParam.EBH5, tPivotParam.HB5, tPivotParam.AR5, tPivotParam.RCI5}) + table.insert( tExtraBore, { tPivotParam.D6, tPivotParam.IY6, tPivotParam.T6, tPivotParam.I6, tPivotParam.PX6, tPivotParam.PY6, tPivotParam.RP6, tPivotParam.EB6, tPivotParam.EBH6, tPivotParam.HB6, tPivotParam.AR6, tPivotParam.RCI6}) + table.insert( tExtraBore, { tPivotParam.D7, tPivotParam.IY7, tPivotParam.T7, tPivotParam.I7, tPivotParam.PX7, tPivotParam.PY7, tPivotParam.RP7, tPivotParam.EB7, tPivotParam.EBH7, tPivotParam.HB7, tPivotParam.AR7, tPivotParam.RCI7}) + + -- Assegno i nomi geometrie + local LG = tPivotParam.LG -- nome geometria face + local LM = tPivotParam.LM -- nome lavorazione face + local LA = tPivotParam.LA -- nome geometria antischeggia + local LGM = tPivotParam.LGM -- nome geometria mortise + local LMM = tPivotParam.LMM -- nome lavorazione mortise + local LGH = tPivotParam.LGH -- nome geometria foro profondo + local LH = 'Pivot_Probe' + local DM = 'DUMMY' + local CH = tPivotParam.CH -- nome suffisso lavorazione chisel + local CLH = tPivotParam.CLH -- nome geometria clean corner su lato cerniera + local CLC = tPivotParam.CLC -- nome geometria clean corner su altri lati + -- variabili per messaggi e settaggi vari + local sCompoName = tPivotParam.Nome + local nCompoNpar = tPivotParam.Npar + local sCompoPath = tPivotParam.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tPivotParam.nCod + local sCodAdj = tPivotParam.sCod + -- variabili per messaggi di errore + local sNamePar1 = tPivotParam.N1 or 'L' + local sNamePar2 = tPivotParam.N2 or 'H' + local sNamePar3 = tPivotParam.N3 or 'T' + local sNamePar4 = tPivotParam.N4 or 'd' + local sNamePar5 = tPivotParam.N5 or 'p' + local sNamePar7 = tPivotParam.N7 or 'd2' + local sNamePar8 = tPivotParam.N8 or 'L2' + local sNamePar9 = tPivotParam.N9 or 'H2' + local sNamePar10 = tPivotParam.N10 or 'T2' + local sNamePar11 = tPivotParam.N11 or 'd3' + local sNamePar12 = tPivotParam.N12 or 'p3' + local sNamePar13 = tPivotParam.N13 or 's' + local sNamePar22 = tPivotParam.N22 or 'D' + local sNamePar23 = tPivotParam.N23 or 'DX' + local sNamePar24 = tPivotParam.N24 or 'L3' + local sNamePar25 = tPivotParam.N25 or 'H3' + local sNamePar26 = tPivotParam.N26 or 'radius' + local sNamePar27 = tPivotParam.N27 or 'sf' + local sNamePar28 = tPivotParam.N28 or 'rf' + local sNamePar29 = tPivotParam.N26 or 'R1' + local sNamePar30 = tPivotParam.N27 or 'D_SK' + local sNamePar31 = tPivotParam.N28 or 's3' + local sNamePar32 = tPivotParam.N29 or 'd4' + local sNamePar33 = tPivotParam.N30 or 'T3' + local sNamePar34 = tPivotParam.N31 or 'Backset' + local sNamePar35 = tPivotParam.N35 or 'clc' + local sNamePar36 = tPivotParam.N36 or 'ccr' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2100 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeKnuckle = true + local bMakeBody = true + -- variabili dei percorsi geometrici + local nGeom1, nAS1, nAS2, nAS3, nAS4, nAS5 + local nPkToJoin1, nPkToJoin3 + local nGeom2b, nAS1b, nAS2b, nAS3b, nAS4b + local nPkToJoin2b, nPkToJoin4b + local nGeom2 + local nPkToJoin2, nPkToJoin4 + local nPkToJoin, nPkToJoin_rev + local dPosMortise = D_X + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + if subtype == 1 and ( not L or not H) then + bMakeFaceGeom = false + bMakeKnuckle = false + bMakeBody = false + clc = nil + CLC = nil + CLH = nil + elseif (not L or not H) and (not L3 or not H3) then + bMakeFaceGeom = false + bMakeKnuckle = false + bMakeBody = false + else + if (not L or not H) then -- se non è presente il body + bMakeBody = false + elseif not L3 or not H3 or L3 <= 0 or H3 <= 0 then -- se non è presente il knuckle o ha valori nulli + bMakeKnuckle = false + end + end + + if est then + bMakeMortGeom = false + bMakeKnuckle = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not T then + T = 0 + end + + if not T3 then + T3 = 0 + tPivotParam.T3 = T3 + end + + -- se tipo intermediate standard e L3 nullo setto i parametri dei raccordi + if ptype == 2 and subtype == 1 and L3 == 0 then + D_SK = 0 + tPivotParam.D_Y = D + rf = radius + tPivotParam.rf = rf + tPivotParam.cl = 3 + cl = 3 + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom and bMakeBody and cl > 0 then + if L >= H then + if rf > (H/2) then + rf = (H/2) + tPivotParam.rf = rf + end + else + if rf > (L/2) then + rf = (L/2) + tPivotParam.rf = rf + end + end + end + + if not L2 or not H2 then -- se non ci sono i parametri dimensionali disabilito la mortasa e il foro + bMakeMortGeom = false + end + + if not H2 and not T2 then -- se non ci sono i parametri dimensionali per il foro lo disabilito + bMakeMortGeom = false + mh = false + end + + if mh then -- se abilitato il foro disabilito la mortasa + bMakeMortGeom = false + end + + if ptype == 1 and subtype > 1 then -- se tipo offset e sottotipo diverso da 1 disabilito mortasa e foro + bMakeMortGeom = false + mh = false + elseif ptype == 2 and subtype == 3 then -- se tipo offsetIntermediate e sottotipo diverso da 1 disabilito mortasa e foro + bMakeMortGeom = false + mh = false + end + + if not T2 then + T2 = 0 + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + LG = LG .. CH + tPivotParam.LG = LG + -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel + if nDrawMach == 1 then + nForceMakeFace = 2 + end + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and (L-rf) < (L2+(2*abs(D_X))) then + jn = false + tPivotParam.jn = false +-- EC = 25 +-- EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-rf-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: +-- D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and subtype < 2 and H2 > H then + jn = false + tPivotParam.jn = false +-- EC = 28 +-- EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar9,EgtToUiUnits(H2), sCompoPath) -- il parametro 'T2' deve essere > del parametro 'T' +-- H2 = H + elseif bMakeBody and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeBody and nDrawMach > 0 and d2 and d2 < DgMin then + EC = 2 + EM = string.format(EgtDoorsMsg[400],sNamePar7,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not jn and d3 and d3 < DgMin then + EC = 3 + EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif bMakeBody and H <= 0 then + EC = 4 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif bMakeBody and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EC = 5 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore o uguale del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and jn and H2 < d then + if DGD.bProoduce then + EC = 6 + EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile + H2 = d + else + d = H2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not jn and H2 < d3 then + if DGD.bProoduce then + EC = 7 + EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d3), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile + H2 = d3 + else + d3 = H2 - 0.002 + end + elseif bMakeBody and L <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d + elseif bMakeBody and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EC = 9 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeBody and nDrawMach > 0 and d2 and L <= d2 then + if DGD.bProoduce then + EC = 10 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar7,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile + L = d2 + 0.002 + else + d2 = L - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and jn and L2 <= d then + if DGD.bProoduce then + EC = 11 + EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile + L2 = d + 0.002 + else + d = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not jn and L2 <= d3 then + if DGD.bProoduce then + EC = 12 + EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile + L2 = d3 + 0.002 + else + d3 = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then + EC = 13 + EM = string.format(EgtDoorsMsg[401],sNamePar13,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d + elseif bMakeBody and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 14 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeKnuckle and nDrawMach > 0 and p3 and ( p3 < PtMin or p3 > PtMax) then + EC = 15 + EM = string.format(EgtDoorsMsg[403],sNamePar12,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not jn and ( p3 < PtMin or p3 > PtMax) then + EC = 16 + EM = string.format(EgtDoorsMsg[403],sNamePar12,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeBody and T < 0 then + EC = 17 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and not dws and T2 <= T then + EC = 18 + EM = string.format(EgtDoorsMsg[407],sNamePar10,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > del parametro 'T' + T2 = T + 0.01 + elseif bMakeFaceGeom and cl > 0 and rf < 0 then + EM = string.format(EgtDoorsMsg[404],sNamePar28,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + EC = 19 + rf = H/2 + elseif bMakeBody and cl > 0 and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then + EC = 20 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + L = H+5 + elseif bMakeBody and cl > 0 and rf < (H/2) and L <= (rf*2) then + EC = 21 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar28..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2' + L = (rf*2)+5 + elseif bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and (L-rf) < L2 then + EC = 22 + EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar28,EgtToUiUnits(L2+rf), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf' + L = rf+L2+5 + elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and (L-(rf*2)) < L2 then + EC = 23 + EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar28..'*2',EgtToUiUnits(L2+(rf*2)), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf*2' + L = (rf*2)+L2+5 + elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and (L-(rf*2)) < (L2+(2*abs(D_X))) then + EC = 24 + EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-(rf*2)-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and cl == 0 and L < L2 then + EC = 26 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L' deve essere > 'L2' + L = L2+5 + elseif bMakeFaceGeom and bMakeMortGeom and cl == 0 and subtype < 2 and L < (L2+(2*abs(D_X))) then + EC = 27 + EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and ptype ~= 3 and subtype < 2 then + if not D then + EC = 29 + EM = string.format(EgtDoorsMsg[591],sNamePar22, sCompoPath) -- il parametro 'D' non è definito + D = 0 + elseif (H-H2) < 2*D then + EC = 30 + EM = string.format(EgtDoorsMsg[423],sNamePar22,EgtToUiUnits(D),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D' é troppo grande, max valore: + D = 0 + end + elseif ptype ~= 3 then + + if bMakeBody and subtype < 2 and bShiftBackSetPos and backset <= 0 then + EC = 31 + EM = string.format(EgtDoorsMsg[401],sNamePar34,EgtToUiUnits(backset), sCompoPath) -- il parametro 'Backset' deve essere > 0 + backset = d/2 + elseif bMakeBody and subtype < 2 and not bShiftBackSetPos and backset <= H/2 then + EC = 32 + EM = string.format(EgtDoorsMsg[407],sNamePar34,EgtToUiUnits(backset),'H/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'Backset' deve essere > 'H/2' + backset = H + elseif bMakeFaceGeom then + + if bMakeKnuckle and not H3 then + EC = 33 + EM = string.format(EgtDoorsMsg[591],sNamePar25, sCompoPath) -- il parametro 'H3' non è definito + H3 = H*1.5 + elseif bMakeKnuckle and not L3 then + EC = 34 + EM = string.format(EgtDoorsMsg[591],sNamePar24, sCompoPath) -- il parametro 'L3' non è definito + L3 = L/2 + elseif bMakeBody and not radius then + EC = 35 + EM = string.format(EgtDoorsMsg[592],sNamePar26) -- il parametro 'Radius' non è definito + radius = H/2 + elseif ( subtype < 2 or subtype > 3) and bMakeKnuckle and bMakeBody and H3 <= H then + EC = 36 + EM = string.format(EgtDoorsMsg[407],sNamePar25,EgtToUiUnits(H3),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H3' deve essere > 'H' + H3 = H*1.5 + elseif bMakeKnuckle and bMakeBody and subtype < 3 and L3 >= L then + EC = 37 + EM = string.format(EgtDoorsMsg[406],sNamePar24,EgtToUiUnits(L3),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L3' deve essere < 'L' + L3 = L/2 + elseif bMakeBody and subtype ~= 2 and radius > H/2 then + EC = 38 + EM = string.format(EgtDoorsMsg[406],sNamePar26,EgtToUiUnits(radius),'H/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'radius' deve essere < 'H/2' + radius = H/2 + elseif bMakeBody and subtype == 2 and radius >= H then + EC = 39 + EM = string.format(EgtDoorsMsg[406],sNamePar26,EgtToUiUnits(radius),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'radius' deve essere < 'H/2' + radius = H + elseif bMakeKnuckle and bMakeBody and subtype < 3 and L-L3 < radius then + EC = 40 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'L3+Radius',EgtToUiUnits(L3+radius), sCompoPath) -- il parametro 'L' deve essere > 'L3+R' + L = L3+radius + elseif bMakeBody and R1 >= L-radius then + EC = 41 + EM = string.format(EgtDoorsMsg[456],sNamePar29,EgtToUiUnits(R1),'L-Radius',EgtToUiUnits(L-radius), sCompoPath) -- il parametro 'R1' deve essere <= 'L-radius' + R1 = L-radius-1.5 + elseif subtype < 2 and R1 >= H3 then + EC = 42 + EM = string.format(EgtDoorsMsg[406],sNamePar29,EgtToUiUnits(R1),'H3',EgtToUiUnits(H3), sCompoPath) -- il parametro 'R1' deve essere < 'H3' + R1 = H3-1.5 + elseif bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK ~= 0 and not B_SK and D_SK2 ~= 0 and + ( (R1i + radius) - (L-D_SK-L3)) > GEO.EPS_SMALL then + EC = 43 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'D_SK+L3+Radius+R1',EgtToUiUnits(D_SK+L3+radius+R1i), sCompoPath) -- il parametro 'L' deve essere > 'D_SK+L3+Radius+R1' + L = D_SK+L3+radius+R1+0.1 + elseif bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK > 0 and (R1i + radius) > D_SK then + EC = 44 + EM = string.format(EgtDoorsMsg[407],sNamePar30,EgtToUiUnits(D_SK),'Radius+R1',EgtToUiUnits(radius+R1i), sCompoPath) -- il parametro 'D_SK' deve essere > 'Radius+R1' + D_SK = radius+R1+0.1 + elseif bMakeKnuckle and bMakeBody and ( subtype == 1 or (ptype == 2 and subtype == 4)) and D_SK > 0 and R1i > (H3-H) then + EC = 45 + EM = string.format(EgtDoorsMsg[406],sNamePar29,EgtToUiUnits(R1i),'H3-H (Backset)',EgtToUiUnits(H3-H), sCompoPath) -- il parametro 'R1' deve essere < 'H3-H' + R1i = 0 + R1 = 0 + elseif bMakeKnuckle and nDrawMach > 0 and subtype == 4 and L3 and d3 and L3 < (d3/2) then + EC = 46 + EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),'d3/2',EgtToUiUnits(d3/2), sCompoPath) -- il parametro 'L3' deve essere > 'd3/2' + L3 = d3/2+0.1 + elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and L3 and d3 and L3 <= d3 then + EC = 47 + EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),sNamePar11,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L3' deve essere > 'd3' + L3 = d3+0.1 + elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and not( stn or stnb) and L3 and d and L3 <= d then + EC = 48 + EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L3' deve essere > 'd' + L3 = d+0.1 + elseif bMakeKnuckle and nDrawMach > 0 and subtype < 4 and not( stn or stnb) and L3 and d2 and L3 <= ( d2 + 0.2 + ((d2/8)/tan(30))) then + EC = 49 + EM = string.format(EgtDoorsMsg[407],sNamePar24,EgtToUiUnits(L3),'min large',EgtToUiUnits( d2 + 0.2 + ((d2/8)/tan(30))), sCompoPath) -- il parametro 'L3' deve essere > della componente minima + L3 = ( d2 + 0.2 + ((d2/8)/tan(30))) + 0.1 + end + end + elseif bMakeBody and nDrawMach > 0 and sf and sf <= 0 then + EC = 50 + EM = string.format(EgtDoorsMsg[401],sNamePar27,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = T + elseif bMakeKnuckle and T3 and T3 < 0 then + EC = 51 + EM = string.format(EgtDoorsMsg[404],sNamePar33,EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere >= 0 + T3 = 0 + elseif bMakeKnuckle and nDrawMach > 0 and s3 and s3 <= 0 then + EC = 52 + EM = string.format(EgtDoorsMsg[401],sNamePar31,EgtToUiUnits(s3), sCompoPath) -- il parametro 's3' deve essere > 0 + s3 = T3 + elseif bMakeKnuckle and nDrawMach > 0 and d4 and d4 < DgMin then + EC = 53 + EM = string.format(EgtDoorsMsg[400],sNamePar32,EgtToUiUnits(d4),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d4 = DgMin + elseif bMakeFaceGeom and ( CLH or CLC) and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 54 + EM = string.format(EgtDoorsMsg[407],sNamePar35,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + end + + if not bPreview and EC ~= 0 then + return (ErrorBase+EC), EM + end + + -- Se Preview cancello tutto + if bPreview then + EgtNewFile() + EgtSetDefaultMaterial( BLACK()) + end + + -- Pezzo e Layer + local Pz + + if bPreview then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + else + if not RC then + Pz = EgtGetCurrPart() -- pezzo corrente + end + if not Pz then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + end + end + + local Lg, Dm + local sRequireCompoName + local hint_2 + local nSubType = tPivotParam.stype + local dAsDiam = tPivotParam.d2 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + if ptype ~= 3 then -- se non è center hung + if subtype == 1 then -- se sottotipo 1 dei tipi rimanenti + if ptype == 2 and L3 == 0 then -- se intermediate con knuckle nullo lancio il componente usato per center hung + sRequireCompoName = '_Latch' + else + sRequireCompoName = '_PivotL' + end + else + if ptype == 2 then -- se tipo intermediate + if subtype == 4 then + tPivotParam.stype = 1 + tPivotParam.d2 = nil + sRequireCompoName = '_PivotL' + else + sRequireCompoName = '_OPivot' + end + tPivotParam.nextSub = subtype + else -- altrimenti tipo offset + sRequireCompoName = '_OPivot' + end + end + else -- altrimenti è center hung, lancio componete tipo concealed hinge + sRequireCompoName = '_Latch' + end + + if bMakeFaceGeom then + if mh then + tPivotParam.jn = false + end + tPivotParam.D_X = dPosMortise + D_SK + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1, nAS1, nAS2, nPkToJoin3, nAS3, nAS4, + nGeom2b, nPkToJoin2b, nAS1b, nAS2b, nPkToJoin4b, nAS3b, nAS4b = MHgen.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + tPivotParam.stype = nSubType + tPivotParam.d2 = dAsDiam + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + local CLC1 + if sRequireCompoName == '_Latch' then -- se center hung o intermediate chiuso + if ptype == 3 then -- se è center hung + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un raccordo + if CLC and clc and clc > 0 and clc < H and clc < L then + CLC1 = MakeClcPath(clc, ccr, CLC, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + if cl == 1 then -- cava arrotondata a sinistra + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC1, Point3d((L/2)-(rf/2),(H/2),0) - ORIG()) + -- angolo x+y- + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC2, Point3d((L/2)-(rf/2),-(H/2),0) - ORIG()) +--[[ + if rf <= 0 then + -- angolo x-y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC3, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG()) -- mi porto in posizione originaria + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d(-(L/2)-(rf/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC4, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG()) -- mi porto in posizione originaria + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2)-(rf/2),(H/2),0) - ORIG()) + end +]]-- + elseif cl == 2 then -- cava arrotondata a destra + -- angolo x-y- + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L/2)+(rf/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC2, Point3d(-(L/2)+(rf/2),(H/2),0) - ORIG()) +--[[ + if rf <= 0 then + -- angolo x+y+ + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC3, Point3d((L/2)-(rf/2),(H/2),0) - ORIG()) -- mi porto in posizione originaria + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2)+(rf/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtMove( CLC4, Point3d((L/2)-(rf/2),(H/2),0) - ORIG()) -- mi porto in posizione originaria + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d((L/2)+(rf/2),-(H/2),0) - ORIG()) + end +]]-- + else + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + else -- altrimenti è intermediate chiuso + if radius <= 0 then -- se non c'è un raccordo + if CLH and clc and clc > 0 and clc < H and clc < L then + CLC1 = MakeClcPath(clc, ccr, CLH, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side + EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + elseif sRequireCompoName == '_PivotL' then -- se offset o intermediate + if ( CLC or CLH) and clc and clc > 0 and clc < H and clc < L then + local sLblGeom + if ptype == 1 then -- se è offset + sLblGeom = CLC + else -- altrimenti è intermediate + sLblGeom = CLH + end + if sLblGeom then + if radius <= 0 then -- se non c'è un raccordo da ddf + CLC1 = MakeClcPath(clc, ccr, sLblGeom, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side + EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + if D_SK > 0 and D_SK2 > 0 then -- se ho knuckle centrato + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L3/2)+D_SK,(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L3/2)+D_SK,-(H/2),0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L-(L3/2)-D_SK),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L-(L3/2)-D_SK),(H/2),0) - ORIG()) + elseif D_SK > 0 then -- se knuckle opposto + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L-(L3/2)),(H/2),0) - ORIG()) + -- angolo x+y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC1, Point3d((L-(L3/2)),-(H/2),0) - ORIG()) + elseif D_SK == 0 then -- se forma L classica + local CLC4 = EgtCopyGlob( CLC1, Lg) + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L-(L3/2)),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC4, Point3d(-(L-(L3/2)),(H/2),0) - ORIG()) + end + end + end + if R1 <= 0 and ( D_SK == 0 or D_SK2 == 0) then -- se non c'è raccordo angolo singolo + CLC1 = MakeClcPath(clc, ccr, sLblGeom, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'w' -- se pivot a L setto 'w' per mantenere il backset su wide side + EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + if D_SK == 0 then -- se forma L classica + -- angolo x+y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC1, Point3d((L3/2),-(H/2),0) - ORIG()) + else -- se L opposta + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L3/2),-(H/2),0) - ORIG()) + end + end + end + end + end + end + end + else + -- disattivo il join dei percorsi + jn = false + tPivotParam.jn = false + end + + if bMakeMortGeom then + tPivotParam.D_X = dPosMortise + -- lancio il secondo componente base + if ptype == 2 and subtype == 4 then -- se tipo intermediate sottotipo 4 + sRequireCompoName = '_PivotL' + tPivotParam.nextSub = 1 + else + tLocalTb = tPivotParam + sRequireCompoName = '_Mortise' + end + MHgen = require( sRequireCompoName) + nGeom2, nPkToJoin2, nPkToJoin4 = MHgen.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + if ptype == 2 and subtype == 4 then -- se tipo intermediate sottotipo 4 + nAS5 = nPkToJoin4 + nPkToJoin4 = nil + end + elseif mh and LGH then -- se devo fare il foro + + -- disattivo il join dei percorsi + jn = false + tPivotParam.jn = false + local dExtraDepth = 0 + + nGeom2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + -- se foro deve rimanere orizzontale ed è applicato su fianco bevel, calcolo la profondità aggiuntiva + if HB and mkrev then + if bMakeFaceGeom then -- se esiste face + if not DGC.Bwd or DGC.Bwd <= 1 then -- se backset non parto dalla dimensione wide + dExtraDepth = H/2 * TAN3 + end + end + end + EgtModifyCurveThickness( nGeom2, -(T2+dExtraDepth)) + EgtSetName( nGeom2, LGH) + -- se mantiene backset anche su mortise + if kbs and kbs > 1 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wide side + sKeepMode = 'w' + end + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + if HB then + EgtSetInfo( nGeom2,'SideDoor','LockLH') + end + end + + -- se ci sono i percorsi antischeggia + if EC == 0 and ( nAS1 or nAS2 or nAS3 or nAS4 or nAS5) then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wide side + sKeepMode = 'w' + end + if nAS1 then + EgtSetInfo( nAS1, 'KeepBackSet', sKeepMode) + end + if nAS2 then + EgtSetInfo( nAS2, 'KeepBackSet', sKeepMode) + end + if nAS3 then + EgtSetInfo( nAS3, 'KeepBackSet', sKeepMode) + end + if nAS4 then + EgtSetInfo( nAS4, 'KeepBackSet', sKeepMode) + end + if nAS5 then + EgtSetInfo( nAS5, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nAS1 then + EgtSetInfo( nAS1, 'ProbeSide', '1') + end + if nAS2 then + EgtSetInfo( nAS2, 'ProbeSide', '1') + end + if nAS3 then + EgtSetInfo( nAS3, 'ProbeSide', '1') + end + if nAS4 then + EgtSetInfo( nAS4, 'ProbeSide', '1') + end + if nAS5 then + EgtSetInfo( nAS5, 'ProbeSide', '1') + end + end + end + + -- se ci sono i percorsi della mortasa li sposto nella posizione predefinita + if EC == 0 and ( nGeom2 or nPkToJoin2 or nPkToJoin4) then + if ptype ~= 3 then -- se pivot a L muovo i percorsi della mortasa in X e Y + if not( ptype == 2 and subtype == 4) then + if nGeom2 then + if L3 == 0 then + EgtMove( nGeom2, Point3d(D_X,D,0) - ORIG()) + else + EgtMove( nGeom2, Point3d((-(((L or 0)-(L3 or 0))/2)+D_SK+D_X),D,0) - ORIG()) + end + end + if nPkToJoin2 then + if L3 == 0 then + EgtMove( nPkToJoin2, Point3d(D_X,D,0) - ORIG()) + else + EgtMove( nPkToJoin2, Point3d((-((L-L3)/2)+D_SK+D_X),D,0) - ORIG()) + end + end + if nPkToJoin4 then + if L3 == 0 then + EgtMove( nPkToJoin4, Point3d(D_X,D,0) - ORIG()) + else + EgtMove( nPkToJoin4, Point3d((-((L-L3)/2)+D_SK+D_X),D,0) - ORIG()) + end + end + end + else -- altrimenti se pivot centerhung sposto i percorsi mortasa solo sulla X + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,0,0) - ORIG()) + end + if nPkToJoin4 then + EgtMove( nPkToJoin4, Point3d(D_X,0,0) - ORIG()) + end + end + end + + -- se entrambe i percorsi presenti e da lavorare con lo stesso utensile, li concateno + if jn and EC == 0 and nPkToJoin1 and nPkToJoin2 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkToJoin1, 'MVar') + nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + if nPkToJoin then + EgtSetName( nPkToJoin, LM) + EgtSetInfo( nPkToJoin, 'NotCheckDir', '1') + if sVarNote then EgtSetInfo( nPkToJoin, 'MVar', sVarNote) end + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + EgtSetInfo( nPkToJoin, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 55 + EM = string.format( EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 then -- altrimenti se non devo concatenare + -- se mantiene backset su face + if kbs and kbs == 1 and nPkToJoin1 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + -- se mantiene backset su face e mortise + elseif kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + end + + -- se entrambe i percorsi inversi presenti e da lavorare con lo stesso utensile, li concateno + if jn and EC == 0 and nPkToJoin3 and nPkToJoin4 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkToJoin3, 'MVar') + nPkToJoin_rev = EgtCurveCompo( Lg, {nPkToJoin3,nPkToJoin4}, true) + if nPkToJoin_rev then + EgtSetName( nPkToJoin_rev, (LM..'_R')) + EgtSetInfo( nPkToJoin_rev, 'NotCheckDir', '1') + if sVarNote then EgtSetInfo( nPkToJoin_rev, 'MVar', sVarNote) end + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + EgtSetInfo( nPkToJoin_rev, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin_rev, 'ProbeSide', '1') + end + else + EC = ErrorBase + 56 + EM = string.format( EgtDoorsMsg[425], sCompoPath) + end + elseif not jn and EC == 0 then -- altrimenti se non devo concatenare + -- se mantiene backset su face + if kbs and kbs == 1 and nPkToJoin3 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + EgtSetInfo( nPkToJoin3, 'KeepBackSet', sKeepMode) + -- se mantiene backset su face e mortise + elseif kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + if nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'KeepBackSet', sKeepMode) + end + if nPkToJoin4 then + EgtSetInfo( nPkToJoin4, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and nPkToJoin3 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin3 then + EgtSetInfo( nPkToJoin3, 'ProbeSide', '1') + end + if nPkToJoin4 then + EgtSetInfo( nPkToJoin4, 'ProbeSide', '1') + end + end + end + + if EC == 0 and ( nPkToJoin2b or nPkToJoin4b) then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + if nPkToJoin2b then + EgtSetInfo( nPkToJoin2b, 'KeepBackSet', sKeepMode) + end + if nPkToJoin4b then + EgtSetInfo( nPkToJoin4b, 'KeepBackSet', sKeepMode) + end + EgtSetInfo( nGeom2b, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin2b then + EgtSetInfo( nPkToJoin2b, 'ProbeSide', '1') + end + if nPkToJoin4b then + EgtSetInfo( nPkToJoin4b, 'ProbeSide', '1') + end + EgtSetInfo( nGeom2b, 'ProbeSide', '1') + end + end + + -- se ci sono i percorsi antischegia geometria body + if EC == 0 and ( nAS1b or nAS2b or nAS3b or nAS4b) then + -- se mantiene backset anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ptype ~= 3 then -- se pivot a L setto 'w' per mantenere il backset su wideside + sKeepMode = 'w' + end + if nAS1b then + EgtSetInfo( nAS1b, 'KeepBackSet', sKeepMode) + end + if nAS2b then + EgtSetInfo( nAS2b, 'KeepBackSet', sKeepMode) + end + if nAS3b then + EgtSetInfo( nAS3b, 'KeepBackSet', sKeepMode) + end + if nAS4b then + EgtSetInfo( nAS4b, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nAS1b then + EgtSetInfo( nAS1b, 'ProbeSide', '1') + end + if nAS2b then + EgtSetInfo( nAS2b, 'ProbeSide', '1') + end + if nAS3b then + EgtSetInfo( nAS3b, 'ProbeSide', '1') + end + if nAS4b then + EgtSetInfo( nAS4b, 'ProbeSide', '1') + end + end + end + + -- aggiungo fori extra + if EC == 0 and nDrawMach >= 0 and subtype == 1 then + + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + local AR10 + local RCI10 + + if k == 1 then + D10 = tExtraBore[k][1] + T10 = tExtraBore[k][2] + I10 = tExtraBore[k][3] + PX10 = tExtraBore[k][4] + PY10 = tExtraBore[k][5] + EB10 = tExtraBore[k][6] + HB10 = tExtraBore[k][7] + else + D10 = tExtraBore[k][1] + IY10 = tExtraBore[k][2] + T10 = tExtraBore[k][3] + I10 = tExtraBore[k][4] + PX10 = tExtraBore[k][5] + PY10 = tExtraBore[k][6] + RP10 = tExtraBore[k][7] + EB10 = tExtraBore[k][8] + EBH10 = tExtraBore[k][9] + HB10 = tExtraBore[k][10] + AR10 = tExtraBore[k][11] + RCI10 = tExtraBore[k][12] + end + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + if D10 and T10 and ( EB10 or EBH10) then + if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then + + if not IY10 then IY10 = 0 end + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + if not AR10 then AR10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 + if ptype ~= 3 then + if L3 and L3 > 0 then + dPosX10 = -((L-L3)/2) + D_SK - PX10 + else + dPosX10 = -PX10 + end + else + dPosX10 = -PX10 + end + + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, HB10, ptype, dws, pbs) + + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, EBH10, EB10, dPosX10, -dInt10, D10, 0, -PY10, T10, RP10, AR10, RCI10, kbs, HB10, ptype, dws, pbs) + end + end + end + end + end + + -- aggiungo foro probe + if EC == 0 and nDrawMach > 0 and posh then + + local dPosProbe = ((L3-L)/2)+D_SK + if L3 == 0 then + dPosProbe = 0 + end + + if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3 + dPosProbe = 0 + end + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + local dHalfLen = 0 + + if posp and posp > 0 then + if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3 + dHalfLen = (L3/2) + else + dHalfLen = (L/2) + end + dPosProbe = dPosProbe + dHalfLen + posp + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + + -- foro positivo + local pCentr = Point3d( dPosProbe,posh,0) + local hintPr + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo + if DGC.Fpd then + sSideDoorInfo = 'LockLH' + else + sSideDoorInfo = EgtIf( dl, 'LockLH', 'SideLH') + end + + if not B_SK then -- se knuckle non è opposto + if rp == 'c' then + dHalfLen = 0 + elseif rp == 'f' then + dHalfLen = (L3/2)+D_SK + else -- se tipo 's' + dHalfLen = (L3/2) + end + if (posiz - (dPosProbe-dHalfLen+1)) > 0 then -- se il foro ci sta + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + else -- se non sta lo metto assieme al negativo + if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3 + pCentr = Point3d( -dPosProbe,posh,0) + else + pCentr = Point3d( ((L3/2)+D_SK-L-( posp or 0)),posh,0) + end + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + end + else -- altrimenti è opposto e posso metterlo + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + + -- foro negativo + local dCompare = ((L3-L)/2)+D_SK + if L3 == 0 then + dCompare = 0 + end + dHalfLen = 0 + if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3 + dCompare = 0 -- D_SK + end + + if dPosProbe ~= dCompare then + + if ptype == 2 and subtype == 3 then -- se tipo intermediate e sottotipo 3 + dHalfLen = (L3/2) + else + dHalfLen = (L/2) + end + + pCentr = Point3d((dCompare-dHalfLen-( posp or 0)) ,posh,0) + + if B_SK then -- se knuckle è opposto + if rp == 's' then + dHalfLen = 0 + end + if ( posiz - (dCompare-dHalfLen-( posp or 0)-1)) < dhei then -- se il foro ci sta + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + else -- altrimenti non ci sta e lo metto assieme al positivo + pCentr = Point3d(((L3/2)+( posp or 0)) ,posh,0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + end + else + if rp == 'f' then + dHalfLen = dHalfLen + L3/2 + D_SK + elseif rp == 's' then + dHalfLen = dHalfLen + L3/2 + end + if ptype == 2 and subtype == 1 then + if ( posiz - (dCompare-dHalfLen-( posp or 0)-1)) < dhei then -- se il foro ci sta + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + else -- altrimenti non ci sta e lo metto assieme al positivo + pCentr = Point3d(((L3/2)+D_SK+( posp or 0)),posh,0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + end + else + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + end + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + + if EC == 0 and nDrawMach > 0 and subtype == 1 then -- se abilitata geometria lavorazione + + if not dws then -- se viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto) + + -- se la sezione strike supera 1/6 dello spessore porta (se è un frame drf vale 0.1 e crea sempre regione) + -- disegno sezione ribasso su faccia superiore/inferiore porta + if fhb > drf then + -- 1: offset type, 2: intermediate type, 3: center hung + if ptype ~= 2 then + -- setto griglia dietro per l'ingombro sicuramente esistente + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + local nIdSideBoxUp + if L3 > 0 then + nIdSideBoxUp = EgtRectangle2P( Lg, Point3d( (L3/2),0,H3-(H/2)), Point3d(-(L3/2),-fhb,H3-(H/2)), GDB_RT.GRID) + end + if nIdSideBoxUp then + EgtModifyCurveThickness(nIdSideBoxUp, -H3) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + else + -- setto griglia dietro per l'ingombro sicuramente esistente + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + local nIdSideBoxUp + if L3 > 0 then + nIdSideBoxUp = EgtRectangle2P( Lg, Point3d(-(L3/2)+(H/2),0,0), Point3d((L3/2)+(H/2),fhb,0), GDB_RT.LOC) + end + if nIdSideBoxUp then + EgtModifyCurveThickness(nIdSideBoxUp, -H3) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + end + else -- altrimenti viene lavorato disposto sul lato wide + + local nIdSideBoxUp + + if nGeom1 then + nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + + if nGeom2 then + nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + if EC == 0 and D_XT and D_XT ~= 0 then + EgtMove( Lg, Point3d(D_XT,0,0) - ORIG()) + end + + if EC == 0 and D_XE and D_XE ~= 0 then + EgtMove( Lg, Point3d(D_XE,0,0) - ORIG()) + end + + -- 27/12/2017 New MDC request + if EC == 0 and ptype ~= 3 then -- se tipo a L sposto in Y per avere il backset corretto + local dHeighVal = 0 + local dLongVal = 0 + if bShiftBackSetPos then + if ptype == 1 then -- se tipo offset + if subtype == 1 then -- se sottotipo 1 + if bMakeBody then + if abs(oribackset) <= 0.001 and H then + dHeighVal = H/2 + elseif H then + dHeighVal = (H - DGC.Ew)/2 + end + end + elseif subtype > 1 and subtype < 4 then -- se sottotipi 2 e 3 + dHeighVal = (DGD.dT/2) - backset + else -- se quarto tipo + if bMakeKnuckle then + if H then + dHeighVal = (H/2) + end + else + dHeighVal = (DGD.dT/2) - backset + end + dLongVal = posiz + end + EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG()) + else -- se tipo offset intermediate + if subtype == 1 or subtype == 4 then -- se sottotipo 1 o 4 + if abs(oribackset) <= 0.001 and H then + dHeighVal = H/2 + elseif H then + dHeighVal = (H - DGC.Ew)/2 + end + else -- sottotipo 3 + dHeighVal = (DGD.dT/2) - backset + end + EgtMove( Lg, Point3d(0,-dHeighVal,0) - ORIG()) + end + else -- se backset applicato in centro a body + if ptype == 1 then -- se tipo offset + if subtype > 1 and subtype < 4 then -- se sottotipi 2 e 3 + dHeighVal = (DGD.dT/2) - backset + elseif subtype == 4 then -- se sottotipo 4 + if bMakeKnuckle then + dHeighVal = 0 + else + dHeighVal = (DGD.dT/2) - backset + end + dLongVal = posiz + end + EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG()) + else -- se tipo offset intermediate + if subtype == 3 then -- se sottotipo 3 + dHeighVal = (DGD.dT/2) - backset + end + EgtMove( Lg, Point3d(dLongVal,-dHeighVal,0) - ORIG()) + end + end + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'Pivot') + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'L3' ,L3) + EgtSetInfo(Lg,'H3' ,H3) + EgtSetInfo(Lg,'T3' ,T3) + EgtSetInfo(Lg,'radius' ,radius) + EgtSetInfo(Lg,'R1' ,R1) + EgtSetInfo(Lg,'D_SK' ,D_SK) + EgtSetInfo(Lg,'D_SK2' ,D_SK2) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'sf' ,sf) + EgtSetInfo(Lg,'sf3' ,sf3) + EgtSetInfo(Lg,'cl' ,cl) + EgtSetInfo(Lg,'rf' ,rf) + EgtSetInfo(Lg,'clc' ,clc) + EgtSetInfo(Lg,'ccr' ,ccr) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'mh' ,mh) + EgtSetInfo(Lg,'HB' ,HB) + EgtSetInfo(Lg,'mkrev' ,mkrev) + EgtSetInfo(Lg,'stn' ,stn) + EgtSetInfo(Lg,'stnb' ,stnb) + EgtSetInfo(Lg,'tb' ,tb) + EgtSetInfo(Lg,'L2' ,L2) + EgtSetInfo(Lg,'H2' ,H2) + EgtSetInfo(Lg,'T2' ,T2) + EgtSetInfo(Lg,'d3' ,d3) + EgtSetInfo(Lg,'p3' ,p3) + EgtSetInfo(Lg,'s' ,s) + EgtSetInfo(Lg,'invG' ,invG) + EgtSetInfo(Lg,'ech' ,ech) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'ptype' ,ptype) + EgtSetInfo(Lg,'subtype' ,subtype) + EgtSetInfo(Lg,'B_SK' ,B_SK) + EgtSetInfo(Lg,'posh' ,posh) + EgtSetInfo(Lg,'posp' ,posp) + EgtSetInfo(Lg,'rp' ,rp) + EgtSetInfo(Lg,'drf' ,drf) + EgtSetInfo(Lg,'dws' ,dws) + EgtSetInfo(Lg,'dthd' ,dthd) + EgtSetInfo(Lg,'ttp' ,ttp) + EgtSetInfo(Lg,'D_XE' ,D_XE) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LG3' ,LG3) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LM3' ,LM3) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LA3' ,LA3) + EgtSetInfo(Lg,'CLC' ,CLC) + EgtSetInfo(Lg,'CLH' ,CLH) + EgtSetInfo(Lg,'LGM' ,LGM) + EgtSetInfo(Lg,'LMM' ,LMM) + EgtSetInfo(Lg,'LGH' ,LGH) + EgtSetInfo(Lg,'LH' ,LH) + EgtSetInfo(Lg,'CH' ,CH) + EgtSetInfo(Lg,'backset' ,backset) + EgtSetInfo(Lg,'oribackset' ,oribackset) + EgtSetInfo(Lg,'Path' ,sCompoPath) + + if ptype ~= 3 then -- se pivot a L + + local dValueDelta = 0 + + if rp == 'f' then -- se riferito a face side + if L3 == 0 and L then + dValueDelta = (L/2) + elseif L3 then + dValueDelta = (L3/2)+D_SK + end + elseif rp == 'c' then -- se riferito a center knuckle + dValueDelta = 0 + else -- se riferito a knuckle top side + if B_SK then + if L3 == 0 and L then + dValueDelta = -(L/2) + elseif L3 then + dValueDelta = -(L3/2) + end + else + if L3 == 0 and L then + dValueDelta = (L/2) + elseif L3 then + dValueDelta = (L3/2) + end + end + end + EgtSetInfo( Lg, 'DeltaPos' , dValueDelta) + EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare da quale lato far partire il punto di riferimento + EgtSetInfo( Lg, 'InserPoint', 'Edge') -- setto una nota per indicare quale punto di riferimento prendere + else + EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare da quale lato far partire il punto di riferimento + EgtSetInfo( Lg, 'InserPoint', 'Center') -- setto una nota per indicare quale punto di riferimento prendere + end + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + + +return Pivot diff --git a/LuaLibs/Rabbet.lua b/LuaLibs/Rabbet.lua new file mode 100644 index 0000000..2c496ac --- /dev/null +++ b/LuaLibs/Rabbet.lua @@ -0,0 +1,1376 @@ +-- +-- EEEEEEEEEE GGGGGG wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwww wwww +-- EEEE GGGG GGGG wwww wwww wwww +-- EEEE GGGG wwww wwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEE GGGG GGGG wwww wwwwwwww wwww +-- EEEE GGGG GGGG wwww wwww wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww +-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww +-- +-- Rabbet.lua by EgalWare s.r.l. 2017.01.31 +-- Autore: Filippo Monchi +-- Rabbet dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e con nomi attributi + +-- 2016.09.21 V1.0a0 FM Add warning messages +-- 2018.04.09 V1.0a2 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.0a3 FM Add parameter to show into message 402 +-- 2019.05.14 V1.0a4 FM Add second anti-splint path on head door side +-- 2019.10.17 V1.0a5 FM Manage steel option (disable generation of some geometries) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.04.29 V2.001 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.02.10 V3.001 FM Manage apply rabbet on opposite face +-- 2021.05.25 V3.002 FM Fix error when some parameters (p3, d3) are at nil +-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.004 FM Modification to use compiled code +-- 2023.09.14 V3.005 FM By MDC requests change the machining path direction from alternate direction to same direction +-- so after one passage it come up (out of door) and come back to start point to start new passage in the same direction +-- 2023.11.22 V3.005 FM by new parameter 'Ver' (from configuration file) manage old way (=0) or new mode as MDC required (>0) +-- 2024.01.22 V3.006 FM Manage to have only draw geometry ( not machined). This must be according to template.ini file + +-- Tavola per definizione modulo (serve ma non usata) +local Rabbet = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DgMin = 4. -- valore minimo diametro utensile +local PtMin = 0.1 +local PtMax = 1.0 +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + + if idTable then + table.insert( idTable, nLine) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumLine = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function Rabbet.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dMaxMat4 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + + if not tMhPar.Ver then tMhPar.Ver = 0 end + + -- do errore se profilo con rabbet è tipo bullnose e/o convesso + if DGD.SIDE == 'hinge' and + ( DGD.tProfs.hingeedge.trimming == '1B' or DGD.tProfs.hingeedge.trimming == '2B' or + DGD.tProfs.hingeedge.trimming == '3B' or DGD.tProfs.hingeedge.trimming == '4B' or + DGD.tProfs.hingeedge.trimming == '5B' or DGD.tProfs.hingeedge.trimming == '6B' or + DGD.tProfs.hingeedge.trimming == '7B' or DGD.tProfs.hingeedge.trimming == '8B' or + DGD.tProfs.hingeedge.trimming == 'CV') then + return tMhPar, 2599, string.format(EgtDoorsMsg[546], DGD.tProfs.hingeedge.trimming) + end + if DGD.SIDE == 'lock' and + ( DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B' or + DGD.tProfs.lockedge.trimming == 'CV') then + return tMhPar, 2598, string.format(EgtDoorsMsg[547], DGD.tProfs.lockedge.trimming) + end + + -- Assegno parametri da ddf + if DGD.SIDE == 'hinge' or DGD.SIDE == 'lock' then + if DGD.sFrame then + if DGD.sFrame == 'L' or DGD.sFrame == 'LE' or DGD.sFrame == 'H' or DGD.sFrame == 'HE' then -- se frame laterali + tMhPar.L = DGD.dH + else + tMhPar.L = DGD.dW + end + else + tMhPar.L = DGD.LENGTH + end + tMhPar.lw = 0 + elseif DGD.SIDE == 'top' or DGD.SIDE == 'bottom' then + if DGD.sFrame then + tMhPar.L = DGD.dT + else + tMhPar.L = DGD.LENGTH + end + tMhPar.lw = 1 + else + return tMhPar, 2597, string.format(EgtDoorsMsg[548], DGD.SIDE) + end + + -- assegno il valore dell'angolo in base al tipo di frame e allo swing + if DGD.sFrame and DGD.ANGLE and DGD.ANGLE ~= 0 then + if DGD.sFrame == 'LE' or DGD.sFrame == 'HE' then + if ( DGD.sFrame == 'HE' and DGD.Lock == 'L' and DGD.Push) or + ( DGD.sFrame == 'LE' and DGD.Lock == 'R' and DGD.Push) or + ( DGD.sFrame == 'HE' and DGD.Lock == 'R' and not DGD.Push) or + ( DGD.sFrame == 'LE' and DGD.Lock == 'L' and not DGD.Push) then + tMhPar.ang = - DGD.ANGLE + else + tMhPar.ang = DGD.ANGLE + end + else + tMhPar.ang = 0 + end + else + tMhPar.ang = 0 + end + + tMhPar.L2 = DGD.dWidthRabbet + tMhPar.H2 = DGD.WIDTH + tMhPar.H = DGD.WIDTH - EgtIf( tMhPar.ang ~= 0, ( ( tMhPar.L - tMhPar.L2)*tan(abs(tMhPar.ang))),0) + tMhPar.T = DGD.DEPTH + tMhPar.op = DGD.OPPO + + -- se non ho parametro step o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s or abs(tMhPar.s) < GEO.EPS_SMALL then + tMhPar.s = tMhPar.T + end + + -- se non ho parametro step antisplint o è 0 lo assegno uguale allo spessore cava + if not tMhPar.s2 or abs(tMhPar.s2) < GEO.EPS_SMALL then + tMhPar.s2 = tMhPar.T + end + + -- se non ho parametro spessore di riferimento lo assegno uguale allo spessore cava + if not tMhPar.Tl or abs(tMhPar.Tl) < GEO.EPS_SMALL then + tMhPar.Tl = tMhPar.T + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM = tMhPar.LM + local nLMi = 1 + local sLMR = tMhPar.LMR + local nLMRi = 1 + local sLA = tMhPar.LA + local nLAi = 1 + if tMhPar.Ver == 0 then + tMhPar.LA2 = tMhPar.LA + end + local sLA2 = tMhPar.LA2 + local nLA2i = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.est = true + tMhPar.d2 = nil + tMhPar.d4 = nil + else + tMhPar.est = nil + end + + if DGD.MachEn > 0 and tMhPar.d and sLM and #sLM > 0 then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + if DGD.MachEn > 0 and tMhPar.d2 and sLA and #sLA > 0 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end + if DGD.MachEn > 0 and tMhPar.d3 and sLMR and #sLMR > 0 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMR, nLMRi) end + if tMhPar.Ver > 0 and DGD.MachEn > 0 and tMhPar.d4 and sLA2 and #sLA2 > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLA2, nLA2i) end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -2596 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif nTempT1 and nTempT1 >= 0 then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and tMhPar.lw and tMhPar.lw == 1 and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + dNumLog = -2596 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif nTempT2 and nTempT2 >= 0 then + tMhPar.d2 = nTempT2 + end + + if tMhPar.Ver > 0 then + if DGD.bProoduce and tMhPar.lw and tMhPar.lw == 1 and tMhPar.d4 and nTempT4 and nTempT4 <= 0 then + dNumLog = -2596 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLA2, nLA2i, tMhPar.d4, dNumLog, sMchngName4) + elseif nTempT4 and nTempT4 >= 0 then + tMhPar.d4 = nTempT4 + end + end + + if DGD.bProoduce and tMhPar.Tl and tMhPar.T > tMhPar.Tl and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then + dNumLog = -2596 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMR, nLMRi, tMhPar.d3, dNumLog, sMchngName3) + elseif nTempT3 and nTempT3 >= 0 then + tMhPar.d3 = nTempT3 + end + + -- se la profondità della cava è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat1 and tMhPar.T > dMaxMat1 then + dNumLog = -2595 + dNumMessage = 549 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 + end + + -- se la profondità antischeggia della cava è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.lw and tMhPar.lw == 1 and tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then + dNumLog = -2594 + dNumMessage = 541 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 + end + + -- se la profondità della cava è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.Tl and tMhPar.T > tMhPar.Tl and tMhPar.T and dMaxMat3 and tMhPar.T > dMaxMat3 then + dNumLog = -2593 + dNumMessage = 549 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat3)) + tMhPar.T = dMaxMat3 + end + end + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function Rabbet.Draw( tRabbetParameter, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni + local L = tRabbetParameter.L + local L2 = tRabbetParameter.L2 + local H = tRabbetParameter.H + local H2 = tRabbetParameter.H2 + local T = tRabbetParameter.T + local ang = tRabbetParameter.ang + local d = tRabbetParameter.d + local p = tRabbetParameter.p + local Tl = tRabbetParameter.Tl + local s = tRabbetParameter.s + local d2 = tRabbetParameter.d2 + local d4 = tRabbetParameter.d4 + local s2 = tRabbetParameter.s2 + local bas = tRabbetParameter.bas + local d3 = tRabbetParameter.d3 + local p3 = tRabbetParameter.p3 + local lw = tRabbetParameter.lw + local sov = tRabbetParameter.sov + local est = tRabbetParameter.est + local kbs = tRabbetParameter.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tRabbetParameter.pbs + local op = tRabbetParameter.op + local Ver = tRabbetParameter.Ver + -- Assegno i nomi geometrie + local LG = tRabbetParameter.LG + local LM = tRabbetParameter.LM + local LMR = tRabbetParameter.LMR + local LA = tRabbetParameter.LA + local LA2 = tRabbetParameter.LA2 + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tRabbetParameter.Nome + local nCompoNpar = tRabbetParameter.Npar + local sCompoPath = tRabbetParameter.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tRabbetParameter.nCod + local sCodAdj = tRabbetParameter.sCod + -- nomi parametri per messaggi + local sNamePar1 = tRabbetParameter.N1 or 'L' + local sNamePar2 = tRabbetParameter.N2 or 'H' + local sNamePar3 = tRabbetParameter.N3 or 'T' + local sNamePar4 = tRabbetParameter.N4 or 'd' + local sNamePar5 = tRabbetParameter.N5 or 'p' + local sNamePar6 = tRabbetParameter.N6 or 'd2' + local sNamePar7 = tRabbetParameter.N7 or 's' + local sNamePar8 = tRabbetParameter.N8 or 'Tl' + local sNamePar9 = tRabbetParameter.N9 or 'd3' + local sNamePar10 = tRabbetParameter.N10 or 's2' + local sNamePar11 = tRabbetParameter.N11 or 'p3' + local sNamePar12 = tRabbetParameter.N12 or 'd4' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2500 + + if T > Tl and not sov then + sov = 0.5 + elseif not sov then + sov = 0 + end + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif nDrawMach > 0 and lw and lw == 1 and d2 and d2 < DgMin then + EC = 2 + EM = string.format(EgtDoorsMsg[400],sNamePar6,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif Ver > 0 and nDrawMach > 0 and lw and lw == 1 and d4 and d4 < DgMin then + EC = 12 + EM = string.format(EgtDoorsMsg[400],sNamePar12,EgtToUiUnits(d4),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d4 = DgMin + elseif nDrawMach > 0 and d3 and T > Tl and d3 < DgMin then + EC = 3 + EM = string.format(EgtDoorsMsg[400],sNamePar9,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif H <= 0 then + EC = 4 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EC = 5 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile + L = d + 0.002 + else + d = L - 0.002 + end + elseif nDrawMach > 0 and T > Tl and d3 and L <= d3 then + if DGD.bProoduce then + EC = 6 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar9,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile + L = d3 + 0.002 + else + d3 = L - 0.002 + end + elseif nDrawMach > 0 and p and ( p < PtMin or p > PtMax) then + EC = 7 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif nDrawMach > 0 and p3 and ( p3 < PtMin or p3 > PtMax) then + EC = 8 + EM = string.format(EgtDoorsMsg[403],sNamePar11,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif T < 0 then + EC = 9 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif nDrawMach > 0 and s and s <= 0 then + EC = 10 + EM = string.format(EgtDoorsMsg[401],sNamePar7,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d + elseif nDrawMach > 0 and s2 and s2 <= 0 then + EC = 11 + EM = string.format(EgtDoorsMsg[401],sNamePar10,EgtToUiUnits(s2), sCompoPath) -- il parametro 's2' deve essere > 0 + s2 = d2 + end + + if not bPreview and EC ~= 0 then + return (ErrorBase+EC), EM + end + + -- Se Preview cancello tutto + if bPreview then + EgtNewFile() + EgtSetDefaultMaterial( BLACK()) + end + + -- Pezzo e Layer + local Pz + + if bPreview then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + else + if not RC then + Pz = EgtGetCurrPart() -- pezzo corrente + end + if not Pz then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + end + end + + local Lg, Dm + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName( Lg, sCompoName) + + EgtSetInfo( Lg, 'DeltaPos', L / 2) -- setto una nota per indicare che deve essere spostata della quantità + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName( Dm, DM) + end + + local hint1, hint2 + local hint, hintPk, hintAs, hintAs2, hintPkSgr + local pIni, pEnd, pIni2, pEnd2 + + if nDrawMach ~= 1 then -- se abilitata geometria esterna + + local tPocket = {} + + -- Costruzione della geometria rabbet ( in senso orario) + pIni = Point3d(L/2,0,0) + if ang >= 0 then + pEnd = Point3d(L/2,-H,0) + else + pEnd = Point3d(L/2,-H2,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + if ang ~= 0 then + + if ang > 0 then + pEnd = Point3d(-(L/2)+L2,-H2,0) + else + pEnd = Point3d((L/2)-L2,-H2,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if ang >= 0 then + pEnd = Point3d(-(L/2),-H2,0) + else + pEnd = Point3d(-(L/2),-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + pEnd = Point3d(-(L/2),0,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + hint = EgtCurveCompo( Lg, tPocket, true) + EgtModifyCurveThickness( hint, -T) + EgtSetName( hint, LG) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint, 'ProbeSide', '1') + end + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + local tPocketAs = {} + local tPocketAs2 = {} + local dZedStart + local dZedWork + local nStep + local dStep + local nPass + local bMakeRoughPath + + if T > Tl and d3 then + bMakeRoughPath = true + end + + -- geometria antischeggia + if lw == 1 and d2 then -- se parametro valido + + if s2 >= T then -- se passo unico + + hint1 = DrawAddLineDrawCircle( Point3d(-((L/2)+dExtraH),(d2*3/4),0), Point3d(-((L/2)+dExtraH), EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0), + Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + hint2 = DrawAddLineDrawCircle( Point3d(-((L/2)+dExtraH),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0), Point3d(-((L-(d2/2))/2),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),0), + Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + hintAs = EgtCurveCompo( Lg, {hint1,hint2}, true) + EgtModifyCurveThickness(hintAs, -T) + + -- if old mode and double antisplint + if Ver == 0 and bas then + hint1 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),(d2*3/4),0), Point3d(((L/2)+dExtraH), -H+(d2/2),0), + Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + hint2 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),-H+(d2/2),0), Point3d(((L-(d2/2))/2),-H+(d2/2),0), + Lg, nil, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + hintAs2 = EgtCurveCompo( Lg, {hint1,hint2}, true) + EgtModifyCurveThickness(hintAs2, -T) + end + else -- altrimenti più passate + + nStep = ceil(T/s2) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + local tMVar = {} + local tMVar2 = {} + local nConEnt + local sKindVar + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + -- discesa in Y + pIni = Point3d(-((L/2)+dExtraH),(d2*3/4),dZedWork) + pEnd = Point3d(-((L/2)+dExtraH),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- entrata in X + pIni = pEnd + pEnd = Point3d(-((L-(d2/2))/2),EgtIf( ang >= 0,-(H+(L*tan(ang))),-H)+(d2/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + -- stacco in Y di 0.2 o 0.01 (in base alla variabile Ver) + pIni = pEnd + pEnd = Point3d( pIni:getX(), pIni:getY()+EgtIf( Ver == 0, 0.2, 0.01), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in X ( uscendo completamente con Ver > 0, uscendo 0.2 + dExtraH se Ver = 0) + pIni = pEnd + pEnd = Point3d( -((L/2)+EgtIf( Ver == 0, dExtraH + 0.2, (d2/2)+0.5)), pIni:getY(), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in Y + pIni = pEnd + pEnd = Point3d( pIni:getX(), (d2*3/4), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + pIni = pEnd + pEnd = Point3d( -((L/2)+dExtraH), (d2*3/4), dZedWork) + + -- if old mode and double anti-splin + if Ver == 0 and bas then + + -- discesa in Y + pIni2 = Point3d(((L/2)+dExtraH),(d2*3/4),dZedWork) + pEnd2 = Point3d(((L/2)+dExtraH),-H+(d2/2),dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- entrata in X + pIni2 = pEnd2 + pEnd2 = Point3d(((L-(d2/2))/2),-H+(d2/2),dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + -- stacco in Y di 0.2 + pIni2 = pEnd2 + pEnd2 = Point3d( pIni2:getX(), pIni2:getY()+0.2, dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in X + pIni2 = pEnd2 + pEnd2 = Point3d(((L/2)+dExtraH+0.2), pIni2:getY(), dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in Y + pIni2 = pEnd2 + pEnd2 = Point3d( pIni2:getX(), (d2*3/4), dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + pIni2 = pEnd2 + pEnd2 = Point3d(((L/2)+dExtraH), (d2*3/4), dZedWork) + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi scendo in z + if nPass <= nStep then + local pIniLoc = pEnd + pEnd = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + + -- if old mode and double anti-splin + if Ver == 0 and bas then + pIniLoc = pEnd2 + pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar2, {nConEnt,sKindVar}) + end + end + end -- end while + + -- trasformo in geometria composita + if #tPocketAs > 0 then + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs then + EgtModifyCurveThickness( hintAs, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}' + if i < #tMVar then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs, 'MVar', sListEnt) end + end + end + if Ver == 0 and #tPocketAs2 > 0 then -- se secondo percorso antischeggia + hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true) + if hintAs2 then + EgtModifyCurveThickness( hintAs2, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar2 do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2[i][1], 0) .. ', ' .. 'code=' .. tMVar2[i][2] .. '}' + if i < #tMVar2 then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end + end + end + end + + if hintAs then -- se esiste geometria + EgtSetName(hintAs,LA) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintAs, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + end + + if Ver == 0 and hintAs2 then -- se esiste geometria secondo antischeggia + EgtSetName(hintAs2,LA) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintAs2, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs2, 'ProbeSide', '1') + end + end + end + + -- seconda geometria antischeggia + if Ver > 0 and lw == 1 and d4 and bas then -- se parametro valido + + if s2 >= T then -- se passo unico + + hint1 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),(d4*3/4),0), Point3d(((L/2)+dExtraH), -H+(d4/2),0), + Lg, nil, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE()) + hint2 = DrawAddLineDrawCircle( Point3d(((L/2)+dExtraH),-H+(d4/2),0), Point3d(((L-(d4/2))/2),-H+(d4/2),0), + Lg, nil, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE()) + + hintAs2 = EgtCurveCompo( Lg, {hint1,hint2}, true) + EgtModifyCurveThickness(hintAs2, -T) + else -- altrimenti più passate + + nStep = ceil(T/s2) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + local tMVar2 = {} + local nConEnt + local sKindVar + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + -- discesa in Y + pIni2 = Point3d(((L/2)+dExtraH),(d4*3/4),dZedWork) + pEnd2 = Point3d(((L/2)+dExtraH),-H+(d4/2),dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), true, true, ORANGE(), ORANGE()) + + -- entrata in X + pIni2 = pEnd2 + pEnd2 = Point3d(((L-(d4/2))/2),-H+(d4/2),dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + -- stacco in Y di 0.01 + pIni2 = pEnd2 + pEnd2 = Point3d( pIni2:getX(), pIni2:getY()+0.01, dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in X uscendo completamente + pIni2 = pEnd2 + pEnd2 = Point3d(((L/2)+(d4/2)+0.5), pIni2:getY(), dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE()) + + -- ritorno in Y + pIni2 = pEnd2 + pEnd2 = Point3d( pIni2:getX(), (d4*3/4), dZedWork) + DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, ORANGE(), ORANGE()) + pIni2 = pEnd2 + pEnd2 = Point3d(((L/2)+dExtraH), (d4*3/4), dZedWork) + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi scendo in z + if nPass <= nStep then + local pIniLoc = pEnd2 + pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d4/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar2, {nConEnt,sKindVar}) + end + end -- end while + + if ( #tPocketAs2 > 0) then -- se secondo percorso antischeggia + hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true) + if hintAs2 then + EgtModifyCurveThickness( hintAs2, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar2 do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2[i][1], 0) .. ', ' .. 'code=' .. tMVar2[i][2] .. '}' + if i < #tMVar2 then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end + end + end + end + + if hintAs2 then -- se esiste geometria secondo antischeggia + EgtSetName(hintAs2,LA2) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintAs2, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs2, 'ProbeSide', '1') + end + end + end + + -- geometria finitura + local tPocket = {} + local tMVar = {} + local nConEnt + local sKindVar + local pStart + -- se ho la sgrossatura setto subito la finitura all'affondamento finale + nStep = EgtIf( bMakeRoughPath, 1, ceil(T/s)) + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + + while LM and #LM > 0 and nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + pIni = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork) + pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + + if H <= (d*p) then -- se cava troppo bassa + + -- linea entrante in Y + pEnd = Point3d(-((L/2)+dExtraH),-H+(d/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea traversa in X + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),-H+(d/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + + -- collego a eventuale linea inclinate + if ang > 0 then -- scivolo verso sinistra + pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH * tan(ang))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork) + elseif ang < 0 then -- scivolo verso destra + pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d/2)/cos(ang))+(dExtraH*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork) + else -- piano + pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork) + end + + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + else + + local nDirVers = -1 + local nHorStep = floor((H/(d*p))+0.6) + local dHorStep = H/nHorStep + local nDistYcentr = dHorStep + local nPosYcentr = nDistYcentr - (d/2) + local nPassHor = 1 + + -- ciclo passate svuotatura + while nPassHor <= nHorStep do + + -- linea affondamento in Y + pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + -- linea passata in X + pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + + if Ver > 0 then + + pIni = pEnd + + -- linea risalita in Y + pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),(d*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr + nDistYcentr + nPassHor = nPassHor + 1 + + -- se ancora dentro l'area + if nPassHor <= nHorStep then + + if Ver > 0 then + -- linea ritorno in X + pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),(d*3/4),dZedWork) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + else + nDirVers = -nDirVers + end + -- ricalcolo punti per linea successiva + pIni = pEnd + end + end -- end while + + pIni = pEnd + + -- collego a eventuale linea inclinate + if ang > 0 then -- scivolo verso sinistra + if Ver == 0 and nDirVers < 0 then -- se ultima a destra + -- vado al punto di intersezione + pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH*tan(ang))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork) + else -- se ultima a sinistra + -- vado al punto di intersezione + pEnd = Point3d(-((L/2)+dExtraH),-H-((L+dExtraH)*tan(ang))+((d/2)/cos(ang))-(dExtraH*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),-H+(((d/2)/cos(ang))+(dExtraH*tan(ang))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork) + end + elseif ang < 0 then -- scivolo verso destra + if Ver == 0 and nDirVers < 0 then -- se ultima a destra + -- vado al punto di intersezione + pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d/2)/cos(ang))+(dExtraH*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d*3/4),dZedWork) + else -- se ultima a sinistra + -- vado al punto di intersezione + pEnd = Point3d(-((L/2)+dExtraH),-H+(((d/2)/cos(ang))-(dExtraH*tan(ang))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH), pIni:getY()+((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),(d*3/4),dZedWork) + end + else -- piano + pEnd = Point3d(pIni:getX(), (d*3/4), dZedWork) + end + + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep then + pIni = pEnd + pEnd = Point3d(pStart:getX(), pStart:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, + YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocket > 0) then + hintPk = EgtCurveCompo( Lg, tPocket, true) + if hintPk then + EgtModifyCurveThickness( hintPk, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}' + if i < #tMVar then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPk, 'MVar', sListEnt) end + EgtSetName( hintPk, LM .. EgtIf( lw == 1, '_H', '')) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPk, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk, 'ProbeSide', '1') + end + else + EC = ErrorBase + 12 + EM = string.format(EgtDoorsMsg[427], sCompoPath) + end + end + + -- creo percorso di sgrossatura + if bMakeRoughPath then + + -- geometria sgrossatura + local tPocket2 = {} + local tMVar = {} + local nConEnt + local sKindVar + local pStart + nStep = ceil(T/s) + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + pIni = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork) + pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + + if H <= (d3*p3) then -- se cava troppo bassa + + -- linea entrante in Y + pEnd = Point3d(-((L/2)+dExtraH),-H+(d3/2)+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), true, true, RED(), RED()) + -- linea traversa in X + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),-H+(d3/2)+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + + -- collego a eventuale linea inclinate + if ang > 0 then -- scivolo verso sinistra + pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH * tan(ang)))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork) + elseif ang < 0 then -- scivolo verso destra + pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))+(dExtraH*tan(ang))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork) + else -- piano + pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork) + end + + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + else + + local nDirVers = -1 + local nHorStep = floor((H/(d3*p3))+0.6) + local dHorStep = H/nHorStep + local nDistYcentr = dHorStep + local nPosYcentr = nDistYcentr - (d3/2) - sov + local nPassHor = 1 + + -- ciclo passate svuotatura + while nPassHor <= nHorStep do + + -- linea affondamento in Y + pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + -- linea passata in X + pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),-nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + + if Ver > 0 then + + pIni = pEnd + + -- linea risalita in Y + pEnd = Point3d((-nDirVers * ((L/2)+dExtraH)),(d3*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + pIni = pEnd + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr + nDistYcentr + nPassHor = nPassHor + 1 + + -- se ancora dentro l'area + if nPassHor <= nHorStep then + if Ver > 0 then + -- linea ritorno in X + pEnd = Point3d((nDirVers * ((L/2)+dExtraH)),(d3*3/4),dZedWork) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + else + nDirVers = -nDirVers + end + -- ricalcolo punti per linea successiva + pIni = pEnd + end + end -- end while + + pIni = pEnd + + -- collego a eventuale linea inclinate + if ang > 0 then -- scivolo verso sinistra + if Ver == 0 and nDirVers < 0 then -- se ultima a destra + -- vado al punto di intersezione + pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH*tan(ang)))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork) + else -- se ultima a sinistra + -- vado al punto di intersezione + pEnd = Point3d(-((L/2)+dExtraH),-H-((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))-(dExtraH*tan(ang))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),-H+(((d3/2)/cos(ang))+(dExtraH*tan(ang)))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork) + end + elseif ang < 0 then -- scivolo verso destra + if Ver == 0 and nDirVers < 0 then -- se ultima a destra + -- vado al punto di intersezione + pEnd = Point3d(((L/2)+dExtraH),-H+((L+dExtraH)*tan(ang))+((d3/2)/cos(ang))+(dExtraH*tan(ang))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH), pIni:getY()-((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraH),(d3*3/4),dZedWork) + else -- se ultima a sinistra + -- vado al punto di intersezione + pEnd = Point3d(-((L/2)+dExtraH),-H+(((d3/2)/cos(ang))-(dExtraH*tan(ang)))+sov,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- faccio linea inclinata + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH), pIni:getY()+((L+(2*dExtraH))*tan(ang)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, RED(), RED()) + -- punti risalita + pIni = pEnd + pEnd = Point3d(((L/2)+dExtraH),(d3*3/4),dZedWork) + end + else -- piano + pEnd = Point3d(pIni:getX(), (d3*3/4), dZedWork) + end + + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW()) + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep then + pIni = pEnd + pEnd = Point3d(pStart:getX(), pStart:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d3/2), false, true, + YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocket2 > 0) then + hintPkSgr = EgtCurveCompo( Lg, tPocket2, true) + if hintPkSgr then + EgtModifyCurveThickness( hintPkSgr, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}' + if i < #tMVar then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPkSgr, 'MVar', sListEnt) end + EgtSetName(hintPkSgr,LMR.. EgtIf( lw == 1, '_H', '')) + EgtSetInfo( hintPkSgr, 'OL', sov) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hintPkSgr, 'KeepBackSet', 'n') -- setto 'n' perché viene mantenuto la profondità cava sul lato narrow + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPkSgr, 'ProbeSide', '1') + end + else + EC = ErrorBase + 13 + EM = string.format(EgtDoorsMsg[427], sCompoPath) + end + end + end + end + + -- se rabbet sul lato opposto, ruoto tutte le geoemtrie + if op and op == 1 and EC == 0 then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + if hint then + EgtRotate( hint, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta + end + if hintAs then + EgtRotate( hintAs, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta + end + if hintAs2 then + EgtRotate( hintAs2, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta + end + if hintPk then + EgtRotate( hintPk, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta + end + if hintPkSgr then + EgtRotate( hintPkSgr, Point3d(0,0,0), Z_AX(), 180, GDB_RT.GRID) -- ruoto su faccia opposta + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint then + EgtSetColor(hint,AQUA()) + end + if hintAs then + EgtSetColor(hintAs,AQUA()) + end + if hintAs2 then + EgtSetColor(hintAs2,AQUA()) + end + if hintPk then + EgtSetColor(hintPk,AQUA()) + end + if hintPkSgr then + EgtSetColor(hintPkSgr,AQUA()) + end + else + if hint then + EgtSetColor(hint,ORANGE()) + end + if hintAs then + EgtSetColor(hintAs,ORANGE()) + end + if hintAs2 then + EgtSetColor(hintAs2,ORANGE()) + end + if hintPk then + EgtSetColor(hintPk,ORANGE()) + end + if hintPkSgr then + EgtSetColor(hintPkSgr,ORANGE()) + end + end + else -- altrimenti non Preview + + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'Rabbet') + EgtSetInfo(Lg,'Nome' ,sCompoName) + EgtSetInfo(Lg,'L' ,L) + EgtSetInfo(Lg,'L2' ,L2) + EgtSetInfo(Lg,'H' ,H) + EgtSetInfo(Lg,'H2' ,H2) + EgtSetInfo(Lg,'T' ,T) + EgtSetInfo(Lg,'ang' ,ang) + EgtSetInfo(Lg,'d' ,d) + EgtSetInfo(Lg,'p' ,p) + EgtSetInfo(Lg,'Tl' ,Tl) + EgtSetInfo(Lg,'s' ,s) + EgtSetInfo(Lg,'d2' ,d2) + EgtSetInfo(Lg,'d4' ,d4) + EgtSetInfo(Lg,'s2' ,s2) + EgtSetInfo(Lg,'bas' ,bas) + EgtSetInfo(Lg,'d3' ,d3) + EgtSetInfo(Lg,'p3' ,p3) + EgtSetInfo(Lg,'lw' ,lw) + EgtSetInfo(Lg,'sov' ,sov) + EgtSetInfo(Lg,'est' ,est) + EgtSetInfo(Lg,'kbs' ,kbs) + EgtSetInfo(Lg,'pbs' ,pbs) + EgtSetInfo(Lg,'op' ,op) + EgtSetInfo(Lg,'Ver' ,Ver) + EgtSetInfo(Lg,'LG' ,LG) + EgtSetInfo(Lg,'LM' ,LM) + EgtSetInfo(Lg,'LMR' ,LMR) + EgtSetInfo(Lg,'LA' ,LA) + EgtSetInfo(Lg,'LA2' ,LA2) + EgtSetInfo(Lg,'Path' ,sCompoPath) + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + + +return Rabbet diff --git a/LuaLibs/RollerLatch.lua b/LuaLibs/RollerLatch.lua new file mode 100644 index 0000000..fd82901 --- /dev/null +++ b/LuaLibs/RollerLatch.lua @@ -0,0 +1,1957 @@ +-- +-- 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 +-- +-- RollerLatch.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Roller Latch + +-- 2016.09.21 V1.0a0 FM Add warning messages +-- 2017.02.20 V1.0a1 FM Manage step face and radius face features +-- 2018.04.05 V1.0a2 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.0a3 FM Add parameter to show into message 402 +-- 2018.10.22 V1.0a4 FM Manage better the big radius fillet parameter +-- 2018.11.30 V1.0a5 FM Manage apply hardware on Lock side +-- 2018.12.06 V1.0a6 FM Manage geometry for calculate box without RollerLatch volume (when strike) +-- 2019.03.00 V1.0a7 FM Manage strike shape like Offset pivot (with knuckle) +-- 2019.05.06 V1.0a8 FM Fix error on using DGD.OFFSET in case it is nil +-- 2019.08.29 V1.0a9 FM Add setting pivot parameter for T shape +-- 2019.10.11 V1.0aa FM Manage steel option (disable to generate pocket paths, mortise) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.29 V2.001 FM Add clean corner geometries +-- 2019.12.18 V2.002 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.003 FM fix a bug on clean corner direction path in case main path turn reverse +-- 2020.04.29 V2.004 FM Update for aluminum material +-- 2020.05.19 V2.005 FM Adjust position geometry for substract region on strike part +-- 2020.05.19 V2.006 FM Adjust calculation parameter H3 and invert knuckle position on frames +-- 2020.05.25 V2.007 FM Manage geometrie for calculate region when frame(jamb) is disposed on wide side +-- 2020.06.19 V2.008 FM fix a bug on not initialized D variable +-- 2020.07.01 V2.009 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 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.03.12 V3.001 FM Add missing functions DrawLocAddLineDrawCircle and DrawLocAddCircleDrawCircle +-- 2021.03.12 V3.001 FM Remove not used variable bEqualTh into call function MakeBoreOrButtoHole +-- 2021.05.10 V3.002 FM Set to 0 variable D_XT if it's not defined +-- 2021.11.24 V3.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V3.004 FM Modification to use compiled code +-- 2024.02.02 V3.005 FM Manage new geometry name suffix LK, enabled by SideDoorDefined CurrCamInfo parameter, to applied on side geometry +-- when the lock is applied on side differeent than lock side +-- 2024.07.19 V3.006 FM Set note 'NotCheckDir' to pocketing, antisplint and buttonhole pocketing paths +-- 2024.10.02 V3.007 FM Manage probe geometry and their offset position when template is disposed on lock side +-- 2024.10.29 V3.008 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local RollerLatch = {} + +-- 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 function DrawLocAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, + nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine +end + +local function DrawLocAddCircleDrawCircle( pCenter, dRadius, dAngIni, dAngCen, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + + if idTable then + table.insert( idTable, nCircle) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumCircle = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, EgtSP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nCircle, nNumCircle, sMVar +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione creazione foro o asola o rampa per asola +local function MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, PX10, Int10, D10, + dParH, PY10, T10, RP10, AR10, + RCI10, kbs, HB10, ls, dws, pbs) + + local pIni, pEnd, pCen + local hint3, hint5 + local tPath = {} + local tPathPok = {} + + if IY10 > 0 and EBH10 ~= '' then -- se parametri asola presenti + + pIni = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10-(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10-(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10-(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 0,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10-(D10/2)),(dParH+PY10+(IY10/2)),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10+(IY10/2)),0) + pCen = Point3d((PX10+Int10),(dParH+PY10+(IY10/2)),0) + DrawLocAddCircleDrawCircle( pCen, (D10/2), 180,-180, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((PX10+Int10+(D10/2)),(dParH+PY10),0) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + hint3 = EgtCurveCompo( Lg, tPath, true) + EgtModifyCurveThickness( hint3, -T10) + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint3, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + if nDrawMach > 0 and RP10 and RP10 > 0 and (RP10/2) < T10 then --se parametro step è valido, creao il percorso a zig-zag centrale + + EgtSetName( hint3,'_'..EBH10) -- aggiungo _ per disabilitare lavorazione + local nStep = ceil(T10/RP10) -- numero di passate + local dStep = (T10/nStep) -- passo ricalcolato + local nPass = 1 + local dZedStart = 0 + local dZedWork + local nInv = 1 + + pIni = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedStart) + + while nPass <= nStep do + + dZedWork = dZedStart - (dStep/2) + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + dZedWork = dZedStart - dStep + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),dZedWork) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + -- se ho altri passi scendo in z + if nPass < nStep then + dZedStart = dZedWork + end + nPass = nPass + 1 + end + -- faccio passata di ritorno + nInv = -nInv + pEnd = Point3d((PX10+Int10),(dParH+PY10+((IY10/2)*nInv)),-T10) + DrawLocAddLineDrawCircle( pIni, pEnd, Lg, tPathPok, bPreview, Dm, 0, false, false, RED(), RED()) + + hint5 = EgtCurveCompo( Lg, tPathPok, true) + EgtModifyCurveThickness( hint5, 0) + EgtSetName( hint5, EBH10) + EgtSetInfo( hint5, 'NotCheckDir', '1') + + -- se rotazione attiva + if AR10 ~= 0 then + -- rotazione in centro all'interasse + if RCI10 then + EgtRotate( hint5, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + -- rotazione in centro all'asola + else + EgtRotate( hint5, Point3d((PX10+Int10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + else + EgtSetName( hint3, EBH10) + end + elseif EB10 ~= '' then + hint3 = EgtCircle( Lg, Point3d((PX10+Int10),(dParH+PY10),0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint3, -T10) + EgtSetName( hint3, EB10) + -- se rotazione in centro all'interasse (sono questo caso perchè non ha senso ruotare un foro in centro a se stesso) + if AR10 ~= 0 and RCI10 then + EgtRotate( hint3, Point3d((PX10),(dParH+PY10),0), Z_AX(), AR10, GDB_RT.LOC) -- ruoto + end + end + + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( hint3, 'KeepBackSet', sKeepMode) + if hint5 then + EgtSetInfo( hint5, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint3, 'ProbeSide', '1') + if hint5 then + EgtSetInfo( hint5, 'ProbeSide', '1') + end + end + + if HB10 then + EgtSetInfo( hint3, 'SideDoor', 'LockLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'LockLH') + end + else + EgtSetInfo (hint3, 'SideDoor', 'SideLH') + if hint5 then + EgtSetInfo( hint5, 'SideDoor', 'SideLH') + end + end + if dws then + local nIdSideBoxUp = EgtCopyGlob( hint3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + if hint5 then + nIdSideBoxUp = EgtCopyGlob( hint5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end +end + +-- Funzione di sistemazione parametri +function RollerLatch.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local nTempT4 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local sMchngName4 + local dOffset = DGD.OFFSET or 0 + tMhPar.bETh = false + + -- 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 + + if tMhPar.H then + if DGD.sFrame then -- se è un assemblato + -- offset, in questo caso parte dal lato wide del frame, quindi gli si deve sottrarre la metà dello spessore del frame + if abs(dOffset) > 0 then + dOffset = dOffset - (DGD.dT/2) + end + tMhPar.H3 = ((DGD.dT + tMhPar.H)/2) - dOffset + else + -- l'offset è riferito dal centro spessore, + -- cioè se <> da 0 le geometrie si spostano del valore offset da centro dello spessore + tMhPar.H3 = ((DGD.dT + tMhPar.H)/2) - dOffset +-- -tMhPar.H3 + (tMhPar.H/2) = -(DGD.dT/2) + dOffset +-- -tMhPar.H3 + (tMhPar.H/2) + (DGD.dT/2) = dOffset + end + end + + tMhPar.invG = 1 + tMhPar.invK = 1 + tMhPar.fht = 0 -- setto il face h top a 0 + tMhPar.fhb = 0 -- setto il face h bottom a 0 + tMhPar.sopp = DGD.Lock == 'L' + tMhPar.fopp = 1 + + if DGD.Lock == 'R' then + if tMhPar.D_X then + tMhPar.D_X = -tMhPar.D_X + end + else + tMhPar.invK = -tMhPar.invK + end + + if DGD.Push then + tMhPar.invG = -tMhPar.invG + end + + if string.lower(DGD.SIDE) == 'bottom' then tMhPar.invG = -tMhPar.invG end + + if tMhPar.nw and tMhPar.L3 and tMhPar.L3 <= 0.001 then + tMhPar.ls = false + end + + -- setto parametro riferimento profondità roller + tMhPar.drf = DGD.dT/6 + + if DGD.sFrame then -- se è un assemblato + tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato + tMhPar.sopp = not tMhPar.sopp + tMhPar.fopp = -tMhPar.fopp + if tMhPar.D_X then + tMhPar.D_X = -tMhPar.D_X + end + end + + -- do errore se applicato a lato lock con profilo bullnose e convesso e non è ammesso + if string.lower(DGD.SIDE) == 'lock' and not DGC.Eah and + ( DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B' or + DGD.tProfs.lockedge.trimming == 'CV') then + return tMhPar, 2099, string.format(EgtDoorsMsg[671], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se non ho il parametro chiseling lo setto disabilitato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non ho il parametro che impedisce la rotazione sul lato bevel lo setto a false + if not tMhPar.dl then + tMhPar.dl = false + DGD.NOBVROT = false + end + + -- Se c'è il profilo bevel e la geometria è applicata al lato lock + if string.lower(DGD.SIDE) == 'lock' and + ( DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB') then + + -- setto il flag che indica profilo bevel + tMhPar.bev = true + + -- Se il parametro per impedire la rotazione sul lato bevel è attivo, ricalcolo gli affondamenti + if tMhPar.dl then + + -- setto la variabile di sistema per non ruotare la geometria + DGD.NOBVROT = true + local dExtraDepth = 0 + + if tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.ls then + -- ricalcolo la profondità per avere spessore minimo = al valore di .T + dExtraDepth = EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + tMhPar.T = tMhPar.T + dExtraDepth + end + + if tMhPar.H2 and tMhPar.T2 and tMhPar.T2 > 0 then + -- se il face è stato calcolato utilizzo il delta per mantenere lo stesso affondamento + -- relativo quando non è bevel + if dExtraDepth > 0 or tMhPar.ls then + tMhPar.T2 = tMhPar.T2 + dExtraDepth + else -- altrimenti ricalcolo la profondità per avere spessore minimo = al valore di .T + tMhPar.T2 = tMhPar.T2 + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H2/2) * TAN3)) + end + end + end + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template è applicato sul lato lock, attivo il suffisso per tutte le geometrie sul lato + tMhPar.LK = '' + if DGD.SDF and DGD.SDF > 1 and string.lower(DGD.SIDE) == 'lock' then + + tMhPar.LK = '_LK' + + -- calcolo la posizione del centro foro sullo spessore porta + if tMhPar.ls then + tMhPar.posh = -(DGD.dT/2) + else + if dOffset > 0 then + tMhPar.posh = (DGD.dT/2) - dOffset + else + tMhPar.posh = 0 + end + end + + if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + + -- se non è latch strike controllo il parametro arrotondamento e il raggio + if not tMhPar.ls then + + DGD.LSREF = false -- setto la variabile globale + + if not tMhPar.cl then + tMhPar.cl = 0 + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.cl > 0 and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- se arrotondo entrambe le estremità disabilito il chisel e il clean corner + if tMhPar.cl == 3 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM + local nLMi = 1 + local sLA + local nLAi = 1 + local sLMM + local nLMMi = 1 + local sLGH + local nLGHi = 1 + local sLG + local nLGi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.LMM = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.d2 = nil + else + tMhPar.est = nil + end + + if tMhPar.est and tMhPar.LG then + sLG = tMhPar.LG .. tMhPar.LK + if DGD.MachEn > 0 and tMhPar.d then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LM then -- geometria face + sLM = tMhPar.LM .. tMhPar.LK + if DGD.MachEn > 0 and tMhPar.d then nTempT1, dMaxMat1, sMchngName1 = MB.GetToolDataFromAttrib( sLM, nLMi) end + end + + if tMhPar.LA then -- geometria antischeggia face + sLA = tMhPar.LA .. tMhPar.LK + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA, nLAi) end + end + + if tMhPar.LMM then -- geometria mortise + sLMM = tMhPar.LMM .. tMhPar.LK + if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLMM, nLMMi) end + end + + if tMhPar.LGH then -- geometria foro + sLGH = tMhPar.LGH .. tMhPar.LK + if DGD.MachEn > 0 and tMhPar.mh and tMhPar.LGH then nTempT4, dMaxMat3, sMchngName4 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end + end + + if tMhPar.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH .. tMhPar.LK + tMhPar.d0 = 0 + if tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.mh then -- se creo foro devo disabilitare il join tra face e mortise + tMhPar.jn = false + 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 = -2092 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 <= 0 then + dNumLog = -2099 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + if DGD.bProoduce and not tMhPar.est and tMhPar.d2 and nTempT2 <= 0 then + dNumLog = -2099 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA, nLAi, tMhPar.d2, dNumLog, sMchngName2) + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + if not tMhPar.est and tMhPar.d3 and nTempT3 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -2099 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLMM, nLMMi, tMhPar.d3, dNumLog, sMchngName3) + end + elseif not tMhPar.est and nTempT3 then + tMhPar.d3 = nTempT3 + end + + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat3 then + dNumLog = -2098 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLGH, nLGHi, nil, dNumLog, sMchngName4) + end + end + + -- Regola applicazione chiseling: + -- se ho impostato un raccordo, anche se poi viene annullato perchè inferiore del raggio fresa + -- disabilito il chiseling perchè implica che se c'è un valore di raccordo non devo fare il chiseling + + -- se tipo latch strike e il raggio valido disabilito il chiseling e il clean corner + if tMhPar.ls then + + DGD.LSREF = true -- setto la variabile globale + + if tMhPar.R1 and tMhPar.R1 <= 0 then + -- se a forma T valida, copio i valori del clean corner per eventuale applicazione su raggio singolo + if tMhPar.H3 and tMhPar.H3 > 0 and tMhPar.L3 > 0 then + tMhPar.clc5 = tMhPar.clc + tMhPar.CLC5 = tMhPar.CLC + end + end + + if tMhPar.rf and tMhPar.rf > 0 then + -- se a forma T copio i valori del clean corner per eventuale applicazione su raggio singolo + -- e azzero il clean corner + if tMhPar.H3 and tMhPar.H3 > 0 and tMhPar.L3 and tMhPar.L3 > 0 then + tMhPar.clc5 = tMhPar.clc + tMhPar.CLC5 = tMhPar.CLC + tMhPar.clc = nil + tMhPar.CLC = nil + else + tMhPar.clc = nil + tMhPar.CLC = nil + end + else -- se non è definito o già nullo lo azzero + tMhPar.rf = 0 + end + + -- se ci sono tutti i raggi, disabilito il chisel + if tMhPar.R1 and tMhPar.R1 > 0 and tMhPar.rf and tMhPar.rf > 0 then + tMhPar.ech = false + end + + -- se è alto come spessore porta annullo alcuni parametri (la forma ad L, il clean corner, il raggio, etc.) + if tMhPar.H and tMhPar.H >= DGD.dT then + tMhPar.bETh = true + tMhPar.L3 = 0 + tMhPar.H3 = 0 + tMhPar.D_SK = 0 + tMhPar.rf = 0 + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + tMhPar.clc5 = nil + tMhPar.CLC5 = nil + end + + if not tMhPar.H3 then + tMhPar.H3 = 0 + end + + if not tMhPar.L3 then + tMhPar.L3 = 0 + end + + -- se non esiste il valore della distanza del knuckle la setto a 0 + if not tMhPar.D_SK then + tMhPar.D_SK = 0 + end + + -- prendo il valore assoluto + tMhPar.D_SK = abs(tMhPar.D_SK) + + -- Se knuckle setto il raccordo R1 e R1i + if tMhPar.D_SK > 0 then + -- per face con knuckle in centro assegno il valore del raggio alla variabile di raggio interno + tMhPar.R1i = tMhPar.R1 + end + + if tMhPar.L3 > 0 and tMhPar.H3 > 0 then -- se ho forma ad L + -- se non ho il parametro raccordo su singolo angolo lo setto al valore del raccordo + if not tMhPar.R1 then + tMhPar.R1 = tMhPar.rf + end + if DGD.sFrame then -- se è un assemblato rendo opposto la posizione del knuckle + tMhPar.D_SK = tMhPar.L - tMhPar.L3 - tMhPar.D_SK + end + end + else + + if tMhPar.H and tMhPar.H >= DGD.dT then + tMhPar.bETh = true + tMhPar.rf = 0 + tMhPar.clc = nil + tMhPar.CLC = nil + end + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- se raggio non definito o minore del diametro utensile lo annullo +-- if not tMhPar.rf or ( tMhPar.d and tMhPar.rf < tMhPar.d/2) then +-- tMhPar.rf = 0 +-- end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + 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 = -2091 + 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 = -2097 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat1 + end + + -- se la profondità antischeggia della face è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T and dMaxMat2 and tMhPar.T > dMaxMat2 then + dNumLog = -2096 + dNumMessage = 462 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat2)) + tMhPar.T = dMaxMat2 - 0.02 -- tolgo 0.02 per permettere la lavorazione + dMaxMat = dMaxMat2 + end + + -- se foro abilitato e la profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then + dNumLog = -2095 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3)) + tMhPar.T2 = dMaxMat3 + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and not tMhPar.mh and + tMhPar.T2 and dMaxMat and tMhPar.T2 > dMaxMat then + dNumLog = -2094 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat)) + tMhPar.T2 = dMaxMat + end + + -- se la mortise non è concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and not tMhPar.mh and + tMhPar.T2 and dMaxMat3 and tMhPar.T2 > dMaxMat3 then + dNumLog = -2093 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat3)) + tMhPar.T2 = dMaxMat3 + end + + -- Raggio: se altro materiale e raggio presente e se raggio minore del diametro utensile + delta, lo annullo + if tMhPar.est then + if tMhPar.ls then + if tMhPar.rf and tMhPar.rf > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + else + if tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + end + 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 = -2090 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) .. ' \n' + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and abs(tMhPar.T2) > tMhPar.TTP then + dNumLog = -2090 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) .. ' \n' + tMhPar.T2 = tMhPar.TTP + end + + if tMhPar.T and tMhPar.T > 0 and tMhPar.ls then + -- Se c'è il profilo bevel e la geometria è applicata al lato lock + if ( DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB') and + string.lower(DGD.SIDE) == 'lock' then + -- Se il parametro per impedire la rotazione sul lato bevel non è attivo + if not tMhPar.dl then + tMhPar.fht = tMhPar.T / cos(3) + else + tMhPar.fht = tMhPar.T + end + -- considerando l'angolo calcolo l'ingombro totale riferito al lato wide + tMhPar.fhb = tMhPar.fht + ( DGD.dT * TAN3) + else + tMhPar.fht = tMhPar.T + tMhPar.fhb = tMhPar.fht + end + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + end + + if tMhPar.CLC5 and tMhPar.clc5 and tMhPar.clc5 > 0 and ( tMhPar.clc5 >= tMhPar.H3 or tMhPar.clc5 >= tMhPar.L) then + tMhPar.clc5 = nil + elseif not tMhPar.CLC5 then + tMhPar.clc5 = 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 RollerLatch.Draw( tRollerParam, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni, parametri utensili e settaggi + local L = tRollerParam.L + local H = tRollerParam.H + local T = tRollerParam.T + local d = tRollerParam.d + local p = tRollerParam.p + local sf = tRollerParam.sf + local cl = tRollerParam.cl + local rf = tRollerParam.rf -- raggio arrotondamento face e a forma di L + local R1 = tRollerParam.R1 -- raggio arrotondamento face su singolo corner + local R1i = tRollerParam.R1i -- raggio interno per face con knuckle centrale + local clc = tRollerParam.clc + local ccr = tRollerParam.ccr + local clc5 = tRollerParam.clc5 + local D_SK = tRollerParam.D_SK -- distanza partenza knuckle + local D_SK2 + local L3 = tRollerParam.L3 -- lunghezza Knuckle a forma di L + local H3 = tRollerParam.H3 -- altezza Knuckle a forma di L + local d2 = tRollerParam.d2 + local mh = tRollerParam.mh -- abilitazione creazione mortasa/foro + local L2 = tRollerParam.L2 + local H2 = tRollerParam.H2 + local T2 = tRollerParam.T2 + local d3 = tRollerParam.d3 + local p3 = tRollerParam.p3 + local s = tRollerParam.s + local ls = tRollerParam.ls -- flag 'latch strike' + local jn = tRollerParam.jn -- flag join paths, means use 'same tool' for face and mortise + local posh = tRollerParam.posh -- posizione in Y del foro di tastatura + local posp = tRollerParam.posp -- posizione in X del foro di tastatura + local D = tRollerParam.D -- distance to edge + local D_X = tRollerParam.D_X -- delta on X pos on mortaise + local D_XT = tRollerParam.D_XT -- delta on X pos for all geometries + local invG = tRollerParam.invG + local invK = tRollerParam.invK + local ech = tRollerParam.ech + local est = tRollerParam.est + local kbs = tRollerParam.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tRollerParam.pbs + local dl = tRollerParam.dl + local bEqualTh = tRollerParam.bETh + local fht = tRollerParam.fht + local fhb = tRollerParam.fhb + local sopp = tRollerParam.sopp + local fopp = tRollerParam.fopp + local drf = tRollerParam.drf + local dws = tRollerParam.Dws + local dthd = tRollerParam.dThD + local ttp = tRollerParam.TTP + local tExtraBore = {} + table.insert( tExtraBore, { tRollerParam.D4, tRollerParam.T4, tRollerParam.I4, tRollerParam.PX4, tRollerParam.PY4, tRollerParam.EB4, tRollerParam.HB4}) + table.insert( tExtraBore, { tRollerParam.D5, tRollerParam.IY5, tRollerParam.T5, tRollerParam.I5, tRollerParam.PX5, tRollerParam.PY5, tRollerParam.RP5, tRollerParam.EB5, tRollerParam.EBH5, tRollerParam.HB5, tRollerParam.AR5, tRollerParam.RCI5}) + table.insert( tExtraBore, { tRollerParam.D6, tRollerParam.IY6, tRollerParam.T6, tRollerParam.I6, tRollerParam.PX6, tRollerParam.PY6, tRollerParam.RP6, tRollerParam.EB6, tRollerParam.EBH6, tRollerParam.HB6, tRollerParam.AR6, tRollerParam.RCI6}) + table.insert( tExtraBore, { tRollerParam.D7, tRollerParam.IY7, tRollerParam.T7, tRollerParam.I7, tRollerParam.PX7, tRollerParam.PY7, tRollerParam.RP7, tRollerParam.EB7, tRollerParam.EBH7, tRollerParam.HB7, tRollerParam.AR7, tRollerParam.RCI7}) + + -- Assegno i nomi geometrie + local LG = tRollerParam.LG -- nome geometria face + local LM = tRollerParam.LM -- nome lavorazione face + local LA = tRollerParam.LA -- nome geometria antischeggia + local LGM = tRollerParam.LGM -- nome geometria mortise + local LMM = tRollerParam.LMM -- nome lavorazione mortise + local LGH = tRollerParam.LGH -- nome geometria foro profondo + local CH = tRollerParam.CH -- suffisso lavorazione chisel + local CLC = tRollerParam.CLC -- nome geometria clean corner + local CLC5 = tRollerParam.CLC5 -- nome geometria clean corner su raggio singolo in caso roller a forma di T + local LK = tRollerParam.LK -- nome suffisso lavorazione su lato lock + local LH = 'Shuttle_Probe' + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tRollerParam.Nome + local nCompoNpar = tRollerParam.Npar + local sCompoPath = tRollerParam.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tRollerParam.nCod + local sCodAdj = tRollerParam.sCod + -- variabili per messaggi di errore + local sNamePar1 = tRollerParam.N1 or 'L' + local sNamePar2 = tRollerParam.N2 or 'H' + local sNamePar3 = tRollerParam.N3 or 'T' + local sNamePar4 = tRollerParam.N4 or 'd' + local sNamePar5 = tRollerParam.N5 or 'p' + local sNamePar7 = tRollerParam.N7 or 'd2' + local sNamePar8 = tRollerParam.N8 or 'L2' + local sNamePar9 = tRollerParam.N9 or 'H2' + local sNamePar10 = tRollerParam.N10 or 'T2' + local sNamePar11 = tRollerParam.N11 or 'd3' + local sNamePar12 = tRollerParam.N12 or 'p3' + local sNamePar13 = tRollerParam.N13 or 's' + local sNamePar14 = tRollerParam.N14 or 'L3' + local sNamePar15 = tRollerParam.N15 or 'H3' + local sNamePar16 = tRollerParam.N16 or 'D_SK' + local sNamePar17 = tRollerParam.N17 or 'R1' + local sNamePar18 = tRollerParam.N18 or 'R1i' + local sNamePar22 = tRollerParam.N22 or 'D' + local sNamePar23 = tRollerParam.N23 or 'DX' + local sNamePar24 = tRollerParam.N24 or 'sf' + local sNamePar25 = tRollerParam.N25 or 'rf' + local sNamePar26 = tRollerParam.N26 or 'clc' + local sNamePar27 = tRollerParam.N27 or 'clc5' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2000 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + -- variabili dei percorsi geometrici + local nGeom1, nGeom2, nAS1, nAS2 + local nPkToJoin1, nPkToJoin2, nPkToJoin + local dPosMortise = D_X or 0 + + -- se ho il suffisso per lavorazione su lato lock modifico i nomi geometrie applicati su questo lato + if LK and #LK > 0 then + if LG then + LG = LG .. LK + tRollerParam.LG = LG + end + if LM then + LM = LM .. LK + tRollerParam.LM = LM + end + if LA then + LA = LA .. LK + tRollerParam.LA = LA + end + if LGM then + LGM = LGM .. LK + tRollerParam.LGM = LGM + end + if LMM then + LMM = LMM .. LK + tRollerParam.LMM = LMM + end + if LGH then + LGH = LGH .. LK + tRollerParam.LGH = LHG + end + if CLC then + CLC = CLC .. LK + tRollerParam.CLC = CLC + end + if CLC5 then + CLC5 = CLC5 .. LK + tRollerParam.CLC5 = CLC5 + end + end + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + -- o setto la disabilitazione della creazione di alcune geometrie + if not L or not H then + bMakeFaceGeom = false + clc = nil + CLC = nil + clc5 = nil + CLC5 = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom and not ls and cl > 0 then + if L >= H then + if rf > (H/2) then + rf = (H/2) + tRollerParam.rf = rf + end + else + if rf > (L/2) then + rf = (L/2) + tRollerParam.rf = rf + end + end + end + + if bMakeFaceGeom and ls and L3 and L3 > 0 and D_SK and D_SK > 0 then + D_SK2 = L - ( D_SK + L3) + end + + if not T then + T = 0 + end + + if not D then + D = 0 + end + + if est or not L2 or not H2 then + bMakeMortGeom = false + end + + if not H2 and not T2 then -- se non ci sono i parametri dimensionali per il foro lo disabilito + bMakeMortGeom = false + mh = false + end + + if mh then -- se abilitato il foro disabilito la mortasa + bMakeMortGeom = false + end + + if not T2 then + T2 = 0 + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + local nForceMakeFace = nDrawMach + + -- se ho abilitato il chiseling modifico il nome geometria + if ech and LG then + LG = LG .. CH + tRollerParam.LG = LG + -- se ho abilitato solo le geometrie di lavorazione, abilito la generazione di entrambe per il contorno chisel + if nDrawMach == 1 then + nForceMakeFace = 2 + end + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 1 + EM = string.format(EgtDoorsMsg[400],sNamePar4,EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and d2 and d2 < DgMin then + EC = 2 + EM = string.format(EgtDoorsMsg[400],sNamePar7,EgtToUiUnits(d2),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not jn and d3 and d3 < DgMin then + EC = 3 + EM = string.format(EgtDoorsMsg[400],sNamePar11,EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif bMakeFaceGeom and H <= 0 then + EC = 4 + EM = string.format(EgtDoorsMsg[401],sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d/2 + elseif bMakeFaceGeom and nDrawMach > 0 and not ls and H < d then + if DGD.bProoduce then + EC = 5 + EM = string.format(EgtDoorsMsg[405],sNamePar2,EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere maggiore o uguale del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and jn and H2 < d then + if DGD.bProoduce then + EC = 6 + EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile + H2 = d + else + d = H2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not jn and H2 < d3 then + if DGD.bProoduce then + EC = 7 + EM = string.format(EgtDoorsMsg[405],sNamePar9,EgtToUiUnits(H2),EgtToUiUnits(d3), sCompoPath) -- il parametro 'H2' deve essere maggiore o uguale del diametro utensile + H2 = d3 + else + d3 = H2 - 0.002 + end + elseif bMakeFaceGeom and L <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d + elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EC = 9 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and d2 and L <= d2 then + if DGD.bProoduce then + EC = 10 + EM = string.format(EgtDoorsMsg[402],sNamePar1,EgtToUiUnits(L),sNamePar7,EgtToUiUnits(d2), sCompoPath) -- il parametro 'L' deve essere maggiore del diametro utensile + L = d2 + 0.002 + else + d2 = L - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and jn and L2 <= d then + if DGD.bProoduce then + EC = 11 + EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar4,EgtToUiUnits(d), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile + L2 = d + 0.002 + else + d = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not jn and L2 <= d3 then + if DGD.bProoduce then + EC = 12 + EM = string.format(EgtDoorsMsg[402],sNamePar8,EgtToUiUnits(L2),sNamePar11,EgtToUiUnits(d3), sCompoPath) -- il parametro 'L2' deve essere maggiore del diametro utensile + L2 = d3 + 0.002 + else + d3 = L2 - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and s and s <= 0 then + EC = 13 + EM = string.format(EgtDoorsMsg[401],sNamePar13,EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d + elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 14 + EM = string.format(EgtDoorsMsg[403],sNamePar5,p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not jn and ( p3 < PtMin or p3 > PtMax) then + EC = 15 + EM = string.format(EgtDoorsMsg[403],sNamePar12,p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeFaceGeom and T < 0 then + EC = 16 + EM = string.format(EgtDoorsMsg[404],sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and not dws and T2 <= T then + EC = 17 + EM = string.format(EgtDoorsMsg[407],sNamePar10,EgtToUiUnits(T2),sNamePar3,EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > del parametro 'T' + T2 = T + 0.01 + elseif bMakeFaceGeom and not ls and cl > 0 and rf and rf < 0 then + EC = 18 + EM = string.format(EgtDoorsMsg[404],sNamePar25,EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + rf = H/2 + elseif bMakeFaceGeom and not ls and cl > 0 and rf and abs(rf - (H/2)) < GEO.EPS_SMALL and L <= H then + EC = 19 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'L' deve essere > 'H' + L = H+5 + elseif bMakeFaceGeom and not ls and cl > 0 and rf and rf < (H/2) and L <= (rf*2) then + EC = 20 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar25..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2' + L = (rf*2)+5 + elseif bMakeFaceGeom and ls and rf and rf >= H then + EC = 30 + EM = string.format(EgtDoorsMsg[407],sNamePar2,EgtToUiUnits(H),sNamePar25,EgtToUiUnits(rf), sCompoPath) -- il parametro 'H' deve essere > 'rf' + H = rf + 0.01 + elseif bMakeFaceGeom and ls and rf and L <= (rf*2) then + EC = 31 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar25..'*2',EgtToUiUnits(rf)*2, sCompoPath) -- il parametro 'L' deve essere > 'rf*2' + L = (rf*2)+1 +-- elseif bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and rf and (L-rf) < L2 then +-- EC = 21 +-- EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar25,EgtToUiUnits(L2+rf), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf' +-- L = rf+L2+5 +-- elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and rf and (L-(rf*2)) < L2 then +-- EC = 22 +-- EM = string.format(EgtDoorsMsg[410],sNamePar1,EgtToUiUnits(L),sNamePar8,sNamePar25..'*2',EgtToUiUnits(L2+(rf*2)), sCompoPath) -- il parametro 'L' deve essere >= 'L2' + 'rf*2' +-- L = (rf*2)+L2+5 +-- elseif bMakeFaceGeom and bMakeMortGeom and cl == 3 and rf and (L-(rf*2)) < (L2+(2*abs(D_X))) then +-- EC = 23 +-- EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-(rf*2)-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: +-- D_X = 0 +-- elseif bMakeFaceGeom and bMakeMortGeom and (cl == 1 or cl == 2) and rf and (L-rf) < (L2+(2*abs(D_X))) then +-- EC = 24 +-- EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-rf-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: +-- D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and L < L2 then + EC = 25 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),sNamePar8,EgtToUiUnits(L2), sCompoPath) -- il parametro 'L' deve essere > 'L2' + L = L2+5 + elseif bMakeFaceGeom and bMakeMortGeom and L < (L2+(2*abs(D_X))) then + EC = 26 + EM = string.format(EgtDoorsMsg[423],sNamePar23,EgtToUiUnits(D_X),EgtToUiUnits((L-L2)/2), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and not ls and H2 > H then + EC = 27 + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar9,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2' + H2 = H + elseif bMakeFaceGeom and bMakeMortGeom and ls and L3 <= 0 and (H2+D) > H then + EC = 28 + EM = string.format(EgtDoorsMsg[423],sNamePar22,EgtToUiUnits(D),EgtToUiUnits(H-H2), sCompoPath) -- il parametro 'D' é troppo grande, max valore: + D = 0 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 29 + EM = string.format(EgtDoorsMsg[401],sNamePar24,EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 43 + EM = string.format(EgtDoorsMsg[407],sNamePar26,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + elseif bMakeFaceGeom and CLC5 and clc5 and ccr and clc5 > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc5 then + EC = 44 + EM = string.format(EgtDoorsMsg[407],sNamePar27,EgtToUiUnits(clc5),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc5 = (2*(ccr*sin(45)))+0.2 + -- controlli per forma ad L/T + elseif bMakeFaceGeom and ls and L3 > 0 then + if H3 > 0 and H3 <= H then + EC = 32 + EM = string.format(EgtDoorsMsg[407],sNamePar15,EgtToUiUnits(H3),sNamePar2,EgtToUiUnits(H), sCompoPath) -- il parametro 'H3' deve essere > 'H' + H3 = H*1.5 + elseif L3 >= L then + EC = 33 + EM = string.format(EgtDoorsMsg[406],sNamePar14,EgtToUiUnits(L3),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'L3' deve essere < 'L' + L3 = L/2 + elseif rf > H/2 then + EC = 34 + EM = string.format(EgtDoorsMsg[406],sNamePar25,EgtToUiUnits(rf),'H/2',EgtToUiUnits(H/2), sCompoPath) -- il parametro 'rf' deve essere < 'H/2' + rf = H/2 + elseif L-L3 < rf then + EC = 35 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'L3+rf',EgtToUiUnits(L3+rf), sCompoPath) -- il parametro 'L' deve essere > 'L3+R' + L = L3+rf + elseif R1 >= L-rf then + EC = 36 + EM = string.format(EgtDoorsMsg[456],sNamePar17,EgtToUiUnits(R1),'L-rf',EgtToUiUnits(L-rf), sCompoPath) -- il parametro 'R1' deve essere <= 'L-rf' + R1 = L-rf-1.5 + elseif R1 > 0 and R1 >= H3 then + EC = 37 + EM = string.format(EgtDoorsMsg[406],sNamePar17,EgtToUiUnits(R1), sNamePar15,EgtToUiUnits(H3), sCompoPath) -- il parametro 'R1' deve essere < 'H3' + R1 = H3-1.5 + elseif D_SK > 0 and D_SK2 > 0 and ((R1i + rf) - D_SK) > GEO.EPS_SMALL then + EC = 38 + EM = string.format(EgtDoorsMsg[407],sNamePar16,EgtToUiUnits(D_SK),'rf+R1',EgtToUiUnits(rf+R1i), sCompoPath) -- il parametro 'D_SK' deve essere > 'rf+R1' + D_SK = rf+R1+0.1 + elseif D_SK > 0 and D_SK2 > 0 and ((R1i + rf) - (L-D_SK-L3)) > GEO.EPS_SMALL then + EC = 39 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'D_SK+L3+rf+R1',EgtToUiUnits(D_SK+L3+rf+R1i), sCompoPath) -- il parametro 'L' deve essere > 'D_SK+L3+rf+R1' + L = D_SK+L3+rf+R1+0.1 + elseif D_SK > 0 and R1i > 0 and R1i > (H3-H) then + EC = 40 + EM = string.format(EgtDoorsMsg[406],sNamePar18,EgtToUiUnits(R1i),'H3-H (Backset)',EgtToUiUnits(H3-H), sCompoPath) -- il parametro 'R1' deve essere < 'H3-H' + R1i = 0 + R1 = 0 + elseif bMakeMortGeom and H2 > H then + EC = 41 + EM = string.format(EgtDoorsMsg[422],sNamePar2,EgtToUiUnits(H),sNamePar9,EgtToUiUnits(H2), sCompoPath) -- il parametro 'H' deve essere >= del parametro 'H2' + H2 = H + elseif bMakeMortGeom and D and H2 and (abs(D)*2) > (H-H2) then + EC = 42 + EM = string.format(EgtDoorsMsg[423],sNamePar22,EgtToUiUnits(abs(D)),EgtToUiUnits((H-H2)/2), sCompoPath) -- il parametro 'D' é troppo grande, max valore: + D = 0 + end + end + + if not bPreview and EC ~= 0 then + return (ErrorBase+EC), EM + end + + -- Se Preview cancello tutto + if bPreview then + EgtNewFile() + EgtSetDefaultMaterial( BLACK()) + end + + -- Pezzo e Layer + local Pz + + if bPreview then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + else + if not RC then + Pz = EgtGetCurrPart() -- pezzo corrente + end + if not Pz then + Pz = EgtGroup(GDB_ID.ROOT,GDB_RT.LOC) -- nuovo pezzo + end + end + + local Lg, Dm + local sRequireCompoName + local nPos1st = 0 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg,sCompoName) + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentante il diametro utensile + EgtSetName( Dm, DM) + end + + if ls then -- se latch strike lancio il componente tipo mortase hinge e tipo concelead hinge senza latch + if H3 > 0 and L3 > 0 then -- se ha forma L/T + sRequireCompoName = '_PivotL' + tRollerParam.stype = 1 + tRollerParam.rad = rf + if D_SK > 0 then + tRollerParam.D_SK2 = L - ( D_SK + L3) + end + if DGD.Lock == 'L' then + tRollerParam.D_SK = L - ( D_SK + L3) + tRollerParam.D_SK2 = L - ( tRollerParam.D_SK + L3) + if D_SK == 0 then + tRollerParam.D_SK2 = 0 + end + end + else + sRequireCompoName = '_LatchStrike' + end + else -- altrimenti lancio componente tipo concealed hinge + if bMakeFaceGeom then + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPos1st = rf/2 + elseif cl == 2 then -- se arrotondamento a destra + nPos1st = -(rf/2) + else + nPos1st = 0 + end + end + tRollerParam.D_X = dPosMortise - nPos1st + sRequireCompoName = '_Latch' + tRollerParam.Dws = nil + end + + if bMakeFaceGeom then + if ls then + tRollerParam.D_X = dPosMortise + tRollerParam.D_SK + end + -- lancio il primo componente base + MHgen = require( sRequireCompoName) + nGeom1, nPkToJoin1, nAS1, nAS2 = MHgen.Draw( EC, EM, tRollerParam, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + + -- se face a T/L sposto le geometrie + if ls and H3 > 0 and L3 > 0 then + if nGeom1 then + EgtMove( nGeom1, Point3d(((L-L3)/2)-tRollerParam.D_SK,(-H3 + (H/2)),0) - ORIG()) + end + if nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d(((L-L3)/2)-tRollerParam.D_SK,(-H3 + (H/2)),0) - ORIG()) + end + if nAS1 then + EgtMove( nAS1, Point3d(((L-L3)/2)-tRollerParam.D_SK,(-H3 + (H/2)),0) - ORIG()) + end + if nAS2 then + EgtMove( nAS2, Point3d(((L-L3)/2)-tRollerParam.D_SK,(-H3 + (H/2)),0) - ORIG()) + end + elseif not ls and abs(nPos1st) > GEO.EPS_SMALL then + if nGeom1 then + EgtMove( nGeom1, Point3d(nPos1st,0,0) - ORIG()) + end + if nPkToJoin1 then + EgtMove( nPkToJoin1, Point3d(nPos1st,0,0) - ORIG()) + end + end + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + local CLC1 + if CLC and clc and clc > 0 and clc < H and clc < L then + CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T, (invG == -1)) + if CLC1 then + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( CLC1, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + end + end + + if ls then -- se latch strike + if H3 > 0 and L3 > 0 then -- se face a T/L + if tRollerParam.D_SK > 0 and tRollerParam.D_SK2 > 0 then -- se ho knuckle centrato + if CLC1 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),H-H3,0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-H3,0) - ORIG()) + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-H3,0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),H-H3,0) - ORIG()) + end + elseif tRollerParam.D_SK > 0 then -- se knuckle opposto + if CLC1 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),H-H3,0) - ORIG()) + -- angolo x+y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC1, Point3d((L/2),-H3,0) - ORIG()) + end + elseif tRollerParam.D_SK == 0 then -- se forma L classica + if CLC1 then + local CLC4 = EgtCopyGlob( CLC1, Lg) + -- angolo x-y- + EgtRotate( CLC1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC1, Point3d(-(L/2),-H3,0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC4, Point3d(-(L/2),H-H3,0) - ORIG()) + end + end + if R1 <= 0 and ( tRollerParam.D_SK == 0 or tRollerParam.D_SK2 == 0) then -- se non c'è raccordo angolo singolo + if CLC5 and clc5 and clc5 > 0 and clc5 < H3 and clc5 < L then + local CLC5 = MakeClcPath(clc5, ccr, CLC5, Lg, -T, (invG == -1)) + if CLC5 then + -- se mantiene backset + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( CLC5, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC5, 'ProbeSide', '1') + end + if tRollerParam.D_SK == 0 then -- se forma L classica + -- angolo x+y- + EgtRotate( CLC5, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC5, Point3d((L/2),-H3,0) - ORIG()) + else -- se L opposta + -- angolo x-y- + EgtRotate( CLC5, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC5, Point3d(-(L/2),-H3,0) - ORIG()) + end + end + end + end + else -- altrimenti forma latch srike standard + if CLC1 then + -- 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 + else -- altrimenti non latch strike + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo + if CLC1 then + if cl <= 1 or cl == 3 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + if cl == 1 then + EgtErase(CLC1) + end + end + if cl == 0 or cl >= 2 then + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + end + end + end + end + end + else + -- disattivo il join dei percorsi + jn = false + tRollerParam.jn = false + end + + if bMakeMortGeom then + tRollerParam.smr = 0 + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2 = MHgen.Draw( EC, EM, tRollerParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + elseif mh then -- se devo fare il foro + + jn = false -- disattivo il join dei percorsi + nGeom2 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + EgtModifyCurveThickness( nGeom2, -T2) + EgtSetName( nGeom2, LGH) + -- se mantiene altezza o centro spessore su mortise + if kbs and kbs > 1 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + + -- se ci sono i percorsi antischegia (è ovvio che è strike) + if EC == 0 and ( nAS1 or nAS2) then + -- se mantiene altezza anche su face + if kbs and kbs > 0 then + local sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + if nAS1 then + EgtSetInfo( nAS1, 'KeepBackSet', sKeepMode) + end + if nAS2 then + EgtSetInfo( nAS2, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nAS1 then + EgtSetInfo( nAS1, 'ProbeSide', '1') + end + if nAS2 then + EgtSetInfo( nAS2, 'ProbeSide', '1') + end + end + end + + if EC == 0 and ( nGeom2 or nPkToJoin2) then + if ls then -- se latch strike muovo i percorsi della mortasa nella giusta posizione + if H3 > 0 and L3 > 0 then + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,-( -D + H3 - (H/2)),0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,-( -D + H3 - (H/2)),0) - ORIG()) + end + else + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,-(D+(H2/2)),0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,-(D+(H2/2)),0) - ORIG()) + end + end + else + if nGeom2 then + EgtMove( nGeom2, Point3d(D_X,0,0) - ORIG()) + end + if nPkToJoin2 then + EgtMove( nPkToJoin2, Point3d(D_X,0,0) - ORIG()) + end + end + end + + -- se percorsi fatti con lo stesso utensile, li concateno + if jn and EC == 0 and nPkToJoin1 and nPkToJoin2 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkToJoin1, 'MVar') + nPkToJoin = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + if nPkToJoin then + EgtSetName( nPkToJoin, LM) + EgtSetInfo( nPkToJoin, 'NotCheckDir', '1') + if sVarNote then EgtSetInfo( nPkToJoin, 'MVar', sVarNote) end + -- se mantiene altezza o centro spessore anche su face + if kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( nPkToJoin, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + else + EC = ErrorBase + 45 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + elseif not jn and EC == 0 then + -- se mantiene altezza o centro spessore su face + if kbs and kbs == 1 and nPkToJoin1 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + -- se mantiene altezza o centro spessore su face e mortise + elseif kbs and kbs > 0 then + local sKeepMode = 'c' -- setto di default per mantenere il centro dello spessore + if ls then -- se latch strike + sKeepMode = 'n' -- setto per mantenere per mantenere il lato narrow + end + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom1, 'KeepBackSet', sKeepMode) + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'KeepBackSet', sKeepMode) + EgtSetInfo( nGeom2, 'KeepBackSet', sKeepMode) + end + end + if pbs and pbs > 0 and nPkToJoin1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + elseif pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + if nPkToJoin1 then + EgtSetInfo( nPkToJoin1, 'ProbeSide', '1') + EgtSetInfo( nGeom1, 'ProbeSide', '1') + end + if nPkToJoin2 then + EgtSetInfo( nPkToJoin2, 'ProbeSide', '1') + EgtSetInfo( nGeom2, 'ProbeSide', '1') + end + end + end + + -- aggiungo fori extra + if EC == 0 and nDrawMach >= 0 then + + -- fori ( viti o passaggio filo elettrico) + for k = 1, 4 do + + local D10 + local IY10 + local T10 + local I10 + local PX10 + local PY10 + local RP10 + local EB10 + local EBH10 + local HB10 + local AR10 + local RCI10 + + if k == 1 then + D10 = tExtraBore[k][1] + T10 = tExtraBore[k][2] + I10 = tExtraBore[k][3] + PX10 = tExtraBore[k][4] + PY10 = tExtraBore[k][5] + EB10 = tExtraBore[k][6] + HB10 = tExtraBore[k][7] + else + D10 = tExtraBore[k][1] + IY10 = tExtraBore[k][2] + T10 = tExtraBore[k][3] + I10 = tExtraBore[k][4] + PX10 = tExtraBore[k][5] + PY10 = tExtraBore[k][6] + RP10 = tExtraBore[k][7] + EB10 = tExtraBore[k][8] + EBH10 = tExtraBore[k][9] + HB10 = tExtraBore[k][10] + AR10 = tExtraBore[k][11] + RCI10 = tExtraBore[k][12] + end + + if dws and T10 and abs(T10) > ttp then + T10 = ttp + end + + if D10 and T10 and ( EB10 or EBH10) then + if D10 > 0 and T10 ~= 0 and ( EB10 ~= '' or EBH10 ~= '') then + + if not IY10 then IY10 = 0 end + if not I10 then I10 = 0 end + if not PX10 then PX10 = 0 end + if not PY10 then PY10 = 0 end + if not AR10 then AR10 = 0 end + + local dInt10 = (I10/2) + local dPosX10 = -PX10 * EgtIf( sopp, -1, 1) + local dPosY10 + if ls and not( L3 and L3 > 0) then + dPosY10 = -PY10 + else -- non è latch face + -- PY10 è preso positivo perchè all'aumentare del valore deve distanziarsi dal wide side (riferimento in caso non si alatch) + dPosY10 = PY10 * fopp + end + + if ls and L3 and L3 > 0 then + dPosY10 = dPosY10 - H3 + (H/2) + end + + if abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + -- se ho il suffisso per lavorazione su lato lock + if LK and #LK > 0 then + EB10 = EB10 .. LK + EBH10 = EBH10 .. LK + end + + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, dInt10, D10, + 0, dPosY10, T10, RP10, AR10, + RCI10, kbs, HB10, ls, dws, pbs) + + -- se l'interasse è valido + if abs(I10) > GEO.EPS_SMALL then + -- creo foro o asola con eventuale svuotatura a rampa + MakeBoreOrButtoHole( Lg, bPreview, Dm, nDrawMach, IY10, + EBH10, EB10, dPosX10, -dInt10, D10, + 0, dPosY10, T10, RP10, AR10, + RCI10, kbs, HB10, ls, dws, pbs) + end + end + end + end + + -- aggiungo foro probe + if nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + if DGD.Push then + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + else + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- 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 + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not dws then -- se frame viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto) + + -- se la sezione strike supera 1/6 dello spessore porta (se è un frame drf vale 0.1 e crea sempre regione) + -- disegno sezione ribasso su faccia superiore/inferiore porta + if fhb > drf then + + -- setto griglia dietro per l'ingombro sicuramente esistente + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + local nIdSideBoxUp + if L3 > 0 then + nIdSideBoxUp = EgtRectangle2P( Lg, Point3d(((L/2)-D_SK)*invK,0,0), Point3d(((L/2)-D_SK-L3)*invK,fhb,0), GDB_RT.LOC) + else + nIdSideBoxUp = EgtRectangle2P( Lg, Point3d((L/2),0,0), Point3d(-(L/2),fhb,0), GDB_RT.LOC) + end + if nIdSideBoxUp then + if bEqualTh then + EgtModifyCurveThickness(nIdSideBoxUp, -dThickDoor) + else + if L3 > 0 then + EgtModifyCurveThickness(nIdSideBoxUp, -H3) + else + EgtModifyCurveThickness(nIdSideBoxUp, -H) + end + end + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + else -- altrimenti viene lavorato disposto sul lato wide + + local nIdSideBoxUp + + if nGeom1 then + nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom2 then + nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + if D_XT and D_XT ~= 0 then + EgtMove( Lg, Point3d(D_XT,0,0) - ORIG()) + elseif not D_XT then + D_XT = 0 + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer del roller latch + EgtSetInfo( Lg, 'Type' ,'RollerLatch') + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'cl' ,cl) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'clc5' ,clc5) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'mh' ,mh) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 'd3' ,d3) + EgtSetInfo( Lg, 'p3' ,p3) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'invK' ,invK) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'dl' ,dl) + EgtSetInfo( Lg, 'bEqualTh' ,bEqualTh) + EgtSetInfo( Lg, 'fht' ,fht) + EgtSetInfo( Lg, 'fhb' ,fhb) + EgtSetInfo( Lg, 'sopp' ,sopp) + EgtSetInfo( Lg, 'fopp' ,fopp) + 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, 'LGM' ,LGM) + EgtSetInfo( Lg, 'LMM' ,LMM) + EgtSetInfo( Lg, 'LGH' ,LGH) + EgtSetInfo( Lg, 'CH' ,CH) + EgtSetInfo( Lg, 'LK' ,LK) + EgtSetInfo( Lg, 'CLC' ,CLC) + EgtSetInfo( Lg, 'CLC5' ,CLC5) + EgtSetInfo( Lg, 'DeltaPos' ,(-(2*D_XT))) + EgtSetInfo( Lg, 'Path' ,sCompoPath) + + if ls then -- se latch strike + EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare quale punto di riferimento prendere + EgtSetInfo( Lg, 'InserPoint', 'Edge') -- setto una nota per indicare quale punto di riferimento prendere + else + EgtSetInfo( Lg, 'AppPoint', 'Wide') -- setto una nota per indicare quale punto di riferimento prendere + EgtSetInfo( Lg, 'InserPoint', 'Center') -- setto una nota per indicare quale punto di riferimento prendere + end + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + elseif not bPreview then + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + end + + if EC == 0 and nCodAdj and nCodAdj < 0 then + EC = nCodAdj + EM = sCodAdj + end + + return EC, EM, Lg +end + + +return RollerLatch diff --git a/LuaLibs/Strike.lua b/LuaLibs/Strike.lua new file mode 100644 index 0000000..99264b9 --- /dev/null +++ b/LuaLibs/Strike.lua @@ -0,0 +1,3746 @@ +-- +-- 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 +-- +-- Strike.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- edge pull tipo mortise o cilindrica + +-- 2016.09.21 V1.011 FM add warning messages +-- 2017.08.30 V1.012 FM Add flag for not rotate Face on bevel profile +-- 2018.04.05 V1.013 FM Manage info (KeepBackSet) for adjust probe on Z +-- 2018.10.17 V1.014 FM Add parameter to show into message 402 +-- 2018.10.22 V1.015 FM Manage better the big radius fillet parameter +-- 2018.10.22 V1.015 FM Add new parameter D_XE to move all geometries +-- 2018.10.22 V1.019 FM Manage new parameter reference (backset or door side) for keyway and secure extra geometries +-- 2019.05.23 V1.01a FM Manage anti-splint path on strike extra rectangle geometry +-- 2019.09.30 V1.01b FM Manage anti-splint path on anti-splint path +-- 2019.10.10 V1.01c FM Manage steel option (disable to generate pocket paths, mortise, make closed and extend face path) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.29 V2.001 FM Add clean corner geometries +-- 2019.12.16 V2.002 FM Fix error on 2nd mortise (not assign tool diameter in case join is false) +-- 2019.12.18 V2.003 FM Use new parameter DGC.Eah that allow insert template also on bullnose ans convex profiles +-- 2019.12.20 V2.004 FM fix a bug on clean corner direction path in case main path turn reverse +-- 2020.04.29 V2.005 FM Update for aluminum material +-- 2020.05.25 V2.006 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2020.05.29 V2.007 FM Manage geometries for calculate region when frame(jamb) is disposed on narrow side +-- 2020.06.24 V2.008 FM Add new line of mounting screw bores +-- 2020.07.01 V2.009 FM Disable Warning message on frames if parameter DGD.Spd is <= 0 +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.02.22 V3.001 FM fix error on check DGD.SIDE (not yet used on strike) +-- 2021.03.12 V3.002 FM Check and adjust the angle parameter on extra rectangle and extra lines +-- 2021.05.11 V3.003 FM fix error on assign name to join paths +-- 2021.11.24 V3.004 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.20 V3.005 FM Use parameter .ITP (Internal Path) from template lua file instead of function EgtGetSourceDir(1) +-- 2022.07.27 V3.006 FM Modification to use compiled code +-- 2024.07.19 V3.007 FM Set note 'NotCheckDir' to pocketing and antisplint paths +-- 2024.10.04 V3.008 FM Manage probe geometry and their offset position when template is disposed on lock side +-- 2024.10.29 V3.009 FM Manage new DGC.Fpd CurrDoorCustomData variable to force shuttle probe geometry to stay horizontal + +-- Tavola per definizione modulo (serve ma non usata) +local Strike = {} + +-- 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.25 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nLine = EgtLine(nGroup, pInitial, pFinal, nReference) + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , nReference) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function MakeRectWithFillet( Lg, P1, P2, Rf, Ang) + + local hint_3 = EgtRectangle2P( Lg, P1, P2, GDB_RT.LOC) + + if hint_3 then + + local nNewId, nNumEnt = EgtExplodeCurveCompo( hint_3) + + if nNewId and nNumEnt and nNumEnt > 0 then + + local pStartIni + + -- se devo inserire i raccordi + if Rf > 0 then + + local tIdFil = {} + local nLine + for p = 1, (nNumEnt-1) do + nLine = EgtCurveFillet( Lg, ( nNewId + p - 1), EgtEP( nNewId + p - 1), ( nNewId + p), EgtSP( nNewId + p), Rf, true) + table.insert( tIdFil, nLine) + end + nLine = EgtCurveFillet( Lg, ( nNewId + nNumEnt - 1), EgtEP( nNewId + nNumEnt - 1), nNewId, EgtSP(nNewId), Rf, true) + table.insert( tIdFil, nLine) + + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, tIdFil[1], (nNewId+1), tIdFil[2], (nNewId+2), tIdFil[3], (nNewId+3), tIdFil[4]}, true) + else + -- creo curvecompo + pStartIni = EgtMP( nNewId) + hint_3 = EgtCurveCompo( Lg, { nNewId, (nNewId+1), (nNewId+2), (nNewId+3)}, true) + end + + if hint_3 then + EgtChangeClosedCurveStartPoint( hint_3, pStartIni, GDB_RT.LOC) -- cambio punto di inizio + if Ang ~= 0 then + EgtRotate( hint_3, EgtGP( hint_3), Z_AX(), Ang, GDB_RT.LOC) -- ruoto + end + end + end + end + + return hint_3 +end + +local function MakeAspOnStrikeRect( Lg, nHint, dX, dY, dThick, + dDoorTh, dShiftX, dShiftY, bRefSide, dBack_set, + dDiam, bOpposite, dZedPos, dDiam2, sSideLock, + Fc) + + local nLine + local ptIni, ptEnd, pInt1, pInt1, ptIni2, ptEnd2 + local tPath = {} + local nPath1, nPath2, nPath3, nPath4 + local nInv = 1 + + if not dBack_set then dBack_set = 0 end + + -- creo la linea + ptIni = Point3d( (dShiftX - max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + ptEnd = Point3d( (dShiftX + max(dX, dY)), EgtIf( bRefSide, 0, -dBack_set), 0) + nLine = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE()) + + if nLine then + + -- verifico se ci sono intersezioni + pInt1 = EgtIP( nLine, nHint, ptIni) + pInt2 = EgtIP( nLine, nHint, ptEnd) + + -- se ci sono entrambe i punti e la loro distanza è maggiore del diametro fresa + if pInt1 and pInt2 then + + local dDist = dist( pInt1, pInt2) + + if dDist>= dDiam then -- se larghezza maggiore dell'utensile + + -- imposto la griglia + if bOpposite then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + nInv = -1 + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + end + + ptIni = Point3d( (pInt1:getX() + (dDiam/2) - dExtraH)*nInv, dDiam*3/4, -pInt1:getY()) + if dDiam2 then + ptIni2 = Point3d( (pInt1:getX() + (dDiam2/2) - dExtraH)*nInv, dDiam2*3/4, -pInt1:getY()) + end + + if dDoorTh - dThick > GEO.EPS_SMALL then -- se spessore non passante + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick + (dDiam/2) - dExtraH, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick + (dDiam2/2) - dExtraH, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- se spessore passante + + if (dDist - dDiam) < 2*dDiam then -- se larghezza minore del doppio diametro utensile + -- creo percorso con 3 linee + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptIni:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni = ptEnd + ptEnd = Point3d( ptIni:getX(), dDiam*3/4, ptIni:getZ()) + DrawAddLineDrawCircle( ptIni, ptEnd, Lg, tPath, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath2 = EgtCurveCompo( Lg, tPath, true) + end + + if dDiam2 then + -- creo il secondo percorso con 3 linee + tPath = {} + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptIni2:getY(), -pInt2:getY()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + ptIni2 = ptEnd2 + ptEnd2 = Point3d( ptIni2:getX(), dDiam2*3/4, ptIni2:getZ()) + DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, tPath, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + -- se il percorso esiste + if tPath then + nPath4 = EgtCurveCompo( Lg, tPath, true) + end + end + else -- larghezza maggiore del doppio diametro, creao due linee distinte + + -- creo 2 persorsi composti da una linea ciascuno + ptEnd = Point3d( ptIni:getX(), -dThick - (dDiam*3/4), ptIni:getZ()) + nPath1 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni = Point3d( (pInt2:getX() - (dDiam/2) + dExtraH)*nInv, ptEnd:getY(), -pInt2:getY()) + ptEnd = Point3d( ptIni:getX(), (dDiam*3/4), ptIni:getZ()) + nPath2 = DrawAddLineDrawCircle( ptIni, ptEnd, Lg, nil, false, nil, (dDiam/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + if dDiam2 then + -- creo 2 persorsi composti da una linea ciascuno + ptEnd2 = Point3d( ptIni2:getX(), -dThick - (dDiam2*3/4), ptIni2:getZ()) + nPath3 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + + ptIni2 = Point3d( (pInt2:getX() - (dDiam2/2) + dExtraH)*nInv, ptEnd2:getY(), -pInt2:getY()) + ptEnd2 = Point3d( ptIni2:getX(), (dDiam2*3/4), ptIni2:getZ()) + nPath4 = DrawAddLineDrawCircle( ptIni2, ptEnd2, Lg, nil, false, nil, (dDiam2/2), true, true, ORANGE(), ORANGE(), nil, 'grid') + end + end + end + end + --debug +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- se esistono gli eventuali percorso setto spessore 0 + if nPath1 then + EgtModifyCurveThickness(nPath1, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath1) + end + end + if nPath2 then + EgtModifyCurveThickness(nPath2, 0) + if sSideLock == 'L' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath2) + end + end + if nPath3 then + EgtModifyCurveThickness(nPath3, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath3) + end + end + if nPath4 then + EgtModifyCurveThickness(nPath4, 0) + if sSideLock == 'R' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + if string.lower(Fc) == 'keyway' then + -- inverto il percorso + EgtInvertCurve(nPath4) + end + end + + -- re-imposto la griglia da sopra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + -- elimino la linea + EgtErase(nLine) + end + + return nPath1, nPath2, nPath3, nPath4 +end + +local function SetProbeProperty( kbs, nValKbsPbs, pbs, sValKbs, nIdGeom, bOtherCondition, nVal1, nVal2) + + if not bOtherCondition then + if kbs and kbs > nValKbsPbs then + EgtSetInfo( nIdGeom, 'KeepBackSet', sValKbs) + end + if pbs and pbs > nValKbsPbs and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nIdGeom, 'ProbeSide', '1') + end + else + if kbs and kbs > nValKbsPbs and nVal1 < nVal2 then + EgtSetInfo( nIdGeom, 'KeepBackSet', sValKbs) + end + if pbs and pbs > nValKbsPbs and nVal1 < nVal2 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nIdGeom, 'ProbeSide', '1') + end + end +end + +local function SetPropertyAndMoveGeom( sSide, kbs, pbs, sValKbs, nPosMove, nIdGeom) + if nIdGeom then + EgtSetInfo(nIdGeom,'SideDoor',sSide) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( nIdGeom, 'KeepBackSet', sValKbs) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nIdGeom, 'ProbeSide', '1') + end + if abs(nPosMove) > GEO.EPS_SMALL then + EgtMove( nIdGeom, Point3d(nPosMove,0,0) - ORIG()) + end + end +end + +local function GetMachToolErrorMessage( nErrorId, sGeomName, dIdMach, dOriDiamTool, nIdLogErr, sMchngName) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local sMessage = '' + + if dOriDiamTool then + if nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[466], nIdLogErr, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -2 then -- errore nel settare la lavorazione, lavorazione non presente in libreria + sMessage = string.format(EgtDoorsMsg[467], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[468], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[469], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[470], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[471], nIdLogErr, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[472], nIdLogErr, sMchngName, dIdMach, sGeomName, EgtToUiUnits( dOriDiamTool)) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + elseif nErrorId == -1 then -- lavorazione non presente in tabella + sMessage = string.format(EgtDoorsMsg[504], nIdLogErr, dIdMach, sGeomName) + elseif nErrorId == -2 then -- errore nel settare la lavorazione + sMessage = string.format(EgtDoorsMsg[505], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -3 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[506], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -4 then -- errore nell'acquisire parametri lavorazione + sMessage = string.format(EgtDoorsMsg[507], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -5 then -- diametro utensile non trovato + sMessage = string.format(EgtDoorsMsg[508], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -6 then -- nome geometria non presente in tabella + sMessage = string.format(EgtDoorsMsg[503], nIdLogErr, sGeomName) + elseif nErrorId == -7 then -- altezza massima utensile non trovata + sMessage = string.format(EgtDoorsMsg[473], nIdLogErr, sMchngName, dIdMach, sGeomName) + elseif nErrorId == -8 then -- tabella non presente nelle note + sMessage = string.format(EgtDoorsMsg[509], nIdLogErr) + end + + return sMessage +end + +-- Funzione di sistemazione parametri +function Strike.AdjustParams( tMhPar) + + tMhPar.invG = 1 + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 -- per face chisel + local dMaxMat1 -- per face machining + local dMaxMata -- per anti splint machining + local dMaxMat2 -- per 1st mortise machining o foro profondo + local dMaxMat3 -- per 2nd mortise machining + local dMaxMat4 -- per mounting screw + local dMaxMat7 -- per mounting screw + local dMaxMat5 -- per preforo + local dMaxMat8 -- per antisplint su extra-rettangolo + local dMaxMat9 -- per antisplint su antisplint + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempTa + local nTempT2 + local nTempT3 + local nTempT4 + local nTempT5 + local nTempT6 + local nTempT7 + local nTempT8 + local nTempT9 + local sMchngName0 + local sMchngName1 + local sMchngNamea + local sMchngName2 + local sMchngName3 + local sMchngName4 + local sMchngName5 + local sMchngName6 + local sMchngName7 + local sMchngName8 + local sMchngName9 + local dOffset = DGD.OFFSET or 0 + + tMhPar.mkrev = false + tMhPar.ls = false + 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 + + -- setto parametro riferimento profondità roller + tMhPar.drf = DGD.dT/6 + + if DGD.sFrame then -- se è un assemblato + tMhPar.drf = 0.1 -- in questo modo crea semre la regione da togliere relativa al materiale asportato + end + + -- do errore se il tipo strike non è adatto per il tipo di porta ( inactive) + if not( DGD.sSwing == 'LHI' or DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI' or DGD.sSwing == 'LHRI') and not DGC.Eif then + return tMhPar, 2698, string.format(EgtDoorsMsg[458], tMhPar.Nome, DGD.sSwing) + end + + -- do errore se profilo tipo bullnose e convesso e non è ammesso + if not DGC.Eah and ( DGD.tProfs.lockedge.trimming == 'CV' or + DGD.tProfs.lockedge.trimming == '1B' or DGD.tProfs.lockedge.trimming == '2B' or + DGD.tProfs.lockedge.trimming == '3B' or DGD.tProfs.lockedge.trimming == '4B' or + DGD.tProfs.lockedge.trimming == '5B' or DGD.tProfs.lockedge.trimming == '6B' or + DGD.tProfs.lockedge.trimming == '7B' or DGD.tProfs.lockedge.trimming == '8B') then + return tMhPar, 2699, string.format(EgtDoorsMsg[431], tMhPar.Nome, DGD.tProfs.lockedge.trimming) + end + + -- se profilo bevel disabilito la giunzione tra face e mortise + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + tMhPar.jnb = false + -- setto il flag che indica profilo bevel + tMhPar.bev = true + else + tMhPar.jnb = true + end + + -- se serratura su lato destro setto il flag per invertire i percorsi + if DGD.Lock == 'R' then tMhPar.invG = -tMhPar.invG end + + tMhPar.SL = DGD.Lock + + if DGD.Push then tMhPar.invG = -tMhPar.invG end + + if tMhPar.dl and tMhPar.H and tMhPar.T and tMhPar.T > 0 and not tMhPar.jnb then + -- se non ruoto face risetto il flag che impedisce il chain tra face e mortise + tMhPar.jnb = true + -- ricalcolo la profondità (se non devo riferirmi al wide della porta) per avere spessore minimo = al valore di .T + tMhPar.T = tMhPar.T + EgtIf( DGC.Bwd and DGC.Bwd == 2, 0, (( tMhPar.H/2) * TAN3)) + else + tMhPar.dl = false + end + + -- se non ho il parametro lo setto disattivato + if not tMhPar.ech then + tMhPar.ech = false + end + + -- se non c'è la variabile suffisso + if not tMhPar.CH then + tMhPar.CH = '_Chisel' + end + + -- se non ho il parametro di arrotondamento lati lo setto disabilitato + if not tMhPar.CL then + tMhPar.cl = 0 + else + tMhPar.cl = 3 + end + + -- se arrotondo entrambe le estremità disabilito il chisel e il clean corner + if tMhPar.cl == 3 then + tMhPar.ech = false + tMhPar.clc = nil + tMhPar.CLC = nil + end + + if not tMhPar.rf then + tMhPar.rf = 0 + if tMhPar.cl > 0 and tMhPar.H then + tMhPar.rf = tMhPar.H/2 + end + end + + -- se non arrotondo entrambe le estremità disabilito il radius face + if tMhPar.cl == 0 then + tMhPar.rf = 0 + end + + if not tMhPar.rs then + tMhPar.rs = 0 + end + + -- se non c'è il parametro angolo foro lo setto a 0 + if not tMhPar.AB then + tMhPar.AB = 0 + elseif abs(tMhPar.AB) >= 80 then + tMhPar.AB = 0 + end + + -- se non c'è il parametro di profondità preforo lo setto a -1 + if not tMhPar.FBP then + tMhPar.FBP = -1 + end + + -- se non c'è il parametro di diametro preforo lo setto a 0 + if not tMhPar.FBD then + tMhPar.FBD = 0 + end + + if tMhPar.FBP >= 0 then -- se ha un valore lo ricalcolo perche' il valore indica la profondità minima + -- se ho il diametro e l'angolo è maggiore di zero + if tMhPar.FBD > 0 and abs(tMhPar.AB) >= 0 then + tMhPar.FBP = tMhPar.FBP + ( ( tMhPar.FBD / tan( 90 - abs(tMhPar.AB))) / 2) + -- se il diametro è valido e di coseguenza l'angolo è a zero, annullo in diametro per non fare il foro. + elseif tMhPar.FBD > 0 then + tMhPar.FBD = 0 + tMhPar.FBP = -1 + end + end + + -- se c'è il parametro delta Y delle mounting screw e la porta è a tirare, inverto il valore dell'offset + if tMhPar.PY8 then + if not DGD.Push or DGD.sFrame then + tMhPar.PY8 = - tMhPar.PY8 + end + end + if tMhPar.PY9 then + if not DGD.Push or DGD.sFrame then + tMhPar.PY9 = - tMhPar.PY9 + end + end + + -- se non c'è il parametro angolo strike face lo setto a 0 + if not tMhPar.AS then + tMhPar.AS = 0 + elseif abs(tMhPar.AS) > 45 then -- se supera max angolo consentito + tMhPar.AS = 45 + end + + -- se non c'è il parametro interasse strike face lo setto a 0 + if not tMhPar.IS then + tMhPar.IS = 0 + end + + -- se non c'è il parametro intersaase 1st mortise lo setto a 0 + if not tMhPar.I2 then + tMhPar.I2 = 0 + end + + -- se non c'è il parametro intersaase 2nd mortise lo setto a 0 + if not tMhPar.I3 then + tMhPar.I3 = 0 + end + + -- se la larghezza del dente è uguale o maggiore della lunghezza del face lo ricalcolo + if tMhPar.L and tMhPar.LS and tMhPar.LS >= tMhPar.L then + if tMhPar.LS > tMhPar.L then + tMhPar.LS = tMhPar.L + end + tMhPar.rf = 0 + tMhPar.rs = 0 + tMhPar.cl = 0 + tMhPar.D_SS = 0 + end + + -- se ci sono tutti i parametri del face e non c'è la distanza di partenza + if tMhPar.L and tMhPar.H and tMhPar.LS and tMhPar.LS > 0 and not tMhPar.D_SS then + tMhPar.D_SS = (tMhPar.L - tMhPar.IS - tMhPar.LS) / 2 + end + + -- se ci sono tutti i parametri del face e c'è la larghezza e l'altezza dello strike face lo ricalcolo in base allo spessore porta + if tMhPar.L and tMhPar.H and tMhPar.LS and tMhPar.LS > 0 and tMhPar.HS and tMhPar.HS > 0 then + if DGD.OFFSET and DGD.OFFSET > 0 then -- se c'è l'offset wide_side + -- si considera che lo strike esce sempre dal lato wide + tMhPar.HS = DGD.OFFSET-(tMhPar.H/2) + tMhPar.ls = true + if tMhPar.HS < 0 then -- se esce negativo è perchè il wide side è troppo poco + tMhPar.HS = 0 + tMhPar.ls = false + end + else -- se non c'è l'offset lo calcolo dal centro spessore + tMhPar.HS = (DGD.dT-tMhPar.H)/2 + tMhPar.ls = true + if tMhPar.HS < 0 then -- se esce negativo è perchè il wide side è troppo poco + tMhPar.HS = 0 + tMhPar.ls = false + end + end + else + tMhPar.HS = 0 + tMhPar.ls = false + end + + -- se c'è face strike ed ha bordi bevel + if tMhPar.ls then + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + tMhPar.mkrev = true -- assegno flag per creare percorso inverso + end + end + + -- se c'è la variabile CurrCamInfo che indica che la porta è disposta con il lato lock sul lato navetta + -- e il template non è sui lati top e bottom + if DGD.SDF and DGD.SDF > 1 then + + -- calcolo la posizione del centro foro sullo spessore porta + if dOffset > 0 then + tMhPar.posh = -(DGD.dT/2) + dOffset + else + tMhPar.posh = 0 + end + + if tMhPar.bev and not tMhPar.dl and not DGC.Fpd then + tMhPar.posh = tMhPar.posh / cos( 3) + end + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLM -- face machining + local nLMi = 1 + local sLA -- antisplint machining + local nLAi = 1 + local sLA2 -- 1st mortise machining + local nLA2i = 1 + local sLA3 -- 2nd mortise machining + local nLA3i = 1 + local sLGH -- bore machining + local nLGHi = 1 + local sLG -- face chiseling or face with other material + local nLGi = 1 + local sLMS1 -- mounting screws machining + local sLMS2 -- mounting screws machining + local nLMSi = 1 + local sLMP -- prebore machining + local nLMPi = 1 + local sASG -- anti-splint on extra rectangle + local nASGi = 1 + local sASGR -- anti-splint on antisplint + local nASGRi = 1 + + -- se porta steel o aluminum disabilito l'antischeggia, la svuotatura, il chisel e modifico il nome geometria + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.LM = nil + tMhPar.LA = nil + tMhPar.LA2 = nil + tMhPar.LA3 = nil + tMhPar.ech = false + tMhPar.CH = nil + tMhPar.est = true + tMhPar.da = nil + tMhPar.d2 = nil + tMhPar.ASG = 0 + tMhPar.EAR = nil + tMhPar.das = nil + else + tMhPar.est = nil + end + + -- devo considerare il profilo serratura e se eventualmente è opposto a quello cerniere + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- profilo serrratura bevel up + -- se lato cerniere opposto mi troverò il bevel al contrario perchè comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 3 + nLGi = 3 + nLAi = 3 + else + nLMi = 2 + nLGi = 2 + nLAi = 2 + end + elseif DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BDEB' then -- profilo serrratura bevel dn + -- se lato cerniere opposto mi troverò il bevel al contrario perchè comanda il lato cerniere + if DGD.bBothOppoBevel then + nLMi = 2 + nLGi = 2 + nLAi = 2 + else + nLMi = 3 + nLGi = 3 + nLAi = 3 + end + end + + if tMhPar.est and tMhPar.LG then -- se altro materiale + 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.ech and tMhPar.LG then -- se chisel abilitato + sLG = tMhPar.LG .. tMhPar.CH + tMhPar.d0 = 0 + if DGD.MachEn > 0 and tMhPar.d0 then nTempT0, dMaxMat0, sMchngName0 = MB.GetToolDataFromAttrib( sLG, nLGi) end + end + + if tMhPar.LA then -- antischeggia + sLA = tMhPar.LA + if DGD.MachEn > 0 and tMhPar.da then nTempTa, dMaxMata, sMchngNamea = MB.GetToolDataFromAttrib( sLA, nLAi) end + end + + if tMhPar.LA2 then -- prima mortasa + sLA2 = tMhPar.LA2 + if DGD.MachEn > 0 and tMhPar.d2 then nTempT2, dMaxMat2, sMchngName2 = MB.GetToolDataFromAttrib( sLA2, nLA2i) end + end + + if tMhPar.LA3 then -- seconda mortasa + sLA3 = tMhPar.LA3 + if DGD.MachEn > 0 and tMhPar.d3 then nTempT3, dMaxMat3, sMchngName3 = MB.GetToolDataFromAttrib( sLA3, nLA3i) end + end + + if tMhPar.mh and tMhPar.LGH then -- foro o foro profondo + sLGH = tMhPar.LGH + if DGD.MachEn > 0 then nTempT6, dMaxMat2, sMchngName6 = MB.GetToolDataFromAttrib( sLGH, nLGHi) end + end + + -- mounting screws + if tMhPar.LMS8 then + sLMS1 = tMhPar.LMS8 + if DGD.MachEn > 0 then nTempT4, dMaxMat4, sMchngName4 = MB.GetToolDataFromAttrib( sLMS1, nLMSi) end + end + if tMhPar.LMS9 then + sLMS2 = tMhPar.LMS9 + if DGD.MachEn > 0 then nTempT7, dMaxMat7, sMchngName7 = MB.GetToolDataFromAttrib( sLMS2, nLMSi) end + end + + -- preforo + if tMhPar.mh and tMhPar.LMP then + sLMP = tMhPar.LMP + if DGD.MachEn > 0 then nTempT5, dMaxMat5, sMchngName5 = MB.GetToolDataFromAttrib( sLMP, nLMPi) end + end + + -- extra bores + if tMhPar.T10 then + if tMhPar.T10 == -0.5 then + tMhPar.T10 = DGD.dT / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > DGD.dT then + tMhPar.T10 = DGD.dT + end + end + + if tMhPar.T11 then + if tMhPar.T11 == -0.5 then + tMhPar.T11 = DGD.dT / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > DGD.dT then + tMhPar.T11 = DGD.dT + end + end + + if tMhPar.T12 then + if tMhPar.T12 == -0.5 then + tMhPar.T12 = DGD.dT / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > DGD.dT then + tMhPar.T12 = DGD.dT + end + end + + if tMhPar.T13 then + if tMhPar.T13 == -0.5 then + tMhPar.T13 = DGD.dT / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > DGD.dT then + tMhPar.T13 = DGD.dT + end + end + + if tMhPar.T14 then + if tMhPar.T14 == -0.5 then + tMhPar.T14 = DGD.dT / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > DGD.dT then + tMhPar.T14 = DGD.dT + end + end + + if tMhPar.T15 then + if tMhPar.T15 == -0.5 then + tMhPar.T15 = DGD.dT / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > DGD.dT then + tMhPar.T15 = DGD.dT + end + end + + if tMhPar.T16 then + if tMhPar.T16 == -0.5 then + tMhPar.T16 = DGD.dT / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > DGD.dT then + tMhPar.T16 = DGD.dT + end + end + + if tMhPar.T17 then + if tMhPar.T17 == -0.5 then + tMhPar.T17 = DGD.dT / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > DGD.dT then + tMhPar.T17 = DGD.dT + end + end + + if tMhPar.T18 then + if tMhPar.T18 == -0.5 then + tMhPar.T18 = DGD.dT / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > DGD.dT then + tMhPar.T18 = DGD.dT + end + end + + if tMhPar.T19 then + if tMhPar.T19 == -0.5 then + tMhPar.T19 = DGD.dT / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > DGD.dT then + tMhPar.T19 = DGD.dT + end + end + + if tMhPar.T20 then + if tMhPar.T20 == -0.5 then + tMhPar.T20 = DGD.dT / 2 + elseif tMhPar.T20 == -1 or tMhPar.T20 > DGD.dT then + tMhPar.T20 = DGD.dT + end + end + + if tMhPar.T21 then + if tMhPar.T21 == -0.5 then + tMhPar.T21 = DGD.dT / 2 + elseif tMhPar.T21 == -1 or tMhPar.T21 > DGD.dT then + tMhPar.T21 = DGD.dT + end + end + + if tMhPar.T22 then + if tMhPar.T22 == -0.5 then + tMhPar.T22 = DGD.dT / 2 + elseif tMhPar.T22 == -1 or tMhPar.T22 > DGD.dT then + tMhPar.T22 = DGD.dT + end + end + + if tMhPar.T23 then + if tMhPar.T23 == -0.5 then + tMhPar.T23 = DGD.dT / 2 + elseif tMhPar.T23 == -1 or tMhPar.T23 > DGD.dT then + tMhPar.T23 = DGD.dT + end + end + + if tMhPar.T24 then + if tMhPar.T24 == -0.5 then + tMhPar.T24 = DGD.dT / 2 + elseif tMhPar.T24 == -1 or tMhPar.T24 > DGD.dT then + tMhPar.T24 = DGD.dT + end + end + + if tMhPar.T25 then + if tMhPar.T25 == -0.5 then + tMhPar.T25 = DGD.dT / 2 + elseif tMhPar.T25 == -1 or tMhPar.T25 > DGD.dT then + tMhPar.T25 = DGD.dT + end + end + + if tMhPar.T26 then + if tMhPar.T26 == -0.5 then + tMhPar.T26 = DGD.dT / 2 + elseif tMhPar.T26 == -1 or tMhPar.T26 > DGD.dT then + tMhPar.T26 = DGD.dT + end + end + + if tMhPar.T27 then + if tMhPar.T27 == -0.5 then + tMhPar.T27 = DGD.dT / 2 + elseif tMhPar.T27 == -1 or tMhPar.T27 > DGD.dT then + tMhPar.T27 = DGD.dT + end + end + + if tMhPar.T28 then + if tMhPar.T28 == -0.5 then + tMhPar.T28 = DGD.dT / 2 + elseif tMhPar.T28 == -1 or tMhPar.T28 > DGD.dT then + tMhPar.T28 = DGD.dT + end + end + + if tMhPar.T29 then + if tMhPar.T29 == -0.5 then + tMhPar.T29 = DGD.dT / 2 + elseif tMhPar.T29 == -1 or tMhPar.T29 > DGD.dT then + tMhPar.T29 = DGD.dT + end + end + + -- extra rectangles + if tMhPar.TR10 then + if tMhPar.TR10 == -0.5 then + tMhPar.TR10 = DGD.dT / 2 + elseif tMhPar.TR10 == -1 or tMhPar.TR10 > DGD.dT then + tMhPar.TR10 = DGD.dT + end + end + + if tMhPar.TR11 then + if tMhPar.TR11 == -0.5 then + tMhPar.TR11 = DGD.dT / 2 + elseif tMhPar.TR11 == -1 or tMhPar.TR11 > DGD.dT then + tMhPar.TR11 = DGD.dT + end + end + + if tMhPar.TR12 then + if tMhPar.TR12 == -0.5 then + tMhPar.TR12 = DGD.dT / 2 + elseif tMhPar.TR12 == -1 or tMhPar.TR12 > DGD.dT then + tMhPar.TR12 = DGD.dT + end + end + + if tMhPar.TR13 then + if tMhPar.TR13 == -0.5 then + tMhPar.TR13 = DGD.dT / 2 + elseif tMhPar.TR13 == -1 or tMhPar.TR13 > DGD.dT then + tMhPar.TR13 = DGD.dT + end + end + + if tMhPar.TR14 then + if tMhPar.TR14 == -0.5 then + tMhPar.TR14 = DGD.dT / 2 + elseif tMhPar.TR14 == -1 or tMhPar.TR14 > DGD.dT then + tMhPar.TR14 = DGD.dT + end + end + + if tMhPar.TR20 then + if tMhPar.TR20 == -0.5 then + tMhPar.TR20 = DGD.dT / 2 + elseif tMhPar.TR20 == -1 or tMhPar.TR20 > DGD.dT then + tMhPar.TR20 = DGD.dT + end + end + + if tMhPar.TR21 then + if tMhPar.TR21 == -0.5 then + tMhPar.TR21 = DGD.dT / 2 + elseif tMhPar.TR21 == -1 or tMhPar.TR21 > DGD.dT then + tMhPar.TR21 = DGD.dT + end + end + + if tMhPar.TR22 then + if tMhPar.TR22 == -0.5 then + tMhPar.TR22 = DGD.dT / 2 + elseif tMhPar.TR22 == -1 or tMhPar.TR22 > DGD.dT then + tMhPar.TR22 = DGD.dT + end + end + + if tMhPar.TR23 then + if tMhPar.TR23 == -0.5 then + tMhPar.TR23 = DGD.dT / 2 + elseif tMhPar.TR23 == -1 or tMhPar.TR23 > DGD.dT then + tMhPar.TR23 = DGD.dT + end + end + + if tMhPar.TR24 then + if tMhPar.TR24 == -0.5 then + tMhPar.TR24 = DGD.dT / 2 + elseif tMhPar.TR24 == -1 or tMhPar.TR24 > DGD.dT then + tMhPar.TR24 = DGD.dT + end + end + + -- Anti-splint su rettangoli + if DGD.MachEn > 0 and tMhPar.ASG and tMhPar.EAR and + ( ( tMhPar.TR10 and tMhPar.TR10 > GEO.EPS_SMALL) or ( tMhPar.TR11 and tMhPar.TR11 > GEO.EPS_SMALL) or ( tMhPar.TR12 and tMhPar.TR12 > GEO.EPS_SMALL) or + ( tMhPar.TR13 and tMhPar.TR13 > GEO.EPS_SMALL) or ( tMhPar.TR14 and tMhPar.TR14 > GEO.EPS_SMALL) or ( tMhPar.TR20 and tMhPar.TR20 > GEO.EPS_SMALL) or + ( tMhPar.TR21 and tMhPar.TR21 > GEO.EPS_SMALL) or ( tMhPar.TR22 and tMhPar.TR22 > GEO.EPS_SMALL) or ( tMhPar.TR23 and tMhPar.TR23 > GEO.EPS_SMALL) or + ( tMhPar.TR24 and tMhPar.TR24 > GEO.EPS_SMALL)) then + sASG = tMhPar.ASG + nTempT8, dMaxMat8, sMchngName8 = MB.GetToolDataFromAttrib( sASG, nASGi) + end + + -- Anti-splint su Anti-splint + if DGD.MachEn > 0 and tMhPar.EAR and tMhPar.EAR == 2 and sASG then + sASGR = tMhPar.ASG..'_R' + tMhPar.ASGR = sASGR + tMhPar.das2 = tMhPar.das + nTempT9, dMaxMat9, sMchngName9 = MB.GetToolDataFromAttrib( sASGR, nASGRi) + end + + -- extra lines + if tMhPar.TL10 then + if tMhPar.TL10 == -0.5 then + tMhPar.TL10 = DGD.dT / 2 + elseif tMhPar.TL10 == -1 or tMhPar.TL10 > DGD.dT then + tMhPar.TL10 = DGD.dT + end + end + + if tMhPar.TL11 then + if tMhPar.TL11 == -0.5 then + tMhPar.TL11 = DGD.dT / 2 + elseif tMhPar.TL11 == -1 or tMhPar.TL11 > DGD.dT then + tMhPar.TL11 = DGD.dT + end + end + + if tMhPar.TL12 then + if tMhPar.TL12 == -0.5 then + tMhPar.TL12 = DGD.dT / 2 + elseif tMhPar.TL12 == -1 or tMhPar.TL12 > DGD.dT then + tMhPar.TL12 = DGD.dT + end + end + + if tMhPar.TL13 then + if tMhPar.TL13 == -0.5 then + tMhPar.TL13 = DGD.dT / 2 + elseif tMhPar.TL13 == -1 or tMhPar.TL13 > DGD.dT then + tMhPar.TL13 = DGD.dT + end + end + + if tMhPar.TL14 then + if tMhPar.TL14 == -0.5 then + tMhPar.TL14 = DGD.dT / 2 + elseif tMhPar.TL14 == -1 or tMhPar.TL14 > DGD.dT then + tMhPar.TL14 = DGD.dT + end + end + + if tMhPar.TL20 then + if tMhPar.TL20 == -0.5 then + tMhPar.TL20 = DGD.dT / 2 + elseif tMhPar.TL20 == -1 or tMhPar.TL20 > DGD.dT then + tMhPar.TL20 = DGD.dT + end + end + + if tMhPar.TL21 then + if tMhPar.TL21 == -0.5 then + tMhPar.TL21 = DGD.dT / 2 + elseif tMhPar.TL21 == -1 or tMhPar.TL21 > DGD.dT then + tMhPar.TL21 = DGD.dT + end + end + + if tMhPar.TL22 then + if tMhPar.TL22 == -0.5 then + tMhPar.TL22 = DGD.dT / 2 + elseif tMhPar.TL22 == -1 or tMhPar.TL22 > DGD.dT then + tMhPar.TL22 = DGD.dT + end + end + + if tMhPar.TL23 then + if tMhPar.TL23 == -0.5 then + tMhPar.TL23 = DGD.dT / 2 + elseif tMhPar.TL23 == -1 or tMhPar.TL23 > DGD.dT then + tMhPar.TL23 = DGD.dT + end + end + + if tMhPar.TL24 then + if tMhPar.TL24 == -0.5 then + tMhPar.TL24 = DGD.dT / 2 + elseif tMhPar.TL24 == -1 or tMhPar.TL24 > DGD.dT then + tMhPar.TL24 = DGD.dT + end + end + + -- percorso custom nge + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + 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 <= 0 then + dNumLog = -2697 + 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 + -------------------------------------------------------------------------------- + -- gestisco il risultato della lettura utensili per face machining + if DGD.bProoduce and not tMhPar.est and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sLM, nLMi, tMhPar.d, dNumLog, sMchngName1) + elseif not tMhPar.est and nTempT1 then + tMhPar.d = nTempT1 + end + + -- gestisco il risultato della lettura utensili per anti-splint machining + if DGD.bProoduce and not tMhPar.est and tMhPar.da and nTempTa and nTempTa <= 0 then + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempTa, sLA, nLAi, tMhPar.da, dNumLog, sMchngNamea) + elseif not tMhPar.est and nTempTa then + tMhPar.da = nTempTa + end + + -- gestisco il risultato della lettura utensili per 1st mortise machining + if not tMhPar.est and tMhPar.d2 and nTempT2 and nTempT2 <= 0 then + if DGD.bProoduce and not tMhPar.jn then -- se non si concatenano i due percorsi + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sLA2, nLA2i, tMhPar.d2, dNumLog, sMchngName2) + end + elseif not tMhPar.est and nTempT2 then + tMhPar.d2 = nTempT2 + end + + -- gestisco il risultato della lettura utensili per 2nd mortise machining + if not tMhPar.est and tMhPar.d3 and nTempT3 and nTempT3 <= 0 then + if DGD.bProoduce and not tMhPar.jn2 then -- se non si concatenano i due percorsi + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sLA3, nLA3i, tMhPar.d3, dNumLog, sMchngName3) + end + elseif not tMhPar.est and nTempT3 then + tMhPar.d3 = nTempT3 + end + + -- gestisco il risultato della lettura utensili per antischeggia su extra rettangoli + if DGD.bProoduce and not tMhPar.est and tMhPar.das and nTempT8 and nTempT8 <= 0 then + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT8, sASG, nASGi, tMhPar.das, dNumLog, sMchngName8) + elseif not tMhPar.est and nTempT8 then + tMhPar.das = nTempT8 + end + + -- gestisco il risultato della lettura utensili per antischeggia su antischeggia + if DGD.bProoduce and not tMhPar.est and tMhPar.das2 and nTempT9 and nTempT9 <= 0 then + dNumLog = -2690 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT9, sASGR, nASGRi, tMhPar.das2, dNumLog, sMchngName9) + elseif not tMhPar.est and nTempT9 then + tMhPar.das2 = nTempT9 + end + + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per foro profondo + if DGD.bProoduce and tMhPar.mh and tMhPar.LGH and not dMaxMat2 then + dNumLog = -2689 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT6, sLGH, nLGHi, nil, dNumLog, sMchngName6) + end + + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per preforo + if DGD.bProoduce and tMhPar.mh and tMhPar.LMP and not dMaxMat5 then + dNumLog = -2689 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT5, sLMP, nLMPi, nil, dNumLog, sMchngName5) + end + + -- se non ho parametro di lunghezza massima utensile preparo messaggio di warning per mounting screw + if DGD.bProoduce and sLMS1 and not dMaxMat4 then + dNumLog = -2688 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT4, sLMS1, nLMSi, nil, dNumLog, sMchngName4) + end + if DGD.bProoduce and sLMS2 and not dMaxMat7 then + dNumLog = -2688 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT7, sLMS2, nLMSi, nil, dNumLog, sMchngName7) + end + + -- chiseling + if tMhPar.ech and tMhPar.d0 and nTempT0 > 0 then + tMhPar.d0 = nTempT0 + 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 = -2687 + 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 = -2698 + dNumMessage = 460 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat1)) + tMhPar.T = dMaxMat1 - 0.02 -- tolgo 0.05 per permettere la lavorazione + end + + -- se mortise concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and ( not tMhPar.mh or ( tMhPar.mh and tMhPar.TB2)) and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -2696 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 - 0.02 + end + + -- se mortise non concatenata a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if ( not tMhPar.jn or not tMhPar.jnb) and not tMhPar.mh and + tMhPar.T2 and dMaxMat2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -2695 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 - 0.02 + end + + -- se foro e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and dMaxMat2 then + if tMhPar.TB2 and tMhPar.TB2 > dMaxMat2 then + dNumLog = -2695 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(dMaxMat2)) + tMhPar.TB2 = dMaxMat2 + elseif tMhPar.T2 and not tMhPar.L2 and tMhPar.T2 > dMaxMat2 then + dNumLog = -2695 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat2)) + tMhPar.T2 = dMaxMat2 + end + end + + -- se preforo e la sua profondità è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.mh and dMaxMat5 and + tMhPar.FBP and tMhPar.FBP > dMaxMat5 then + dNumLog = -2695 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.FBP), EgtToUiUnits(dMaxMat5)) + tMhPar.FBP = dMaxMat5 + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T8 and dMaxMat4 and tMhPar.T8 > dMaxMat4 then + dNumLog = -2691 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T8), EgtToUiUnits(dMaxMat4)) + tMhPar.T8 = dMaxMat4 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se la profondità dei mounting screws è maggiore della capacità utensile limito la profondità ed emetto un warning + if tMhPar.T9 and dMaxMat7 and tMhPar.T9 > dMaxMat7 then + dNumLog = -2691 + dNumMessage = 463 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T9), EgtToUiUnits(dMaxMat7)) + tMhPar.T9 = dMaxMat7 - 0.02 -- tolgo 0.02 per permettere la lavorazione + end + + -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and + tMhPar.T2 and dMaxMat1 and tMhPar.T2 > dMaxMat1 then + dNumLog = -2694 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T2), EgtToUiUnits(dMaxMat1)) + tMhPar.T2 = dMaxMat1 - 0.02 + end + + -- se tutte le mortise concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and tMhPar.jnb and + tMhPar.T3 and dMaxMat1 and tMhPar.T3 > dMaxMat1 then + dNumLog = -2693 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat1)) + tMhPar.T3 = dMaxMat1 + end + + -- se solo le mortise concatenate a face e la profondità della seconda mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and tMhPar.jn2 and not tMhPar.mh and + tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then + dNumLog = -2692 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) + tMhPar.T3 = dMaxMat2 + end + + -- se nessuna mortise è concatenate a face e la profondità della mortise è maggiore della capacità utensile, + -- limito la profondità ed emetto un warning + if not tMhPar.jn and not tMhPar.jn2 and + tMhPar.T3 and dMaxMat2 and tMhPar.T3 > dMaxMat2 then + dNumLog = -2691 + dNumMessage = 461 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T3), EgtToUiUnits(dMaxMat2)) + tMhPar.T3 = dMaxMat2 + end + + -- Raggio: se altro materiale e raggio presente e raggio minore del diametro utensile + delta, lo annullo + if tMhPar.est and tMhPar.rf and tMhPar.rf > 0 and tMhPar.cl > 0 and tMhPar.d and tMhPar.rf < ((tMhPar.d/2)+0.02) then + tMhPar.rf = 0 + end + + if tMhPar.CLC and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.H or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CLC then + tMhPar.clc = nil + 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.dThD or abs( abs(tMhPar.T) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T', EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T2 and ( abs(tMhPar.T2) > tMhPar.dThD or abs( abs(tMhPar.T2) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T2', EgtToUiUnits(tMhPar.T2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T2 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T3 and ( abs(tMhPar.T3) > tMhPar.dThD or abs( abs(tMhPar.T3) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T3', EgtToUiUnits(tMhPar.T3), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T3 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T8 and ( abs(tMhPar.T8) > tMhPar.dThD or abs( abs(tMhPar.T8) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T8', EgtToUiUnits(tMhPar.T8), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T8 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.T9 and ( abs(tMhPar.T9) > tMhPar.dThD or abs( abs(tMhPar.T9) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'T9', EgtToUiUnits(tMhPar.T9), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.T9 = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.FBP and ( abs(tMhPar.FBP) > tMhPar.dThD or abs( abs(tMhPar.FBP) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'FBP', EgtToUiUnits(tMhPar.FBP), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.FBP = tMhPar.TTP + end + if tMhPar.Dws and DGD.Spd > 0 and tMhPar.TB2 and ( abs(tMhPar.TB2) > tMhPar.dThD or abs( abs(tMhPar.TB2) - tMhPar.dThD) < DGD.Spd) then + dNumLog = -2686 + dNumMessage = 681 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sPieceName, 'TB2', EgtToUiUnits(tMhPar.TB2), EgtToUiUnits(tMhPar.TTP), EgtToUiUnits(tMhPar.dThD)) + tMhPar.TB2 = tMhPar.TTP + end + + if tMhPar.T and tMhPar.T > 0 and tMhPar.ls then + -- Se c'è il profilo bevel e la geometria è applicata al lato lock + if ( DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB') and + ( not DGD.SIDE or string.lower(DGD.SIDE) == 'lock') then + -- Se il parametro per impedire la rotazione sul lato bevel non è attivo + if not tMhPar.dl then + tMhPar.fht = tMhPar.T / cos(3) + else + tMhPar.fht = tMhPar.T + end + -- considerando l'angolo calcolo l'ingombro totale riferito al lato wide + tMhPar.fhb = tMhPar.fht + ( DGD.dT * TAN3) + else + tMhPar.fht = tMhPar.T + tMhPar.fhb = tMhPar.fht + end + 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 Strike.Draw( tLckP, bPreview, bRunByCompo, nDrawMach, dThickDoor) + + -- Assegno le dimensioni geometria + local L = tLckP.L -- lunghezza face + local H = tLckP.H -- larghezza face + local T = tLckP.T -- spessore face + local LS = tLckP.LS -- lunghezza strike face + local HS = tLckP.HS -- altezza strike face + local AS = tLckP.AS -- angolo strike face + local IS = tLckP.IS -- interasse strike face + local D_SS = tLckP.D_SS -- distanza partenza srike + local rs = tLckP.rs -- raggio arrotondamento strike + local ls = tLckP.ls -- latch strike + local cl = tLckP.cl -- arrotonda estremità face, 0: nessun arrotondamento, 1: arrotonda a sinistra, + -- 2: arrotonda a destra, 3: arrotonda entrambe i lati + local rf = tLckP.rf -- raggio arrotondamento face + local clc = tLckP.clc + local ccr = tLckP.ccr + local d = tLckP.d -- diametro utensile face + local p = tLckP.p -- percentuale uso utensile face + local sf = tLckP.sf -- passo affondamento face + local dl = tLckP.dl -- disponi face come lock, cioè non ruotata su bevel + local da = tLckP.da -- diametro utensile anti-splint + local ech = tLckP.ech -- abilitazione chisel + local est = tLckP.est -- altro materiale trovato + local mh = tLckP.mh -- crea foro: true o mortasa: false + local L2 = tLckP.L2 -- lunghezza mortasa (seconda cava) + local H2 = tLckP.H2 -- larghezza mortasa o diametro foro + local T2 = tLckP.T2 -- profondità mortasa o foro + local I2 = tLckP.I2 -- intersasse mortasa + local HB2 = tLckP.HB2 -- diametro foro orizzontale + local TB2 = tLckP.TB2 -- profondità foro orizzontale + local d2 = tLckP.d2 -- diametro utensile svuotatura mortasa ( non per foro) + local p2 = tLckP.p2 -- percentuale uso utensile mortasa + local s = tLckP.s -- passo affondamento mortasa + local FBD = tLckP.FBD -- diametro preforo + local FBP = tLckP.FBP -- profondità preforo + local AB = tLckP.AB -- angolo fori + local L3 = tLckP.L3 -- lunghezza seconda mortasa ( terza cava) + local H3 = tLckP.H3 -- larghezza seconda mortasa ( terza cava) + local T3 = tLckP.T3 -- profondità seconda mortasa ( terza cava) + local I3 = tLckP.I3 -- intersasse seconda mortasa + local d3 = tLckP.d3 -- diametro utensile svuotatura seconda mortasa + local p3 = tLckP.p3 -- percentuale uso utensile seconda mortasa + local s3 = tLckP.s3 -- passo affondamento seconda mortasa + -- tabelle per i viti fissaggio (mounting screw) + local tMountingScrew = {} + -- inserimento dati nella tabella fori + table.insert( tMountingScrew, { tLckP.D8, tLckP.T8, tLckP.I8, tLckP.IY8, tLckP.mcs8, tLckP.mss8, tLckP.PX8C, tLckP.PX8, tLckP.PY8, tLckP.LMS8}) + table.insert( tMountingScrew, { tLckP.D9, tLckP.T9, tLckP.I9, tLckP.IY9, tLckP.mcs9, tLckP.mss9, tLckP.PX9C, tLckP.PX9, tLckP.PY9, tLckP.LMS9}) + local kbs = tLckP.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tLckP.pbs -- Probe on side, 0 = none, 1 = only face geometries, 2 = all + local mkrev = tLckP.mkrev -- flag creazione inversione percorsi + local SL = tLckP.SL + local fht = tLckP.fht + local fhb = tLckP.fhb + local drf = tLckP.drf + local dws = tLckP.Dws + local dthd = tLckP.dThD + -- gestione inversione percorsi + local invG = tLckP.invG -- flag per invertire il senso dei percorsi di lavorazione + -- Assegno i flag + local jn = tLckP.jn -- flag per giunzione prima cava face con seconda cava (mortasa) + local jn2 = tLckP.jn2 -- flag per giunzione seconda cava (mortasa) con terza cava ( seconda mortasa) + local jnb = tLckP.jnb -- flag che indica se profilo tipo bevel o meno + -- Inserimento geometrie probe + local posh = tLckP.posh -- posizione in Y del foro di tastatura + local posp = tLckP.posp -- posizione in X del foro di tastatura + -- Disassamento delle 2 cave rispetto alla face + local D_X = tLckP.D_X -- disassamento seconda cava (mortasa o foro) da centro lunghezza face + local D_X3 = tLckP.D_X3 -- disassamento terza cava (seconda mortasa) da centro lunghezza face + -- Disassamento dei fori rispetto al face + local DH_X = tLckP.DH_X -- disassamento fori da centro lunghezza face + -- Disassamento globale + local D_XE = tLckP.D_XE -- Extra delta on X pos for all geometries + -- Nome file custom geometry e percorso file da caricare + local CustGeomFile = tLckP.CGF or '' + local CustGeomPath = tLckP.CGP or '' + -- Anti-splint su extra rectangle geometry + local EAR = tLckP.EAR + local das = tLckP.das + local ASG = tLckP.ASG + -- Second anti-splint on extra rectangle geometry + local das2 = tLckP.das2 + local ASGR = tLckP.ASGR + -- tabelle per i fori, rettangoli e linee opzionali + local tExtraBore = {} + local tExtraRect = {} + local tExtraLine = {} + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D10, tLckP.T10, tLckP.PX10, tLckP.PY10, tLckP.EB10, tLckP.RBS10}) + table.insert( tExtraBore, { tLckP.D11, tLckP.T11, tLckP.PX11, tLckP.PY11, tLckP.EB11, tLckP.RBS11}) + table.insert( tExtraBore, { tLckP.D12, tLckP.T12, tLckP.PX12, tLckP.PY12, tLckP.EB12, tLckP.RBS12}) + table.insert( tExtraBore, { tLckP.D13, tLckP.T13, tLckP.PX13, tLckP.PY13, tLckP.EB13, tLckP.RBS13}) + table.insert( tExtraBore, { tLckP.D14, tLckP.T14, tLckP.PX14, tLckP.PY14, tLckP.EB14, tLckP.RBS14}) + table.insert( tExtraBore, { tLckP.D15, tLckP.T15, tLckP.PX15, tLckP.PY15, tLckP.EB15, tLckP.RBS15}) + table.insert( tExtraBore, { tLckP.D16, tLckP.T16, tLckP.PX16, tLckP.PY16, tLckP.EB16, tLckP.RBS16}) + table.insert( tExtraBore, { tLckP.D17, tLckP.T17, tLckP.PX17, tLckP.PY17, tLckP.EB17, tLckP.RBS17}) + table.insert( tExtraBore, { tLckP.D18, tLckP.T18, tLckP.PX18, tLckP.PY18, tLckP.EB18, tLckP.RBS18}) + table.insert( tExtraBore, { tLckP.D19, tLckP.T19, tLckP.PX19, tLckP.PY19, tLckP.EB19, tLckP.RBS19}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR10, tLckP.WR10, tLckP.RR10, tLckP.TR10, tLckP.PRX10, tLckP.PRY10, tLckP.AR10, tLckP.ER10, tLckP.RRS10}) + table.insert( tExtraRect, { tLckP.LR11, tLckP.WR11, tLckP.RR11, tLckP.TR11, tLckP.PRX11, tLckP.PRY11, tLckP.AR11, tLckP.ER11, tLckP.RRS11}) + table.insert( tExtraRect, { tLckP.LR12, tLckP.WR12, tLckP.RR12, tLckP.TR12, tLckP.PRX12, tLckP.PRY12, tLckP.AR12, tLckP.ER12, tLckP.RRS12}) + table.insert( tExtraRect, { tLckP.LR13, tLckP.WR13, tLckP.RR13, tLckP.TR13, tLckP.PRX13, tLckP.PRY13, tLckP.AR13, tLckP.ER13, tLckP.RRS13}) + table.insert( tExtraRect, { tLckP.LR14, tLckP.WR14, tLckP.RR14, tLckP.TR14, tLckP.PRX14, tLckP.PRY14, tLckP.AR14, tLckP.ER14, tLckP.RRS14}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL10, tLckP.TL10, tLckP.PLX10, tLckP.PLY10, tLckP.AL10, tLckP.EL10, tLckP.RLS10}) + table.insert( tExtraLine, { tLckP.LL11, tLckP.TL11, tLckP.PLX11, tLckP.PLY11, tLckP.AL11, tLckP.EL11, tLckP.RLS11}) + table.insert( tExtraLine, { tLckP.LL12, tLckP.TL12, tLckP.PLX12, tLckP.PLY12, tLckP.AL12, tLckP.EL12, tLckP.RLS12}) + table.insert( tExtraLine, { tLckP.LL13, tLckP.TL13, tLckP.PLX13, tLckP.PLY13, tLckP.AL13, tLckP.EL13, tLckP.RLS13}) + table.insert( tExtraLine, { tLckP.LL14, tLckP.TL14, tLckP.PLX14, tLckP.PLY14, tLckP.AL14, tLckP.EL14, tLckP.RLS14}) + -- inserimento dati nella tabella fori + table.insert( tExtraBore, { tLckP.D20, tLckP.T20, tLckP.PX20, tLckP.PY20, tLckP.EB20, tLckP.RBS20}) + table.insert( tExtraBore, { tLckP.D21, tLckP.T21, tLckP.PX21, tLckP.PY21, tLckP.EB21, tLckP.RBS21}) + table.insert( tExtraBore, { tLckP.D22, tLckP.T22, tLckP.PX22, tLckP.PY22, tLckP.EB22, tLckP.RBS22}) + table.insert( tExtraBore, { tLckP.D23, tLckP.T23, tLckP.PX23, tLckP.PY23, tLckP.EB23, tLckP.RBS23}) + table.insert( tExtraBore, { tLckP.D24, tLckP.T24, tLckP.PX24, tLckP.PY24, tLckP.EB24, tLckP.RBS24}) + table.insert( tExtraBore, { tLckP.D25, tLckP.T25, tLckP.PX25, tLckP.PY25, tLckP.EB25, tLckP.RBS25}) + table.insert( tExtraBore, { tLckP.D26, tLckP.T26, tLckP.PX26, tLckP.PY26, tLckP.EB26, tLckP.RBS26}) + table.insert( tExtraBore, { tLckP.D27, tLckP.T27, tLckP.PX27, tLckP.PY27, tLckP.EB27, tLckP.RBS27}) + table.insert( tExtraBore, { tLckP.D28, tLckP.T28, tLckP.PX28, tLckP.PY28, tLckP.EB28, tLckP.RBS28}) + table.insert( tExtraBore, { tLckP.D29, tLckP.T29, tLckP.PX29, tLckP.PY29, tLckP.EB29, tLckP.RBS29}) + -- inserimento dati nella tabella rettangoli + table.insert( tExtraRect, { tLckP.LR20, tLckP.WR20, tLckP.RR20, tLckP.TR20, tLckP.PRX20, tLckP.PRY20, tLckP.AR20, tLckP.ER20, tLckP.RRS20}) + table.insert( tExtraRect, { tLckP.LR21, tLckP.WR21, tLckP.RR21, tLckP.TR21, tLckP.PRX21, tLckP.PRY21, tLckP.AR21, tLckP.ER21, tLckP.RRS21}) + table.insert( tExtraRect, { tLckP.LR22, tLckP.WR22, tLckP.RR22, tLckP.TR22, tLckP.PRX22, tLckP.PRY22, tLckP.AR22, tLckP.ER22, tLckP.RRS22}) + table.insert( tExtraRect, { tLckP.LR23, tLckP.WR23, tLckP.RR23, tLckP.TR23, tLckP.PRX23, tLckP.PRY23, tLckP.AR23, tLckP.ER23, tLckP.RRS23}) + table.insert( tExtraRect, { tLckP.LR24, tLckP.WR24, tLckP.RR24, tLckP.TR24, tLckP.PRX24, tLckP.PRY24, tLckP.AR24, tLckP.ER24, tLckP.RRS24}) + -- inserimento dati nella tabella linee + table.insert( tExtraLine, { tLckP.LL20, tLckP.TL20, tLckP.PLX20, tLckP.PLY20, tLckP.AL20, tLckP.EL20, tLckP.RLS20}) + table.insert( tExtraLine, { tLckP.LL21, tLckP.TL21, tLckP.PLX21, tLckP.PLY21, tLckP.AL21, tLckP.EL21, tLckP.RLS21}) + table.insert( tExtraLine, { tLckP.LL22, tLckP.TL22, tLckP.PLX22, tLckP.PLY22, tLckP.AL22, tLckP.EL22, tLckP.RLS22}) + table.insert( tExtraLine, { tLckP.LL23, tLckP.TL23, tLckP.PLX23, tLckP.PLY23, tLckP.AL23, tLckP.EL23, tLckP.RLS23}) + table.insert( tExtraLine, { tLckP.LL24, tLckP.TL24, tLckP.PLX24, tLckP.PLY24, tLckP.AL24, tLckP.EL24, tLckP.RLS24}) + -- Assegno le label degli attributi fianco porta + local LG = tLckP.LG -- nome geometria face: per la doppia face, la prima geometria è LG..'1st' + local LG2 = tLckP.LG2 -- nome geometria seconda cava (mortasa) + local LG3 = tLckP.LG3 -- nome geometria terza cava (seconda mortasa) + local LM = tLckP.LM -- nome geometria lavorazione face: per la doppia face, la prima geometria è LM..'1st' + local LA = tLckP.LA -- nome geometria lavorazione antischeggia + local LA2 = tLckP.LA2 -- nome geometria lavorazione seconda cava (mortasa) + local LA3 = tLckP.LA3 -- nome geometria lavorazione terza cava (seconda mortasa) + local CH = tLckP.CH -- nome suffisso lavorazione chisel + local CLC = tLckP.CLC -- nome geometria clean corner + -- Assegno le label alla geometria foro profondo di lato + local LGH = tLckP.LGH -- nome geometria seconda cava (foro) + local LMP = tLckP.LMP -- nome geometrie precut bore + -- variabile nome geometrie probe + local LH = 'Shuttle_Probe' + -- variabili per messaggi e settaggi vari + local sCompoName = tLckP.Nome + local nCompoNpar = tLckP.Npar + local sCompoPath = tLckP.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tLckP.nCod + local sCodAdj = tLckP.sCod + -- variabili per messaggi di errore + local tsNamePar = {} + table.insert( tsNamePar, tLckP.NPL or 'L') + table.insert( tsNamePar, tLckP.NPH or 'H') + table.insert( tsNamePar, tLckP.NPT or 'T') + table.insert( tsNamePar, tLckP.NPd or 'd') + table.insert( tsNamePar, tLckP.NPp or 'p') -- 5 + table.insert( tsNamePar, tLckP.NPLS or 'LS') + table.insert( tsNamePar, tLckP.NL2 or 'L2') + table.insert( tsNamePar, tLckP.NT2 or 'T2') + table.insert( tsNamePar, tLckP.NPd2 or 'd2') + table.insert( tsNamePar, tLckP.NPp2 or 'p2') -- 10 + table.insert( tsNamePar, tLckP.NPS or 's') + table.insert( tsNamePar, tLckP.NPH2 or 'H2') + table.insert( tsNamePar, tLckP.NPHS or 'HS') + table.insert( tsNamePar, tLckP.NL3 or 'L3') + table.insert( tsNamePar, tLckP.NL3 or 'H3') -- 15 + table.insert( tsNamePar, tLckP.NT3 or 'T3') + table.insert( tsNamePar, tLckP.NPd3 or 'd3') + table.insert( tsNamePar, tLckP.NPp3 or 'p3') + table.insert( tsNamePar, tLckP.NPS3 or 's3') + table.insert( tsNamePar, tLckP.NPD_X or 'D_X') -- 20 + table.insert( tsNamePar, tLckP.NPD_X3 or 'D_X3') + table.insert( tsNamePar, tLckP.NPAS or 'AS') + table.insert( tsNamePar, tLckP.NPIS or 'IS') + table.insert( tsNamePar, tLckP.NPDS or 'D_SS') + table.insert( tsNamePar, tLckP.NPRS or 'rs') -- 25 + table.insert( tsNamePar, tLckP.NPDL or 'dl') + table.insert( tsNamePar, tLckP.NPDA or 'da') + table.insert( tsNamePar, tLckP.NPI2 or 'I2') + table.insert( tsNamePar, tLckP.NPHB2 or 'HB2') + table.insert( tsNamePar, tLckP.NPTB2 or 'TB2') -- 30 + table.insert( tsNamePar, tLckP.NPFBD or 'FBD') + table.insert( tsNamePar, tLckP.NPFBP or 'FBP') + table.insert( tsNamePar, tLckP.NPI2 or 'I3') + table.insert( tsNamePar, tLckP.NPSF or 'sf') + table.insert( tsNamePar, tLckP.NPRF or 'rf') -- 35 + table.insert( tsNamePar, tLckP.N50 or 'clc') + table.insert( tsNamePar, tLckP.N51 or 'ccr') + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 2600 + -- variabili che abilitano la creazione della geometria + local bMakeFaceGeom = true + local bMakeMortGeom = true + local bMakeBoreGeom = true + local bMakeMortGeom2nd = true + + if not bRunByCompo then + RC = false + end + + -- verifico se dei parametri sono nulli e in qual caso assegno dei valori sostitutivi + if not L or not H then + bMakeFaceGeom = false + jn = false -- disattivo il join tra face e mortasa + clc = nil + CLC = nil + end + + -- se le dimensioni del raccordo sono eccessive le riconduco a valori accettabili + if bMakeFaceGeom and cl and cl > 0 then + if L >= H then + if rf > (H/2) then + rf = (H/2) + end + else + if rf > (L/2) then + rf = (L/2) + end + end + end + + -- se rilevato profilo bevel disattivo il join tra face e mortasa + if not jnb then + jn = false + end + + if not T then T = 0 end + if not D_X then D_X = 0 end + if not DH_X then DH_X = 0 end + if not D_XE then D_XE = 0 end + + if est or ( not L2 or not H2) or ( mh and not HB2) then + bMakeMortGeom = false + -- disattivo il join + jn = false + jn2 = false + end + + if not mh or not LGH or (( not HB2 or not TB2) and ( not H2 or not T2)) then + bMakeBoreGeom = false + end + + if not T2 then + T2 = 0 + end + + if est or not L3 or not H3 then + bMakeMortGeom2nd = false + jn2 = false + end + + if not T3 then + T3 = 0 + end + + -- se prima e seconda cava giuntate assegno il diametro della seconda cava uguale alla prima + if jn and bMakeFaceGeom and bMakeMortGeom then + d2 = d + p2 = p + end + + -- se seconda e terza cava giuntate assegno il diametro della terza cava uguale alla seconda + if jn2 and bMakeMortGeom and bMakeMortGeom2nd then + d3 = d2 + p3 = p2 + s3 = s + end + + -- determino se c'è strike + local dLSc = 0 + local dR1 = rs + if ls then -- c'è strike + dLSc = HS * tan(AS) + dR1 = rs * tan((90-AS)/2) + end + + if ls and IS > 0 and IS <= LS+(2*dR1) then -- se strike e interasse troppo corto per creare due denti + IS = 0 -- annullo interasse, singolo dente + end + + if not ASGR then + das2 = nil + end + + -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione + if not nDrawMach then + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if bMakeFaceGeom and L <= 0 then + EC = 1 + EM = string.format(EgtDoorsMsg[401],tsNamePar[1],EgtToUiUnits(L), sCompoPath) -- il parametro 'L' deve essere > 0 + L = d*2 + elseif bMakeMortGeom and not mh and L2 < 0 then + EC = 2 + EM = string.format(EgtDoorsMsg[404],tsNamePar[7],EgtToUiUnits(L2), sCompoPath) -- il parametro 'L2' deve essere >= 0 + L2 = d2*2 + elseif bMakeMortGeom2nd and L3 < 0 then + EC = 3 + EM = string.format(EgtDoorsMsg[404],tsNamePar[14],EgtToUiUnits(L3), sCompoPath) -- il parametro 'L3' deve essere >= 0 + L3 = d3*2 + elseif bMakeFaceGeom and H <= 0 then + EC = 4 + EM = string.format(EgtDoorsMsg[401],tsNamePar[2],EgtToUiUnits(H), sCompoPath) -- il parametro 'H' deve essere > 0 + H = d + elseif bMakeMortGeom and H2 <= 0 then + EC = 5 + EM = string.format(EgtDoorsMsg[401],tsNamePar[12],EgtToUiUnits(H2), sCompoPath) -- il parametro 'H2' deve essere > 0 + H2 = d2 + elseif bMakeMortGeom2nd and H3 <= 0 then + EC = 6 + EM = string.format(EgtDoorsMsg[401],tsNamePar[15],EgtToUiUnits(H3), sCompoPath) -- il parametro 'H3' deve essere > 0 + H3 = d3 + elseif bMakeFaceGeom and T < 0 then + EC = 7 + EM = string.format(EgtDoorsMsg[404],tsNamePar[3],EgtToUiUnits(T), sCompoPath) -- il parametro 'T' deve essere >= 0 + T = 0 + elseif bMakeMortGeom and T2 <= 0 then + EC = 8 + EM = string.format(EgtDoorsMsg[401],tsNamePar[8],EgtToUiUnits(T2), sCompoPath) -- il parametro 'T2' deve essere > 0 + T2 = 0.1 + elseif bMakeMortGeom2nd and T3 <= 0 then + EC = 9 + EM = string.format(EgtDoorsMsg[401],tsNamePar[16],EgtToUiUnits(T3), sCompoPath) -- il parametro 'T3' deve essere > 0 + T3 = 0.1 + elseif bMakeFaceGeom and nDrawMach > 0 and L <= d then + if DGD.bProoduce then + EC = 11 + EM = string.format(EgtDoorsMsg[402],tsNamePar[1],EgtToUiUnits(L),tsNamePar[4],EgtToUiUnits(d), sCompoPath) -- il parametro 'L' deve essere maggiore al diametro utensile + L = d + 0.002 + else + d = L - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not mh and L2 <= d2 then + if DGD.bProoduce then + EC = 12 + EM = string.format(EgtDoorsMsg[402],tsNamePar[7],EgtToUiUnits(L2),tsNamePar[9],EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L2 = d2 + 0.002 + else + d2 = L2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and L3 <= d3 then + if DGD.bProoduce then + EC = 13 + EM = string.format(EgtDoorsMsg[402],tsNamePar[7],EgtToUiUnits(L2),tsNamePar[9],EgtToUiUnits(d2), sCompoPath) -- il parametro 'L2' deve essere maggiore al diametro utensile + L3 = d3 + 0.002 + else + d3 = L3 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and H < d then + if DGD.bProoduce then + EC = 14 + EM = string.format(EgtDoorsMsg[405],tsNamePar[2],EgtToUiUnits(H),EgtToUiUnits(d), sCompoPath) -- il parametro 'H' deve essere >= del diametro utensile + H = d + else + d = H - 0.002 + end + elseif bMakeMortGeom and nDrawMach > 0 and not mh and H2 < d2 then + if DGD.bProoduce then + EC = 15 + EM = string.format(EgtDoorsMsg[405],tsNamePar[12],EgtToUiUnits(H2),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H2' deve essere >= del diametro utensile + H2 = d2 + else + d2 = H2 - 0.002 + end + elseif bMakeMortGeom2nd and nDrawMach > 0 and H3 < d3 then + if DGD.bProoduce then + EC = 16 + EM = string.format(EgtDoorsMsg[405],tsNamePar[15],EgtToUiUnits(H3),EgtToUiUnits(d2), sCompoPath) -- il parametro 'H3' deve essere >= del diametro utensile + H3 = d3 + else + d3 = H3 - 0.002 + end + elseif bMakeFaceGeom and nDrawMach > 0 and d < DgMin then + EC = 17 + EM = string.format(EgtDoorsMsg[400],tsNamePar[4], EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d = DgMin + elseif bMakeMortGeom and nDrawMach > 0 and not mh and d2 < DgMin then + EC = 18 + EM = string.format(EgtDoorsMsg[400],tsNamePar[9], EgtToUiUnits(d),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d2 = DgMin + elseif bMakeMortGeom2nd and nDrawMach > 0 and d3 < DgMin then + EC = 19 + EM = string.format(EgtDoorsMsg[400],tsNamePar[17], EgtToUiUnits(d3),EgtToUiUnits(DgMin)) -- il diametro utensile deve essere >= di + d3 = DgMin + elseif bMakeFaceGeom and nDrawMach > 0 and ( p < PtMin or p > PtMax) then + EC = 20 + EM = string.format(EgtDoorsMsg[403],tsNamePar[5],p,PtMin,PtMax, sCompoPath) -- il parametro 'p' deve essere compreso tra + p = 0.8 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and ( p2 < PtMin or p2 > PtMax) then + EC = 21 + EM = string.format(EgtDoorsMsg[403],tsNamePar[10],p2,PtMin,PtMax, sCompoPath) -- il parametro 'p2' deve essere compreso tra + p2 = 0.8 + elseif bMakeMortGeom2nd and nDrawMach > 0 and ( p3 < PtMin or p3 > PtMax) then + EC = 22 + EM = string.format(EgtDoorsMsg[403],tsNamePar[18],p3,PtMin,PtMax, sCompoPath) -- il parametro 'p3' deve essere compreso tra + p3 = 0.8 + elseif bMakeFaceGeom and bMakeMortGeom and not mh and L2 >= L then + EC = 23 + EM = string.format(EgtDoorsMsg[406],tsNamePar[7],EgtToUiUnits(L2),tsNamePar[1],EgtToUiUnits(L), sCompoPath) -- il parametro 'L2' deve essere < 'L' + L2 = L - 0.1 +-- elseif bMakeMortGeom and bMakeMortGeom2nd and not mh and L3 >= L2 then +-- EC = 24 +-- EM = string.format(EgtDoorsMsg[406],tsNamePar[14],EgtToUiUnits(L3),tsNamePar[7],EgtToUiUnits(L2), sCompoPath) -- il parametro 'L3' deve essere < 'L2' +-- L3 = L2 - 0.1 + elseif bMakeFaceGeom and bMakeMortGeom and H2 > H then + EC = 25 + EM = string.format(EgtDoorsMsg[456],tsNamePar[12],EgtToUiUnits(H2),tsNamePar[2],EgtToUiUnits(H), sCompoPath) -- il parametro 'H2' deve essere <= 'H' + H2 = H + elseif bMakeMortGeom and bMakeMortGeom2nd and H3 > H2 then + EC = 26 + EM = string.format(EgtDoorsMsg[456],tsNamePar[15],EgtToUiUnits(H3),tsNamePar[12],EgtToUiUnits(H2), sCompoPath) -- il parametro 'H3' deve essere <= 'H2' + H3 = H2 + elseif bMakeFaceGeom and bMakeMortGeom and not dws and T2 <= T then + EC = 27 + EM = string.format(EgtDoorsMsg[407],tsNamePar[8],EgtToUiUnits(T2),tsNamePar[3],EgtToUiUnits(T), sCompoPath) -- il parametro 'T2' deve essere > 'T' + T2 = T + 0.1 +-- elseif bMakeMortGeom and bMakeMortGeom2nd and not dws and T3 <= T2 then +-- EC = 29 +-- EM = string.format(EgtDoorsMsg[407],tsNamePar[16],EgtToUiUnits(T3),tsNamePar[8],EgtToUiUnits(T2), sCompoPath) -- il parametro 'T3' deve essere > 'T2' +-- T3 = T2 + 0.1 + elseif bMakeMortGeom and nDrawMach > 0 and not mh and s and s <= 0 then + EC = 30 + EM = string.format(EgtDoorsMsg[401],tsNamePar[11],EgtToUiUnits(s), sCompoPath) -- il parametro 's' deve essere > 0 + s = d2 + elseif bMakeMortGeom2nd and nDrawMach > 0 and s3 and s3 <= 0 then + EC = 31 + EM = string.format(EgtDoorsMsg[401],tsNamePar[19],EgtToUiUnits(s3), sCompoPath) -- il parametro 's3' deve essere > 0 + s3 = d3 + elseif bMakeFaceGeom and bMakeMortGeom and jn and abs(I2)<=0 and D_X and L and L2 and abs(D_X) > ((L-L2)/2) then -- se il decentramento è troppo alto e fa sbordare la cava2 dalla 1 + EC = 32 + local dDelta = abs(((L-L2)/2)-abs(D_X)) + EM = string.format(EgtDoorsMsg[423],tsNamePar[20],EgtToUiUnits(D_X),EgtToUiUnits(D_X + EgtIf( D_X >= 0, -dDelta, dDelta)), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeFaceGeom and bMakeMortGeom and jn and abs(I2)>0 and D_X and L and L2 and abs(D_X) > ((L-(L2+abs(I2)))/2) then -- se il decentramento è troppo alto e fa sbordare la cava2 dalla 1 + EC = 33 + local dDelta = abs(((L-(L2+abs(I2)))/2)-abs(D_X)) + EM = string.format(EgtDoorsMsg[423],tsNamePar[20],EgtToUiUnits(D_X),EgtToUiUnits(D_X + EgtIf( D_X >= 0, -dDelta, dDelta)), sCompoPath) -- il parametro 'D_X' é troppo grande, max valore: + D_X = 0 + elseif bMakeMortGeom and bMakeMortGeom2nd and jn2 and abs(I2)<=0 and abs(I3)<=0 and D_X and D_X3 and L2 and L3 and abs(D_X-D_X3) < ((L2+L3)/2) and abs(D_X-D_X3) > ((L2-L3)/2) then -- se il decentramento è troppo alto e fa sbordare la cava3 dalla cava2 + EC = 34 + local dDelta = abs(((L2-(L3+abs(I3)))/2)-abs(D_X-D_X3)) + EM = string.format(EgtDoorsMsg[624],tsNamePar[21],EgtToUiUnits(D_X3),EgtToUiUnits(D_X3 + EgtIf( D_X3 >= 0, -dDelta, dDelta)), sCompoPath) -- il parametro 'D_X3' é troppo grande, max valore: + D_X3 = 0 + elseif bMakeMortGeom and bMakeMortGeom2nd and jn2 and abs(I2)<=0 and abs(I3)>0 and D_X and D_X3 and L2 and L3 and (L2-(L3+abs(I3))) >= 0 and ((L2-(L3+abs(I3)))/2) <= abs(D_X3-D_X) then -- se il decentramento è troppo alto e fa sbordare la cava3 dalla 2 + EC = 35 + local dDelta = abs(((L2-L3)/2)-abs(D_X-D_X3)) + EM = string.format(EgtDoorsMsg[624],tsNamePar[21],EgtToUiUnits(D_X3),EgtToUiUnits(D_X3 + EgtIf( D_X3 >= 0, -dDelta, dDelta)), sCompoPath) -- il parametro 'D_X3' é troppo grande, max valore: + D_X3 = 0 + elseif bMakeMortGeom and bMakeMortGeom2nd and D_X and D_X3 and abs(abs(D_X)-abs(D_X3)) < GEO.EPS_SMALL and abs(I2)>0 and abs(I3)>0 and abs(abs(I2)-abs(I3)) > GEO.EPS_SMALL and (abs(I2)-L2) > (abs(I3)-L3) then -- se le seconde mortase doppie sbordano delle prime mortase doppie + EC = 36 + EM = string.format(EgtDoorsMsg[625],tsNamePar[33],EgtToUiUnits(I3),EgtToUiUnits(abs(I2)-L2+L3), sCompoPath) -- il parametro 'I3' é troppo piccolo, min valore: + I3 = abs(I2)-L2+L3 + elseif bMakeMortGeom and bMakeMortGeom2nd and D_X and D_X3 and abs(abs(D_X)-abs(D_X3)) < GEO.EPS_SMALL and abs(I2)>0 and abs(I3)>0 and abs(I2-abs(I3)) > GEO.EPS_SMALL and (I2+L2) < (abs(I3)+L3) then -- se le seconde mortase doppie sbordano delle prime mortase doppie + EC = 37 + EM = string.format(EgtDoorsMsg[624],tsNamePar[33],EgtToUiUnits(I3),EgtToUiUnits(abs(I2)+L2-L3), sCompoPath) -- il parametro 'I3' é troppo grande, max valore: + I3 = abs(I2)+L2-L3 + elseif bMakeFaceGeom and nDrawMach > 0 and sf and sf <= 0 then + EC = 38 + EM = string.format(EgtDoorsMsg[401],tsNamePar[34],EgtToUiUnits(sf), sCompoPath) -- il parametro 'sf' deve essere > 0 + sf = d + elseif bMakeFaceGeom and cl and cl > 0 and rf < 0 then + EC = 39 + EM = string.format(EgtDoorsMsg[404],tsNamePar[35],EgtToUiUnits(rf), sCompoPath) -- il parametro 'rf' deve essere >= 0 + rf = H/2 + elseif bMakeFaceGeom and CLC and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 40 + EM = string.format(EgtDoorsMsg[407],tsNamePar[36],EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + elseif bMakeBoreGeom and not dws and FBP and ( ( TB2 and FBP >= TB2) or ( not TB2 and T2 and FBP >= T2)) then + if TB2 and FBP >= TB2 then + EC = 41 + EM = string.format(EgtDoorsMsg[407],tsNamePar[30],EgtToUiUnits(TB2),tsNamePar[32],EgtToUiUnits(FBP), sCompoPath) -- il parametro 'TB2' deve essere > 'FBP' + TB2 = FBP + 0.1 + elseif T2 and FBP >= T2 then + EC = 42 + EM = string.format(EgtDoorsMsg[407],tsNamePar[8],EgtToUiUnits(T2),tsNamePar[32],EgtToUiUnits(FBP), sCompoPath) -- il parametro 'T2' deve essere > 'FBP' + T2 = FBP + 0.1 + end + elseif bMakeFaceGeom and ls then + if (L-(2*rf)) < (LS+IS+(2*dR1)) then -- se lunghezza face troppo corta per parte latch + EC = 43 + EM = string.format(EgtDoorsMsg[627],tsNamePar[1],EgtToUiUnits(L),EgtToUiUnits((2*rf)+LS+IS+(2*dR1)), sCompoPath) -- il parametro 'L' é troppo piccolo, min valore: + L = (2*rf)+LS+IS+(2*dR1) + elseif LS <= (d+(dLSc*2)) then -- se larghezza dello strike è inferiore della componente inclinata + EC = 44 + EM = string.format(EgtDoorsMsg[627],tsNamePar[6],EgtToUiUnits(LS),EgtToUiUnits(d+(2*dLSc)), sCompoPath) -- il parametro 'LS' é troppo piccolo, min valore: + LS = d+(2*dLSc)+ 0.1 + elseif D_SS < (dR1+rf) then + EC = 45 + EM = string.format(EgtDoorsMsg[627],tsNamePar[24],EgtToUiUnits(D_SS),EgtToUiUnits(dR1+rf), sCompoPath) -- il parametro 'LS' é troppo piccolo, min valore: + D_SS = dR1+rf + 0.1 + end + 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 + -- variabili dei percorsi geometrici + local nGeom1st, nGeom2st, nGeom1, nGeom2, nGeom3, nGeom4 + local nAS1, nAS2, nAS3, nAS4 + local hint_1, hint_2, hint_3, hint_4, hint_5, hint_6, hint_7, hint_8 -- variabili percorsi su fianco + local hint_10, hint_11, hint_13, hint_14, hint_15 -- variabili percorsi su secure o keyway + local nPkToJoin1st, nPkToJoin1, nPkToJoin2, nPkToJoin3, nPkToJoin4 + local nPkToJoin1st_r, nPkToJoin1_r, nPkToJoin2_r, nPkToJoin3_r, nPkToJoin4_r + local nPkJoin, nPkJoin1, nPkJoin2, nPkJoin3 + local nPkJoin_rev, nPkJoin1_rev, nPkJoin2_rev, nPkJoin3_rev + local nPos1st = 0 + local nDirMort1 = 1 + local nDirMort2 = 1 + local bMatchMort = false + local dFirstface = {} + local nForceMakeFace = nDrawMach + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale + EgtSetName(Lg,sCompoName) + + if bMakeFaceGeom then + + -- in base agli arrotondamenti calcolo lo spostamento per posizionare la cava in centro + if cl == 1 then -- se arrotondamento a sinistra + nPos1st = rf/2 + elseif cl == 2 then -- se arrotondamento a destra + nPos1st = -(rf/2) + else + nPos1st = 0 + end + + -- prima cava face completa + -- assegno i valori coerenti con la tabella del componente + dFirstface.L = L + dFirstface.H = H + dFirstface.T = T + dFirstface.rf = rf + dFirstface.cl = cl + dFirstface.d = d + dFirstface.p = p + dFirstface.sf = sf + dFirstface.jn = jn + dFirstface.L2 = L2 + dFirstface.H2 = H2 + dFirstface.invG = invG + dFirstface.est = est + dFirstface.smr = 0 -- così il latch non crea i raccordini per evitare il chiseling + dFirstface.mkrev = mkrev + -- se ho abilitato il chiseling modifico il nome geometria + if ech then + dFirstface.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 + else + dFirstface.LG = LG + end + dFirstface.LM = LM + dFirstface.Nome = sCompoName + dFirstface.D_X = D_X + (abs(I2/2)*nDirMort1) - nPos1st + dFirstface.Dws = nil -- disabilito per non creare geometrie (doppie) inerenti il calcolo regioni nei componenti chiamati + + local sRequireCompoName = '_Latch' + if ls then + dFirstface.LS = LS + dFirstface.HS = HS + dFirstface.AS = AS + dFirstface.IS = IS + dFirstface.D_SS = D_SS + dFirstface.rs = rs + dFirstface.da = da + dFirstface.LA = LA + if IS > 0 then -- se doppio strike setto la posizione della prossima mortise + nDirMort1 = -1 -- setto per invertire il senso di inserimento delle prime mortase + dFirstface.D_X = D_X + (abs(I2/2)*nDirMort1) - nPos1st + end + sRequireCompoName = '_Strike' + end + + -- lancio il primo componente base per disegnare la face completa + MHgen = require( sRequireCompoName) + if ls then + nGeom1st, nPkToJoin1st, nGeom2st, nAS1, nAS2, nAS3, nAS4, nPkToJoin1st_r = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + else + nGeom1st, nPkToJoin1st, nGeom2st, nAS1, nAS2, nPkToJoin1st_r = MHgen.Draw( EC, EM, dFirstface, bPreview, bRunByCompo, nForceMakeFace, Pz, Lg, dThickDoor) + end + + -- setto le note che indicano su che lato della porta devono essere messe le geometrie + local sSide = EgtIf( dl, 'Lock', 'Side') + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nGeom1st) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nPkToJoin1st) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nGeom2st) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nAS1) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nAS2) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nAS3) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nAS4) + SetPropertyAndMoveGeom( sSide, kbs, pbs, 'c', nPos1st, nPkToJoin1st_r) + + -- Clean corner + if nDrawMach >= 0 then -- se abilitata geometria + if cl ~= 3 or ( cl == 3 and rf > 0) then -- se c'è almeno un lato senza raccordo + if CLC and clc and clc > 0 and clc < H and clc < L then + + local CLC1 = MakeClcPath( clc, ccr, CLC, Lg, -T, (invG == -1)) + if CLC1 then + local nLS = 0 + local nD_SS = 0 + if LS then nLS = LS end + if D_SS then nD_SS = D_SS end + -- se mantiene backset + SetProbeProperty( kbs, 0, pbs, 'c', CLC1) -- setto 'c' perché viene mantenuto il centro spessore + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( CLC1, 'ProbeSide', '1') + end + EgtSetInfo( CLC1,'SideDoor',sSide) + if cl <= 1 or cl == 3 then + if LS ~= L and D_SS ~= 0 then + -- angolo x+y+ + local CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((L/2),(H/2),0) - ORIG()) + end + -- angolo x+y- + local CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d((L/2),-(H/2),0) - ORIG()) + if cl == 1 then + EgtErase(CLC1) + end + end + if cl == 0 or cl >= 2 then + -- angolo x-y- + local CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(-(L/2),-(H/2),0) - ORIG()) + if LS ~= L and abs(L-nD_SS-nLS) >= GEO.EPS_SMALL then + -- angolo x-y+ + EgtMove( CLC1, Point3d(-(L/2),(H/2),0) - ORIG()) + else + EgtErase(CLC1) + end + end + end + end + end + end + end + + if bMakeBoreGeom then -- se foro orizzontale abilitato + + -- se parametri foro/preforo + if LMP and FBD and FBD > 0 and FBP and FBP > 0 then + hint_7 = EgtCircle( Lg, Point3d(0,0,0), FBD/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_7, -FBP) + EgtSetName(hint_7,LMP) + if AB and abs(AB) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_7, Point3d(0,0,0), Z_AX(), AB, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + end + -- se parametri secondo foro + if HB2 and TB2 then + hint_8 = EgtCircle( Lg, Point3d(0,0,0), HB2/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_8, -TB2) + elseif H2 and T2 then + hint_8 = EgtCircle( Lg, Point3d(0,0,0), H2/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_8, -T2) + end + EgtSetName(hint_8,LGH) + if AB and abs(AB) > 0 then + -- setto la griglia di fronte + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.FRONT)) + EgtRotate( hint_8, Point3d(0,0,0), Z_AX(), AB, GDB_RT.GRID) -- ruoto su faccia frontale + -- setto la griglia di top + EgtSetGridFrame( Frame3d( 0, 0, 0, GDB_FR.TOP)) + end + + if hint_8 then -- se esiste secondo foro + EgtSetInfo(hint_8,'SideDoor','Lock') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', hint_8) -- setto 'c' perché viene mantenuto il centro spessore + end + if hint_7 then -- se esiste foro/preforo + EgtSetInfo(hint_7,'SideDoor','Lock') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', hint_7) -- setto 'c' perchè viene mantenuto il centro spessore + end + end + + -- determino se ho due coppie di mortase compatibili al concatenamento in Z + if bMakeMortGeom and bMakeMortGeom2nd and jn2 and abs(I2)> 0 and abs(I3)>0 and + (D_X+(abs(I2)-L2)/2) <= (D_X3+(abs(I3)-L3)/2) and (D_X+(abs(I2)+L2)/2) >= (D_X3+(abs(I3)+L3)/2) then + bMatchMort = true -- setto flag per indicare che le coppie di mortase sono centrate + end + + if bMakeMortGeom then -- se seconda cava abilitata + + -- eseguo la prima delle prime mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.LGM = LG2 + dMortise.LMM = LA2 + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.Nome = sCompoName + dMortise.jne = jn2 + dMortise.D_X = 0 + -- se c'è il match tra le 4 mortase + if bMatchMort then + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.D_X = -(((abs(I2)-abs(I3))/2)-(D_X-D_X3))*nDirMort1 + dMortise.jne = jn2 + dMortise.jnt = false + nDirMort2 = nDirMort1 + else -- se non c'è il match vedo se c'è intersasse con la mortsa dello stesso livello + -- calcolo la posizione dal centro seconda cava (mortasa) al centro della cava successiva + if abs(I2) > 0 then -- se ho seconda cava + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.D_X = -abs(I2)*nDirMort1 + dMortise.jne = true + dMortise.jnt = true + nDirMort2 = -nDirMort1 + else -- se ho solo una cava + if jn2 then -- se si concatena alle seguenti + nDirMort1 = 1 + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.D_X = D_X3 + ((abs(I3)/2)*nDirMort1) - D_X + nDirMort2 = nDirMort1 + dMortise.jnt = true + if ((L2 - (L3+abs(I3)))/2) > abs(D_X3-D_X) then -- se prima mortasa contiene la/e seconda/e mortasa/e rimango a z della prima mortasa + dMortise.jnt = false + end + end + end + end + + -- lancio il componente base + MHgen = require('_Mortise') + nGeom1, nPkToJoin1, nPkToJoin1_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X+(abs(I2/2)*nDirMort1)), nGeom1) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X+(abs(I2/2)*nDirMort1)), nPkToJoin1) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X+(abs(I2/2)*nDirMort1)), nPkToJoin1_r) + end + + if bMatchMort then -- se le mortase sono centrate + + -- eseguo la prima delle seconde mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T2 + dMortise.L2 = L3 + dMortise.H2 = H3 + dMortise.T2 = T3 + dMortise.s = s3 + dMortise.d = d3 + dMortise.p = p3 + dMortise.jn = jn2 + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.LGM = LG3 + dMortise.LMM = LA3 + dMortise.Nome = sCompoName + -- assegno i seguenti valori cava con le dimensioni della prima mortasa + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.D_X = -(((abs(I2)+abs(I3))/2)+D_X-D_X3)*nDirMort1 + dMortise.jne = jn2 + dMortise.jnt = true + dMortise.TE = T + + -- lancio il componente base + MHgen = require('_Mortise') + nGeom3, nPkToJoin3, nPkToJoin3_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nGeom3) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nPkToJoin3) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nPkToJoin3_r) + else -- altrimenti verifico se ho doppia prima mortasa + + if bMakeMortGeom and abs(I2) > 0 then -- se ho seconda cava doppia + + -- eseguo la doppia delle prime mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.L3 = L2 + dMortise.H3 = H2 + dMortise.d3 = d2 + dMortise.p3 = p2 + dMortise.LGM = LG2 + dMortise.LMM = LA2 + dMortise.Nome = sCompoName + dMortise.jne = jn2 + dMortise.jnt = false + + if bMakeMortGeom2nd then -- se ho seconda mortasa + dMortise.jnt = true + end + + if jn2 then + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.D_X = ((D_X3+abs(I3/2))-(D_X-(abs(I2/2)*nDirMort1))) + end + + -- lancio il componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2, nPkToJoin2_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nGeom2) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nPkToJoin2) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nPkToJoin2_r) + end + end + + if bMatchMort then -- se le mortase sono centrate + + -- eseguo la doppia delle prime mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L2 + dMortise.H2 = H2 + dMortise.T2 = T2 + dMortise.s = s + dMortise.d = d2 + dMortise.p = p2 + dMortise.jn = jn2 + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.LGM = LG2 + dMortise.LMM = LA2 + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.Nome = sCompoName + dMortise.jne = jn2 + dMortise.jnt = false + dMortise.D_X = (((abs(I2)-abs(I3))/2)+D_X-D_X3)*nDirMort2 + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom2, nPkToJoin2, nPkToJoin2_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nGeom2) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nPkToJoin2) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X-(abs(I2/2)*nDirMort1)), nPkToJoin2_r) + else + + if bMakeMortGeom2nd then -- se seconde mortase abilitate + + -- eseguo la prima delle seconde mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + dMortise.T = T + dMortise.L2 = L3 + dMortise.H2 = H3 + dMortise.T2 = T3 + dMortise.s = s3 + dMortise.d = d3 + dMortise.p = p3 + dMortise.jn = jn2 + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.LGM = LG3 + dMortise.LMM = LA3 + dMortise.Nome = sCompoName + dMortise.D_X = 0 + dMortise.jne = false + dMortise.jnt = true + if I3 and abs(I3) > 0 then -- se ho doppia seconda mortasa + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.D_X = -abs(I3)*nDirMort2 + dMortise.jne = true + else + dMortise.TE = 0 + if not jn2 then + dMortise.d3 = d3 + dMortise.p3 = p3 + dMortise.s3 = s3 + end + end + if abs(I2) < GEO.EPS_SMALL and ((L2 - (L3+abs(I3)))/2) > abs(D_X3-D_X) then -- se prima mortasa non doppia contiene la/e seconda/e martasa/e rimango a z della prima mortasa + dMortise.T = T2 + if abs(I3) > 0 then + dMortise.TE = T2 + else + dMortise.TE = 0 + end + elseif abs(I2) < GEO.EPS_SMALL then -- altrimenti se prima mortasa non doppia e non contiene le seconde mortase + if not jn then -- se non collegate a svuotatura face + dMortise.T = 0 + end + end + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom3, nPkToJoin3, nPkToJoin3_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nGeom3) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nPkToJoin3) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3+(abs(I3/2)*nDirMort2)), nPkToJoin3_r) + end + end + + if bMakeMortGeom2nd then -- se seconde mortase abilitate + + if bMatchMort or abs(I3) > 0 then -- se ho terza cava doppia + + -- eseguo la doppia delle seconde mortase + local dMortise = {} + -- assegno i valori coerenti con la tabella del componente + + dMortise.T = T2 + dMortise.TE = 0 + + -- se le mortase non sono centrate e le seconde non sono contenute nella prima + if not bMatchMort and (((L2 - (L3+abs(I3)))/2) <= abs(D_X3-D_X)) then + if not jn then -- se non collegate a svuotatura face + dMortise.T = 0 -- quota di partezza alla profondità face + else + dMortise.T = T -- quota di partezza alla profondità face + end + end + dMortise.L2 = L3 + dMortise.H2 = H3 + dMortise.T2 = T3 + dMortise.s = s3 + dMortise.d = d3 + dMortise.p = p3 + dMortise.jn = jn2 + dMortise.invG = invG + dMortise.mkrev = mkrev + dMortise.LGM = LG3 + dMortise.LMM = LA3 + dMortise.Nome = sCompoName + dMortise.D_X = 0 + dMortise.jne = false + dMortise.jnt = true + dMortise.L3 = L3 + dMortise.H3 = H3 + dMortise.d3 = d3 + dMortise.p3 = p3 + + -- lancio il secondo componente base + MHgen = require('_Mortise') + nGeom4, nPkToJoin4, nPkToJoin4_r = MHgen.Draw( EC, EM, dMortise, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- assegno le note e muovo nella posizione definitiva + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3-(abs(I3/2)*nDirMort2)), nGeom4) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3-(abs(I3/2)*nDirMort2)), nPkToJoin4) + SetPropertyAndMoveGeom( 'Lock', kbs, pbs, 'c', (D_X3-(abs(I3/2)*nDirMort2)), nPkToJoin4_r) + end + end + + -- disegno le geometrie mounting screw + if EC == 0 then + + for k = 1, 2 do + + local D9 = tMountingScrew[k][1] + local T9 = tMountingScrew[k][2] + local I9 = tMountingScrew[k][3] or 0 + local IY9 = tMountingScrew[k][4] or 0 + local mcs = tMountingScrew[k][5] + local mss = tMountingScrew[k][6] + local PX9C = tMountingScrew[k][7] or 0 + local PX9 = tMountingScrew[k][8] or 0 + local PY9 = tMountingScrew[k][9] or 0 + local LMS = tMountingScrew[k][10] + + -- se dimensioni foro viti idonee + if D9 and T9 and LMS then + + if D9 > 0 and T9 ~= 0 and LMS ~= '' then + + if not Lg then + Lg = EgtGroup( Pz, GDB_RT.LOC) + EgtSetName( Lg, sCompoName) + end + + hint_3 = EgtCircle( Lg, Point3d(PX9+(I9/2),PY9+(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_3, -T9) + EgtSetName( hint_3, LMS) + EgtSetInfo( hint_3, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_3) -- setto 'c' perchè viene mantenuto il centro spessore + + if IY9 ~= 0 then + hint_5 = EgtCircle( Lg, Point3d(PX9+(I9/2),PY9-(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_5, -T9) + EgtSetName( hint_5, LMS) + EgtSetInfo( hint_5, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_5) -- setto 'c' perchè viene mantenuto il centro spessore + end + + if mcs then + if mss then + hint_1 = EgtCircle( Lg, Point3d(PX9+PX9C,PY9,0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_1, -T9) + EgtSetName( hint_1, LMS) + EgtSetInfo( hint_1, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_1) -- setto 'c' perchè viene mantenuto il centro spessore + else + hint_1 = EgtCircle( Lg, Point3d(PX9+PX9C,PY9+(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_1, -T9) + EgtSetName( hint_1, LMS) + EgtSetInfo( hint_1, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_1) -- setto 'c' perchè viene mantenuto il centro spessore + hint_2 = EgtCircle( Lg, Point3d(PX9+PX9C,PY9-(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_2, -T9) + EgtSetName( hint_2, LMS) + EgtSetInfo( hint_2,'SideDoor','Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_2) -- setto 'c' perchè viene mantenuto il centro spessore + end + end + + if I9 ~= 0 then + hint_4 = EgtCircle( Lg, Point3d(PX9-(I9/2),PY9+(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_4, -T9) + EgtSetName( hint_4, LMS) + EgtSetInfo( hint_4, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_4) -- setto 'c' perchè viene mantenuto il centro spessore + + if IY9 ~= 0 then + hint_6 = EgtCircle( Lg, Point3d(PX9-(I9/2),PY9-(IY9/2),0), D9/2 , GDB_RT.LOC) + EgtModifyCurveThickness( hint_6, -T9) + EgtSetName( hint_6, LMS) + EgtSetInfo( hint_6, 'SideDoor', 'Lock') -- setto una nota per indicare su che lato della porta deve essere spostato + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', hint_6) -- setto 'c' perchè viene mantenuto il centro spessore + end + end + end + end + end + end + + if EC == 0 and bMakeBoreGeom and hint_8 then -- se esiste il secondo foro + if DH_X and abs(DH_X) > GEO.EPS_SMALL then + EgtMove( hint_8, Point3d(DH_X,0,0) - ORIG()) + elseif not HB2 and abs(D_X) > GEO.EPS_SMALL then + EgtMove( hint_8, Point3d(D_X,0,0) - ORIG()) + end + end + if EC == 0 and bMakeBoreGeom and hint_7 then -- se esiste il foro/preforo + if DH_X and abs(DH_X) > GEO.EPS_SMALL then + EgtMove( hint_7, Point3d(DH_X,0,0) - ORIG()) + elseif not HB2 and abs(D_X) > GEO.EPS_SMALL then + EgtMove( hint_7, Point3d(D_X,0,0) - ORIG()) + end + end + + -- se percorsi fatti con lo stesso utensile, li concateno + if jn and EC == 0 and nPkToJoin1st and nPkToJoin1 then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkToJoin1st, 'MVar') + nPkJoin = EgtCurveCompo( Lg, {nPkToJoin1st,nPkToJoin1}, true) + if nPkJoin then + EgtSetName( nPkJoin, LM) + if sVarNote then EgtSetInfo( nPkJoin, 'MVar', sVarNote) end + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin, 'NotCheckDir', '1') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom1) -- setto 'c' perchè viene mantenuto il centro spessore + else + EC = ErrorBase + 52 + EM = string.format( EgtDoorsMsg[426], sCompoPath) + end + end + + -- se percorsi inversi fatti con lo stesso utensile, li concateno + if jn and EC == 0 and nPkToJoin1st_r and nPkToJoin1_r then + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkToJoin1st_r, 'MVar') + nPkJoin_rev = EgtCurveCompo( Lg, {nPkToJoin1st_r,nPkToJoin1_r}, true) + if nPkJoin_rev then + EgtSetName( nPkJoin_rev, LM..'R') + if sVarNote then EgtSetInfo( nPkJoin_rev, 'MVar', sVarNote) end + -- se concatenata con la seconda cava (mortasa), forzo la posizione a Lock ( non segue angolo del profilo bevel) + EgtSetInfo( nPkJoin_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin_rev, 'NotCheckDir', '1') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom1) -- setto 'c' perchè viene mantenuto il centro spessore + else + EC = ErrorBase + 53 + EM = string.format( EgtDoorsMsg[425], sCompoPath) + end + end + + if not bMatchMort then -- se le cave non si combinano + + -- se ho doppia cava e non matchano con le 4 cave + if EC == 0 and nPkToJoin1 and nPkToJoin2 then + local sVarNote + if nPkJoin then -- se fatto concatenamento con face + sVarNote = EgtGetInfo( nPkJoin, 'MVar') + nPkJoin1 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin2}, true) + else + nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin2}, true) + end + if nPkJoin1 then + if nPkJoin then + if sVarNote then EgtSetInfo( nPkJoin1, 'MVar', sVarNote) end + EgtSetName( nPkJoin1, LM) + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom2) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin1, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 1, pbs, 'c', nPkJoin1) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin1, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') + else + EC = ErrorBase + 54 + EM = string.format( EgtDoorsMsg[426], sCompoPath) + end + end + + -- se ho doppia cava inversa senza match tra le mortase + if EC == 0 and nPkToJoin1_r and nPkToJoin2_r then + local sVarNote + if nPkJoin_rev then -- se fatto concatenamento con face + sVarNote = EgtGetInfo( nPkJoin_rev, 'MVar') + nPkJoin1_rev = EgtCurveCompo( Lg, {nPkJoin_rev,nPkToJoin2_r}, true) + else + nPkJoin1_rev = EgtCurveCompo( Lg, {nPkToJoin1_r,nPkToJoin2_r}, true) + end + if nPkJoin1_rev then + if nPkJoin_rev then + if sVarNote then EgtSetInfo( nPkJoin1_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin1_rev, LM..'R') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom2) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin1_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin1_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin1_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 55 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + end + + -- se ho terza cava senza match + if jn2 and EC == 0 and nPkToJoin3 then + if nPkJoin1 then -- se riuscito precedente concatenamento + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkJoin1, 'MVar') + nPkJoin2 = EgtCurveCompo( Lg, {nPkJoin1,nPkToJoin3}, true) + if nPkJoin2 then + if nPkJoin then -- se riuscito primo concatenamento + if sVarNote then EgtSetInfo( nPkJoin2, 'MVar', sVarNote) end + EgtSetName( nPkJoin2, LM) + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom3) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin2, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin2, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2, 'NotCheckDir', '1') + else + EC = ErrorBase + 56 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + else + local sVarNote + if nPkJoin then -- se riuscito primo concatenamento + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin, 'MVar') + nPkJoin2 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin3}, true) + elseif nPkToJoin1 then + nPkJoin2 = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin3}, true) + end + + if nPkJoin2 then + if sVarNote then EgtSetInfo( nPkJoin2, 'MVar', sVarNote) end + EgtSetName( nPkJoin2, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + EgtSetInfo( nPkJoin2, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2, 'NotCheckDir', '1') + else + EC = ErrorBase + 57 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + end + end + + -- se ho terza cava inversa senza match + if jn2 and EC == 0 and nPkToJoin3_r then + if nPkJoin1_rev then -- se riuscito precedente concatenamento + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkJoin1_rev, 'MVar') + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkJoin1_rev,nPkToJoin3_r}, true) + if nPkJoin2_rev then + if nPkJoin_rev then -- se riuscito primo concatenamento + if sVarNote then EgtSetInfo( nPkJoin2_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin2_rev, LM..'R') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom3) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin2_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin2_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 58 + EM = string.format( EgtDoorsMsg[425], sCompoPath) + end + else + local sVarNote + if nPkJoin_rev then -- se riuscito primo concatenamento + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin_rev, 'MVar') + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkJoin_rev,nPkToJoin3_r}, true) + elseif nPkToJoin1_r then + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkToJoin1_r,nPkToJoin3_r}, true) + end + + if nPkJoin2_rev then + if sVarNote then EgtSetInfo( nPkJoin2_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin2_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + EgtSetInfo( nPkJoin2_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 59 + EM = string.format( EgtDoorsMsg[425], sCompoPath) + end + end + end + + -- se ho doppia terza cava senza match + if EC == 0 and nPkToJoin3 and nPkToJoin4 then + local sVarNote + if nPkJoin2 then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin2, 'MVar') + nPkJoin3 = EgtCurveCompo( Lg, {nPkJoin2,nPkToJoin4}, true) + else + nPkJoin3 = EgtCurveCompo( Lg, {nPkToJoin3,nPkToJoin4}, true) + end + if nPkJoin3 then + if nPkJoin2 then + if sVarNote then EgtSetInfo( nPkJoin3, 'MVar', sVarNote) end + if nPkJoin then + EgtSetName( nPkJoin3, LM) + else + EgtSetName( nPkJoin3, LA2) + end + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom4) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin3, LA3) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin3, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin3, 'NotCheckDir', '1') + else + EC = ErrorBase + 60 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + end + + -- se ho doppia terza cava inversa senza match + if EC == 0 and nPkToJoin3_r and nPkToJoin4_r then + local sVarNote + if nPkJoin2_rev then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin2_rev, 'MVar') + nPkJoin3_rev = EgtCurveCompo( Lg, {nPkJoin2_rev,nPkToJoin4_r}, true) + else + nPkJoin3_rev = EgtCurveCompo( Lg, {nPkToJoin3_r,nPkToJoin4_r}, true) + end + if nPkJoin3_rev then + if nPkJoin2_rev then + if sVarNote then EgtSetInfo( nPkJoin3_rev, 'MVar', sVarNote) end + if nPkJoin_rev then + EgtSetName( nPkJoin3_rev, LM..'R') + else + EgtSetName( nPkJoin3_rev, LA2..'R') + end + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom4) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin3_rev, LA3..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin3_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin3_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 61 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + end + + else -- se ho il match con tra le mortase + + -- se ho doppia cava e matchano con le 4 cave concateno con la seconda mortasa + if EC == 0 and nPkToJoin1 and nPkToJoin3 then + local sVarNote + if nPkJoin then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin, 'MVar') + nPkJoin1 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin3}, true) + else + nPkJoin1 = EgtCurveCompo( Lg, {nPkToJoin1,nPkToJoin3}, true) + end + if nPkJoin1 then + if nPkJoin then + if sVarNote then EgtSetInfo( nPkJoin1, 'MVar', sVarNote) end + EgtSetName( nPkJoin1, LM) + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom3) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin1, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin1, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin1, 'NotCheckDir', '1') + else + EC = ErrorBase + 62 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + end + + -- se ho doppia cava inversa con match tra le mortase + if EC == 0 and nPkToJoin1_r and nPkToJoin3_r then + local sVarNote + if nPkJoin_rev then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin_rev, 'MVar') + nPkJoin1_rev = EgtCurveCompo( Lg, {nPkJoin_rev,nPkToJoin3_r}, true) + else + nPkJoin1_rev = EgtCurveCompo( Lg, {nPkToJoin1_r,nPkToJoin3_r}, true) + end + if nPkJoin1_rev then + if nPkJoin_rev then + if sVarNote then EgtSetInfo( nPkJoin1_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin1_rev, LM..'R') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom3) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin1_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin1_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin1_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin1_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 63 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + end + + -- se ho seconda cava con match + if jn2 and EC == 0 and nPkToJoin2 then + if nPkJoin1 then -- se riuscito precedente concatenamento + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkJoin1, 'MVar') + nPkJoin2 = EgtCurveCompo( Lg, {nPkJoin1,nPkToJoin2}, true) + if nPkJoin2 then + if nPkJoin then -- se riuscito primo concatenamento + if sVarNote then EgtSetInfo( nPkJoin2, 'MVar', sVarNote) end + EgtSetName( nPkJoin2, LM) + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom2) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin2, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin2, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2, 'NotCheckDir', '1') + else + EC = ErrorBase + 64 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + else + local sVarNote + if nPkJoin then -- se riuscito primo concatenamento + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin, 'MVar') + nPkJoin2 = EgtCurveCompo( Lg, {nPkJoin,nPkToJoin2}, true) + elseif nPkToJoin3 then + nPkJoin2 = EgtCurveCompo( Lg, {nPkToJoin3,nPkToJoin2}, true) + end + + if nPkJoin2 then + if sVarNote then EgtSetInfo( nPkJoin2, 'MVar', sVarNote) end + EgtSetName( nPkJoin2, LA2) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2) -- setto 'c' perchè viene mantenuto il centro spessore + EgtSetInfo( nPkJoin2, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2, 'NotCheckDir', '1') + else + EC = ErrorBase + 65 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + end + end + + -- se ho seconda cava inversa con match + if jn2 and EC == 0 and nPkToJoin2_r then + if nPkJoin1_rev then -- se riuscito precedente concatenamento + -- recupero la nota delle variazioni dalla geometria del face + local sVarNote = EgtGetInfo( nPkJoin1_rev, 'MVar') + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkJoin1_rev,nPkToJoin2_r}, true) + if nPkJoin2_rev then + if nPkJoin_rev then -- se riuscito primo concatenamento + if sVarNote then EgtSetInfo( nPkJoin2_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin2_rev, LM..'R') + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom2) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin2_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin2_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 66 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + else + local sVarNote + if nPkJoin_rev then -- se riuscito primo concatenamento + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin_rev, 'MVar') + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkJoin_rev,nPkToJoin2_r}, true) + elseif nPkToJoin3_r then + nPkJoin2_rev = EgtCurveCompo( Lg, {nPkToJoin3_r,nPkToJoin2_r}, true) + end + + if nPkJoin2_rev then + if sVarNote then EgtSetInfo( nPkJoin2_rev, 'MVar', sVarNote) end + EgtSetName( nPkJoin2_rev, LA2..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin2_rev) -- setto 'c' perchè viene mantenuto il centro spessore + EgtSetInfo( nPkJoin2_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin2_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 67 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + end + end + + -- se ho doppia terza cava con match + if EC == 0 and nPkToJoin2 and nPkToJoin4 then + local sVarNote + if nPkJoin2 then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin2, 'MVar') + nPkJoin3 = EgtCurveCompo( Lg, {nPkJoin2,nPkToJoin4}, true) + else + nPkJoin3 = EgtCurveCompo( Lg, {nPkToJoin2,nPkToJoin4}, true) + end + if nPkJoin3 then + if nPkJoin2 then + if sVarNote then EgtSetInfo( nPkJoin3, 'MVar', sVarNote) end + if nPkJoin then + EgtSetName( nPkJoin3, LM) + else + EgtSetName( nPkJoin3, LA2) + end + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom4) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin3, LA3) + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin3, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin3, 'NotCheckDir', '1') + else + EC = ErrorBase + 68 + EM = string.format(EgtDoorsMsg[426], sCompoPath) + end + end + + -- se ho doppia terza cava inversa con match + if EC == 0 and nPkToJoin2_r and nPkToJoin4_r then + local sVarNote + if nPkJoin2_rev then -- se fatto concatenamento con face + -- recupero la nota delle variazioni dalla geometria del face + sVarNote = EgtGetInfo( nPkJoin2_rev, 'MVar') + nPkJoin3_rev = EgtCurveCompo( Lg, {nPkJoin2_rev,nPkToJoin4_r}, true) + else + nPkJoin3_rev = EgtCurveCompo( Lg, {nPkToJoin2_r,nPkToJoin4_r}, true) + end + if nPkJoin3_rev then + if nPkJoin2_rev then + if sVarNote then EgtSetInfo( nPkJoin3_rev, 'MVar', sVarNote) end + if nPkJoin_rev then + EgtSetName( nPkJoin3_rev, LM..'R') + else + EgtSetName( nPkJoin3_rev, LA2..'R') + end + -- se mantiene centro spessore anche su face + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3_rev) -- setto 'c' perchè viene mantenuto il centro spessore + SetProbeProperty( kbs, 0, pbs, 'c', nGeom4) -- setto 'c' perchè viene mantenuto il centro spessore + else + EgtSetName( nPkJoin3_rev, LA3..'R') + -- se mantiene centro spessore su mortise + SetProbeProperty( kbs, 0, pbs, 'c', nPkJoin3_rev) -- setto 'c' perchè viene mantenuto il centro spessore + end + EgtSetInfo( nPkJoin3_rev, 'SideDoor', 'Lock') + EgtSetInfo( nPkJoin3_rev, 'NotCheckDir', '1') + else + EC = ErrorBase + 69 + EM = string.format(EgtDoorsMsg[425], sCompoPath) + end + end + end + + if EC == 0 then -- se nessun errore + + -- Gestione file custom + local MakeFaceGeom = true + + -- caricamento del file custom + if string.len(CustGeomFile) > 0 and string.find( string.lower(CustGeomFile), '.nge') > 0 then + + -- sostituisco il carattere '\' con '_' nel nome file + CustGeomFile = string.gsub(CustGeomFile, '\\', '_') + CustGeomFile = string.gsub(CustGeomFile, '/', '_') + -- concateno il file alla path + local sCustomPathFile = CustGeomPath..CustGeomFile + local nNewPart + local nNewLayer + local nNewEnt + local nTypeEnt + local sTypeInfo + local cColor + + -- provo ad inserire + MakeFaceGeom = not EgtInsertFile( sCustomPathFile) + + -- se fallito inserimento file dò un messaggio di errore + if MakeFaceGeom then + EC = ErrorBase + 51 + EM = string.format( EgtDoorsMsg[457], sCustomPathFile) + else + + nNewPart = EgtGetNext(Pz) -- nome nuovo pezzo + nNewLayer = EgtGetFirstInGroup( nNewPart) -- ottengo nuovo layer + + -- riloco tutti i nuovi layer dal nuovo pezzo al pezzo corrente + while nNewLayer do + + nNewEnt = EgtGetFirstInGroup( nNewLayer) -- ottengo nuova entità + + while nNewEnt do + + -- controllo se ha dei colori e le note giuste per cambiare lo spessore + nTypeEnt = EgtGetType( nNewEnt) + sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor') + cColor = EgtGetCalcColor( nNewEnt) + + if sTypeInfo and cColor and DGD.dT then + if string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + if AreSameColor(cColor,RED(),30) then -- se colore rosso allora spessore completo + EgtModifyCurveThickness(nNewEnt, -DGD.dT) + elseif AreSameColor(cColor,LIME(),30) then -- se colore verde allora metà spessore + EgtModifyCurveThickness(nNewEnt, -(DGD.dT/2)) + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', nNewEnt) -- setto 'x' perchè viene mantenuto il centro spessore + else -- altrimenti controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', nNewEnt) -- setto 'x' provvisoriamente + end + end + end + elseif sTypeInfo and string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + -- controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', nNewEnt) -- setto 'x' provvisoriamente + end + end + + EgtRelocateGlob( nNewEnt, Lg) -- riloco nel layer della serratura + nNewEnt = EgtGetFirstInGroup(nNewLayer) + end + nNewLayer = EgtGetNext(nNewLayer) + end + + -- cancello il nuovo pezzo + EgtErase(nNewPart) + end + end + + -- Extra bores Keyway + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,PY10,0), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T10) + EgtSetName(hint_13,EB10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Extra rectangles Keyway + for k = 1, 5 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + + -- se parametri esistenti e dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(PRY10+(WR10/2)),0), RR10, AR10) + EgtModifyCurveThickness(hint_13, -TR10) + EgtSetName(hint_13,ER10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RRS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and EAR and (( das and das > 0) or ( das2 and das2 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, DGD.BACK_SET, + das, nil, nil, das2, SL, + 'keyway') + + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', hint_13, true, TR10, DGD.dT) -- setto 'x' perchè non si sa ancora da quale parte viene applicato + end + end + end + + -- Extra lines Keyway + for k = 1, 5 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -TL10) + EgtSetName(hint_13,EL10) + EgtSetInfo(hint_13,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RLS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', hint_13, true, TL10, DGD.dT) -- setto 'x' perchè non si sa ancora da quale parte viene applicato + end + end + end + + -- Extra bores Secure + for k = 11, 20 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] or 0 + local PY10 = tExtraBore[k][4] or 0 + local EB10 = tExtraBore[k][5] + local RBS10 = tExtraBore[k][6] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_13 = EgtCircle( Lg, Point3d(PX10,-PY10,0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -T10) + EgtSetName(hint_13,EB10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RBS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_13, 'ProbeSide', '1') + end + end + end + end + + -- Extra rectangles Secure + for k = 6, 10 do + + local LR10 = tExtraRect[k][1] + local WR10 = tExtraRect[k][2] + local RR10 = tExtraRect[k][3] + local TR10 = tExtraRect[k][4] + local PRX10 = tExtraRect[k][5] or 0 + local PRY10 = tExtraRect[k][6] or 0 + local AR10 = tExtraRect[k][7] + local ER10 = tExtraRect[k][8] + local RRS10 = tExtraRect[k][9] + + -- se dimensioni rettangolo idonee + if LR10 and WR10 and TR10 and ER10 then + if LR10 > 0 and WR10 > 0 and TR10 ~= 0 and ER10 ~= '' and + (2*RR10) < LR10 and (2*RR10) < WR10 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AR10 and abs(AR10) >= 360 then + while abs(AR10) >= 360 do + AR10 = AR10 + EgtIf( AR10 > 0, -360, 360) + end + end + + hint_13 = MakeRectWithFillet( Lg, Point3d((PRX10-(LR10/2)),(-PRY10-(WR10/2)),0), Point3d((PRX10+(LR10/2)),(-PRY10+(WR10/2)),0), RR10, AR10) + EgtModifyCurveThickness(hint_13, -TR10) + EgtSetName(hint_13,ER10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RRS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- se rettangolo sborda faccio antischeggia + if nDrawMach > 0 and EAR and (( das and das > 0) or ( das2 and das2 > 0)) then + -- creo percorso anti-scheggia se rettangolo sborda + hint_14, hint_15, hint_10, hint_11 = MakeAspOnStrikeRect( Lg, hint_13, LR10, WR10, TR10, + DGD.dT, PRX10, PRY10, RRS10, DGD.BACK_SET, + das, true, nil, das2, SL, + 'secure') + if hint_14 then + EgtSetName( hint_14, ASG) + EgtSetInfo( hint_14, 'NotCheckDir', '1') + EgtSetInfo( hint_14, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_14, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_14, 'ProbeSide', '1') + end + end + if hint_15 then + EgtSetName( hint_15, ASG) + EgtSetInfo( hint_15, 'NotCheckDir', '1') + EgtSetInfo( hint_15, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_15, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_15, 'ProbeSide', '1') + end + end + if hint_10 then + EgtSetName( hint_10, ASGR) + EgtSetInfo( hint_10, 'NotCheckDir', '1') + EgtSetInfo( hint_10, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_10, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_10, 'ProbeSide', '1') + end + end + if hint_11 then + EgtSetName( hint_11, ASGR) + EgtSetInfo( hint_11, 'NotCheckDir', '1') + EgtSetInfo( hint_11, 'SideDoor', 'Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint_11, 'ReferHw', RRS10) -- setto la nota che indica a cosa è riferita, false: per backset true: per door side + if pbs and pbs > 1 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_11, 'ProbeSide', '1') + end + end + end + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', hint_13, true, TR10, DGD.dT) -- setto 'x' perchè non si sa ancora da quale parte viene applicato + end + end + end + + -- Extra lines Secure + for k = 6, 10 do + + local LL10 = tExtraLine[k][1] + local TL10 = tExtraLine[k][2] + local PLX10 = tExtraLine[k][3] or 0 + local PLY10 = tExtraLine[k][4] or 0 + local AL10 = tExtraLine[k][5] + local EL10 = tExtraLine[k][6] + local RLS10 = tExtraLine[k][7] + + -- se parametri esistenti e dimensioni linea idonee + if LL10 and TL10 and EL10 then + if LL10 > 0 and TL10 ~= 0 and EL10 ~= '' and + AL10 < 360 and AL10 > -360 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + if AL10 and abs(AL10) >= 360 then + while abs(AL10) >= 360 do + AL10 = AL10 + EgtIf( AL10 > 0, -360, 360) + end + end + + hint_13 = EgtLinePDL( Lg, Point3d( PLX10,-PLY10,0), AL10, LL10, GDB_RT.LOC) + EgtModifyCurveThickness(hint_13, -TL10) + EgtSetName(hint_13,EL10) + EgtSetInfo(hint_13,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_13,'ReferHw',RLS10) -- setto la nota che indicaa cosa è riferita, false: per backset true: per door side + -- setto nota per correzione profondità con probe + -- se mantiene profondità e non è a spessore passante + SetProbeProperty( kbs, 1, pbs, 'x', hint_13, true, TL10, DGD.dT) -- setto 'x' perchè non si sa ancora da quale parte viene applicato + end + end + end + + -- aggiungo foro probe + if nDrawMach > 0 and posh and L then + + local dPosProbe = 0 + local sPositiveSuffixProbe = '' + local sNegativeSuffixProbe = '' + + if posp and posp > 0 then + dPosProbe = (L/2) + posp + if ( SL == 'R' and DGD.Push) or ( SL == 'L' and not DGD.Push) then + sPositiveSuffixProbe = '_NEG' + sNegativeSuffixProbe = '_POS' + else + sPositiveSuffixProbe = '_POS' + sNegativeSuffixProbe = '_NEG' + end + end + + local pCentr = Point3d( dPosProbe, posh, 0) + local hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + + -- verifico se devo forzare direzione orizzontale o seguire il profilo + local sSideDoorInfo + if DGC.Fpd then + sSideDoorInfo = 'Lock' + else + sSideDoorInfo = EgtIf( dl, 'Lock', 'Side') + end + + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sPositiveSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + if dPosProbe > 0 then + pCentr = Point3d( -dPosProbe, posh, 0) + hintPr = EgtArc( Lg, pCentr, 1, 0, -360, 0, GDB_RT.LOC) + if hintPr then + EgtModifyCurveThickness( hintPr, -10) + EgtSetName( hintPr, LH..sNegativeSuffixProbe) + EgtSetInfo( hintPr, 'SideDoor', sSideDoorInfo) + end + end + end + end + + if EC == 0 and nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not dws then -- se frame viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto) + + -- se la sezione strike supera 1/6 dello spessore porta (se è un frame drf vale 0.1 e crea sempre regione) + -- disegno sezione ribasso su faccia superiore/inferiore porta + if fhb > drf then + + -- setto griglia dietro per l'ingombro sicuramente esistente + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + local nIdSideBoxUp + local nIdSideBoxUp2 + if LS > 0 then + nIdSideBoxUp = EgtRectangle2P( Lg, Point3d(-(L/2)+D_SS,0,((H/2)+HS)), Point3d(-(L/2)+D_SS+LS,-fhb,((H/2)+HS)), GDB_RT.GRID) + if IS > 0 then + nIdSideBoxUp2 = EgtRectangle2P( Lg, Point3d(-(L/2)+D_SS+IS,0,((H/2)+HS)), Point3d(-(L/2)+D_SS+IS+LS,-fhb,((H/2)+HS)), GDB_RT.GRID) + end + end + if nIdSideBoxUp then + EgtModifyCurveThickness(nIdSideBoxUp, -(HS+H)) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nIdSideBoxUp2 then + EgtModifyCurveThickness(nIdSideBoxUp2, -(HS+H)) + EgtSetName( nIdSideBoxUp2, 'upper') + EgtSetInfo( nIdSideBoxUp2, 'SideDoor', 'upper') + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + else -- altrimenti frame viene disposto sul lato wide + + local nIdSideBoxUp + + if nGeom1st then + nIdSideBoxUp = EgtCopyGlob( nGeom1st, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom2st then + nIdSideBoxUp = EgtCopyGlob( nGeom2st, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom1 then + nIdSideBoxUp = EgtCopyGlob( nGeom1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom2 then + nIdSideBoxUp = EgtCopyGlob( nGeom2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom3 then + nIdSideBoxUp = EgtCopyGlob( nGeom3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if nGeom4 then + nIdSideBoxUp = EgtCopyGlob( nGeom4, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_1 then + nIdSideBoxUp = EgtCopyGlob( hint_1, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_2 then + nIdSideBoxUp = EgtCopyGlob( hint_2, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_3 then + nIdSideBoxUp = EgtCopyGlob( hint_3, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_4 then + nIdSideBoxUp = EgtCopyGlob( hint_4, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_5 then + nIdSideBoxUp = EgtCopyGlob( hint_5, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_6 then + nIdSideBoxUp = EgtCopyGlob( hint_6, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_7 then + nIdSideBoxUp = EgtCopyGlob( hint_7, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + if hint_8 then + nIdSideBoxUp = EgtCopyGlob( hint_8, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + if EC == 0 and D_XE and D_XE ~= 0 then + EgtMove( Lg, Point3d(0,D_XE,0) - ORIG()) + end + + -- Se non Preview + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo( Lg, 'Type' ,'Strike') + EgtSetInfo( Lg, 'Nome' ,sCompoName) + EgtSetInfo( Lg, 'L' ,L) + EgtSetInfo( Lg, 'H' ,H) + EgtSetInfo( Lg, 'T' ,T) + EgtSetInfo( Lg, 'LS' ,LS) + EgtSetInfo( Lg, 'HS' ,HS) + EgtSetInfo( Lg, 'AS' ,AS) + EgtSetInfo( Lg, 'IS' ,IS) + EgtSetInfo( Lg, 'D_SS' ,D_SS) + EgtSetInfo( Lg, 'rs' ,rs) + EgtSetInfo( Lg, 'ls' ,ls) + EgtSetInfo( Lg, 'cl' ,cl) + EgtSetInfo( Lg, 'rf' ,rf) + EgtSetInfo( Lg, 'd' ,d) + EgtSetInfo( Lg, 'p' ,p) + EgtSetInfo( Lg, 'sf' ,sf) + EgtSetInfo( Lg, 'dl' ,dl) + EgtSetInfo( Lg, 'da' ,da) + EgtSetInfo( Lg, 'ech' ,ech) + EgtSetInfo( Lg, 'clc' ,clc) + EgtSetInfo( Lg, 'ccr' ,ccr) + EgtSetInfo( Lg, 'mh' ,mh) + EgtSetInfo( Lg, 'L2' ,L2) + EgtSetInfo( Lg, 'H2' ,H2) + EgtSetInfo( Lg, 'T2' ,T2) + EgtSetInfo( Lg, 'I2' ,I2) + EgtSetInfo( Lg, 'HB2' ,HB2) + EgtSetInfo( Lg, 'TB2' ,TB2) + EgtSetInfo( Lg, 'd2' ,d2) + EgtSetInfo( Lg, 'p2' ,p2) + EgtSetInfo( Lg, 's' ,s) + EgtSetInfo( Lg, 'FBD' ,FBD) + EgtSetInfo( Lg, 'FBP' ,FBP) + EgtSetInfo( Lg, 'AB' ,AB) + EgtSetInfo( Lg, 'L3' ,L3) + EgtSetInfo( Lg, 'H3' ,H3) + EgtSetInfo( Lg, 'T3' ,T3) + EgtSetInfo( Lg, 'I3' ,I3) + EgtSetInfo( Lg, 'd3' ,d3) + EgtSetInfo( Lg, 'p3' ,p3) + EgtSetInfo( Lg, 's3' ,s3) + EgtSetInfo( Lg, 'est' ,est) + EgtSetInfo( Lg, 'kbs' ,kbs) + EgtSetInfo( Lg, 'pbs' ,pbs) + EgtSetInfo( Lg, 'invG' ,invG) + EgtSetInfo( Lg, 'posh' ,posh) + EgtSetInfo( Lg, 'posp' ,posp) + EgtSetInfo( Lg, 'mkrev' ,mkrev) + EgtSetInfo( Lg, 'jn' ,jn) + EgtSetInfo( Lg, 'jn2' ,jn2) + EgtSetInfo( Lg, 'jnb' ,jnb) + EgtSetInfo( Lg, 'fht' ,fht) + EgtSetInfo( Lg, 'fhb' ,fhb) + EgtSetInfo( Lg, 'drf' ,drf) + EgtSetInfo( Lg, 'dws' ,dws) + EgtSetInfo( Lg, 'dthd' ,dthd) + EgtSetInfo( Lg, 'SL' ,SL) + EgtSetInfo( Lg, 'D_X' ,D_X) + EgtSetInfo( Lg, 'D_X3' ,D_X3) + EgtSetInfo( Lg, 'DH_X' ,DH_X) + EgtSetInfo( Lg, 'D_XE' ,D_XE) + + EgtSetInfo( Lg, 'CustGeomFile' ,CustGeomFile) + EgtSetInfo( Lg, 'CustGeomPath' ,CustGeomPath) + + EgtSetInfo( Lg, 'LG' ,LG) + EgtSetInfo( Lg, 'LG2' ,LG2) + EgtSetInfo( Lg, 'LG3' ,LG3) + EgtSetInfo( Lg, 'LM' ,LM) + EgtSetInfo( Lg, 'LA' ,LA) + EgtSetInfo( Lg, 'LA2' ,LA2) + EgtSetInfo( Lg, 'LA3' ,LA3) + EgtSetInfo( Lg, 'CH' ,CH) + EgtSetInfo( Lg, 'CLC' ,CLC) + EgtSetInfo( Lg, 'LGH' ,LGH) + EgtSetInfo( Lg, 'LMP' ,LMP) + EgtSetInfo( Lg, 'EAR' ,EAR) + EgtSetInfo( Lg, 'das' ,das) + EgtSetInfo( Lg, 'ASG' ,ASG) + EgtSetInfo( Lg, 'das2' ,das2) + EgtSetInfo( Lg, 'ASGR' ,ASGR) + 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 Strike diff --git a/LuaLibs/Viewer.lua b/LuaLibs/Viewer.lua new file mode 100644 index 0000000..943c9ea --- /dev/null +++ b/LuaLibs/Viewer.lua @@ -0,0 +1,720 @@ +-- +-- 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 +-- +-- Viewer.lua by EgalWare s.r.l. 2016.07.05 +-- Autore: Filippo Monchi +-- Spioncino + +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.04.29 V2.001 FM Update for aluminum material +-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.20 V2.003 FM Use parameter .ITP (Internal Path) from template lua file instead of function EgtGetSourceDir(1) +-- 2022.07.27 V2.004 FM Modification to use compiled code + +-- Tavola per definizione modulo (serve ma non usata) +local Viewer = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Funzione di sistemazione parametri +function Viewer.AdjustParams( tMhPar) + + -- se porta steel o aluminum + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.est = true + else + tMhPar.est = nil + end + + if tMhPar.T1 then + if tMhPar.T1 == -0.5 then + tMhPar.T1 = DGD.dT / 2 + elseif tMhPar.T1 == -1 then + tMhPar.T1 = DGD.dT + end + end + + if tMhPar.T2 then + if tMhPar.T2 == -0.5 then + tMhPar.T2 = DGD.dT / 2 + elseif tMhPar.T2 == -1 then + tMhPar.T2 = DGD.dT + end + end + + if tMhPar.T3 then + if tMhPar.T3 == -0.5 then + tMhPar.T3 = DGD.dT / 2 + elseif tMhPar.T3 == -1 then + tMhPar.T3 = DGD.dT + end + end + + if tMhPar.T4 then + if tMhPar.T4 == -0.5 then + tMhPar.T4 = DGD.dT / 2 + elseif tMhPar.T4 == -1 then + tMhPar.T4 = DGD.dT + end + end + + -- extra bores + if tMhPar.T10 then + if tMhPar.T10 == -0.5 then + tMhPar.T10 = DGD.dT / 2 + elseif tMhPar.T10 == -1 or tMhPar.T10 > DGD.dT then + tMhPar.T10 = DGD.dT + end + end + + if tMhPar.T11 then + if tMhPar.T11 == -0.5 then + tMhPar.T11 = DGD.dT / 2 + elseif tMhPar.T11 == -1 or tMhPar.T11 > DGD.dT then + tMhPar.T11 = DGD.dT + end + end + + if tMhPar.T12 then + if tMhPar.T12 == -0.5 then + tMhPar.T12 = DGD.dT / 2 + elseif tMhPar.T12 == -1 or tMhPar.T12 > DGD.dT then + tMhPar.T12 = DGD.dT + end + end + + if tMhPar.T13 then + if tMhPar.T13 == -0.5 then + tMhPar.T13 = DGD.dT / 2 + elseif tMhPar.T13 == -1 or tMhPar.T13 > DGD.dT then + tMhPar.T13 = DGD.dT + end + end + + if tMhPar.T14 then + if tMhPar.T14 == -0.5 then + tMhPar.T14 = DGD.dT / 2 + elseif tMhPar.T14 == -1 or tMhPar.T14 > DGD.dT then + tMhPar.T14 = DGD.dT + end + end + + if tMhPar.T15 then + if tMhPar.T15 == -0.5 then + tMhPar.T15 = DGD.dT / 2 + elseif tMhPar.T15 == -1 or tMhPar.T15 > DGD.dT then + tMhPar.T15 = DGD.dT + end + end + + if tMhPar.T16 then + if tMhPar.T16 == -0.5 then + tMhPar.T16 = DGD.dT / 2 + elseif tMhPar.T16 == -1 or tMhPar.T16 > DGD.dT then + tMhPar.T16 = DGD.dT + end + end + + if tMhPar.T17 then + if tMhPar.T17 == -0.5 then + tMhPar.T17 = DGD.dT / 2 + elseif tMhPar.T17 == -1 or tMhPar.T17 > DGD.dT then + tMhPar.T17 = DGD.dT + end + end + + if tMhPar.T18 then + if tMhPar.T18 == -0.5 then + tMhPar.T18 = DGD.dT / 2 + elseif tMhPar.T18 == -1 or tMhPar.T18 > DGD.dT then + tMhPar.T18 = DGD.dT + end + end + + if tMhPar.T19 then + if tMhPar.T19 == -0.5 then + tMhPar.T19 = DGD.dT / 2 + elseif tMhPar.T19 == -1 or tMhPar.T19 > DGD.dT then + tMhPar.T19 = DGD.dT + end + end + + if tMhPar.T20 then + if tMhPar.T20 == -0.5 then + tMhPar.T20 = DGD.dT / 2 + elseif tMhPar.T20 == -1 or tMhPar.T20 > DGD.dT then + tMhPar.T20 = DGD.dT + end + end + + if tMhPar.T21 then + if tMhPar.T21 == -0.5 then + tMhPar.T21 = DGD.dT / 2 + elseif tMhPar.T21 == -1 or tMhPar.T21 > DGD.dT then + tMhPar.T21 = DGD.dT + end + end + + if tMhPar.T22 then + if tMhPar.T22 == -0.5 then + tMhPar.T22 = DGD.dT / 2 + elseif tMhPar.T22 == -1 or tMhPar.T22 > DGD.dT then + tMhPar.T22 = DGD.dT + end + end + + if tMhPar.T23 then + if tMhPar.T23 == -0.5 then + tMhPar.T23 = DGD.dT / 2 + elseif tMhPar.T23 == -1 or tMhPar.T23 > DGD.dT then + tMhPar.T23 = DGD.dT + end + end + + if tMhPar.T24 then + if tMhPar.T24 == -0.5 then + tMhPar.T24 = DGD.dT / 2 + elseif tMhPar.T24 == -1 or tMhPar.T24 > DGD.dT then + tMhPar.T24 = DGD.dT + end + end + + if tMhPar.T25 then + if tMhPar.T25 == -0.5 then + tMhPar.T25 = DGD.dT / 2 + elseif tMhPar.T25 == -1 or tMhPar.T25 > DGD.dT then + tMhPar.T25 = DGD.dT + end + end + + if tMhPar.T26 then + if tMhPar.T26 == -0.5 then + tMhPar.T26 = DGD.dT / 2 + elseif tMhPar.T26 == -1 or tMhPar.T26 > DGD.dT then + tMhPar.T26 = DGD.dT + end + end + + if tMhPar.T27 then + if tMhPar.T27 == -0.5 then + tMhPar.T27 = DGD.dT / 2 + elseif tMhPar.T27 == -1 or tMhPar.T27 > DGD.dT then + tMhPar.T27 = DGD.dT + end + end + + if tMhPar.T28 then + if tMhPar.T28 == -0.5 then + tMhPar.T28 = DGD.dT / 2 + elseif tMhPar.T28 == -1 or tMhPar.T28 > DGD.dT then + tMhPar.T28 = DGD.dT + end + end + + if tMhPar.T29 then + if tMhPar.T29 == -0.5 then + tMhPar.T29 = DGD.dT / 2 + elseif tMhPar.T29 == -1 or tMhPar.T29 > DGD.dT then + tMhPar.T29 = DGD.dT + end + end + + -- percorso custom nge + if tMhPar.CGF and tMhPar.CGP then + if string.len(tMhPar.CGF) > 0 and string.len(tMhPar.CGP) == 0 then + tMhPar.CGP = tMhPar.ITP + end + end + + return tMhPar +end + +-- Funzione di disegno +function Viewer.Draw( tViwr, bPreview, bRunByCompo, nDrawMach) + + local est = tViwr.est + + -- Nome file custom geometry e percorso file da caricare + local CustGeomFile = tViwr.CGF or '' + local CustGeomPath = tViwr.CGP or '' + -- tabelle per i fori, rettangoli e linee opzionali + local tExtraBore = {} + -- Assegno le dimensioni geometrie KEYWAY + local D1 = tViwr.D1 + local T1 = tViwr.T1 + local ms = tViwr.ms + local D2 = tViwr.D2 + local T2 = tViwr.T2 + local I2 = tViwr.I2 + local AV = tViwr.AV + local mc = tViwr.mc + -- inserimento dati nella tabella fori Keyway + table.insert( tExtraBore, { tViwr.D10, tViwr.T10, tViwr.PX10, tViwr.PY10, tViwr.EB10}) + table.insert( tExtraBore, { tViwr.D11, tViwr.T11, tViwr.PX11, tViwr.PY11, tViwr.EB11}) + table.insert( tExtraBore, { tViwr.D12, tViwr.T12, tViwr.PX12, tViwr.PY12, tViwr.EB12}) + table.insert( tExtraBore, { tViwr.D13, tViwr.T13, tViwr.PX13, tViwr.PY13, tViwr.EB13}) + table.insert( tExtraBore, { tViwr.D14, tViwr.T14, tViwr.PX14, tViwr.PY14, tViwr.EB14}) + table.insert( tExtraBore, { tViwr.D15, tViwr.T15, tViwr.PX15, tViwr.PY15, tViwr.EB15}) + table.insert( tExtraBore, { tViwr.D16, tViwr.T16, tViwr.PX16, tViwr.PY16, tViwr.EB16}) + table.insert( tExtraBore, { tViwr.D17, tViwr.T17, tViwr.PX17, tViwr.PY17, tViwr.EB17}) + table.insert( tExtraBore, { tViwr.D18, tViwr.T18, tViwr.PX18, tViwr.PY18, tViwr.EB18}) + table.insert( tExtraBore, { tViwr.D19, tViwr.T19, tViwr.PX19, tViwr.PY19, tViwr.EB19}) + -- Assegno le dimensioni geometrie SECURE + local D3 = tViwr.D3 + local T3 = tViwr.T3 + local msd = tViwr.msd + local D4 = tViwr.D4 + local T4 = tViwr.T4 + local I4 = tViwr.I4 + local AVd = tViwr.AVd + local mcd = tViwr.mcd + -- inserimento dati nella tabella fori Secure + table.insert( tExtraBore, { tViwr.D20, tViwr.T20, tViwr.PX20, tViwr.PY20, tViwr.EB20}) + table.insert( tExtraBore, { tViwr.D21, tViwr.T21, tViwr.PX21, tViwr.PY21, tViwr.EB21}) + table.insert( tExtraBore, { tViwr.D22, tViwr.T22, tViwr.PX22, tViwr.PY22, tViwr.EB22}) + table.insert( tExtraBore, { tViwr.D23, tViwr.T23, tViwr.PX23, tViwr.PY23, tViwr.EB23}) + table.insert( tExtraBore, { tViwr.D24, tViwr.T24, tViwr.PX24, tViwr.PY24, tViwr.EB24}) + table.insert( tExtraBore, { tViwr.D25, tViwr.T25, tViwr.PX25, tViwr.PY25, tViwr.EB25}) + table.insert( tExtraBore, { tViwr.D26, tViwr.T26, tViwr.PX26, tViwr.PY26, tViwr.EB26}) + table.insert( tExtraBore, { tViwr.D27, tViwr.T27, tViwr.PX27, tViwr.PY27, tViwr.EB27}) + table.insert( tExtraBore, { tViwr.D28, tViwr.T28, tViwr.PX28, tViwr.PY28, tViwr.EB28}) + table.insert( tExtraBore, { tViwr.D29, tViwr.T29, tViwr.PX29, tViwr.PY29, tViwr.EB29}) + -- Assegno le label degli attributi porta KEYWAY + local LSU = tViwr.LSU + local SCU = tViwr.SCU + -- Assegno le label degli attributi porta SECURE + local LSD = tViwr.LSD + local SCD = tViwr.SCD + -- variabili per messaggi e settaggi vari + local sCompoName = tViwr.Nome + local nCompoNpar = tViwr.Npar + local sCompoPath = tViwr.Path + -- variabili per messaggi di errore + local sNamePar6 = tViwr.NPI2 or 'I2' + local sNamePar7 = tViwr.NPAV or 'Screw direction on KEYWAY side' + local sNamePar14 = tViwr.NPI4 or 'I4' + local sNamePar15 = tViwr.NPAVd or 'Screw direction on SECURE side' + + -- RunByComponetInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1400 + + if not bRunByCompo then + RC = false + end + + -- se non definita o parametri relativi alla definizione dei percorsi sono mancanti, la setto per non creare geometria di lavorazione + if not nDrawMach then + nDrawMach = 0 + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- Verifica delle dimensioni, alcune condizioni vengono verificate solo se è abilitata la creazione dei percorsi di lavorazione + if ms and AV and ( AV < 0 or AV > 180) then + EC = 1 + EM = string.format(EgtDoorsMsg[403],sNamePar7,AV,0,180, sCompoPath) -- il parametro 'AV' deve essere compreso tra + AV = 90 + elseif msd and AVd and ( AVd < 0 or AVd > 180) then + EC = 2 + EM = string.format(EgtDoorsMsg[403],sNamePar15,AVd,0,180, sCompoPath) -- il parametro 'AVd' deve essere compreso tra + AVd = 90 + elseif ms and I2 and D1 and I2 <= D1 then -- se fori vite abilitati e interasse fori < diametro foro maniglia + EC = 3 + EM = string.format(EgtDoorsMsg[420],sNamePar6,EgtToUiUnits(I2),EgtToUiUnits(D1), sCompoPath) -- il parametro interasse fori deve essere > del diametro foro spioncino + I2 = D1 + 10 + elseif msd and D3 and I4 and I4 <= D3 then -- se fori vite abilitati e interasse fori < diametro foro maniglia + EC = 4 + EM = string.format(EgtDoorsMsg[420],sNamePar33,EgtToUiUnits(I8),EgtToUiUnits(D7), sCompoPath) -- il parametro interasse fori deve essere > del diametro foro maniglia + I4 = D3 + 10 + 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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer principale + EgtSetName(Lg,sCompoName) + + local hint1, hint2, hint3, hint4, hint5 -- variabili entità geometriche + local hint, hint_2, hint_3 -- variabili percorsi + + -- Gestione file custom + local MakeFaceGeom = true + + -- caricamento del file custom + if string.len(CustGeomFile) > 0 and string.find( string.lower(CustGeomFile), '.nge') > 0 then + + -- sostituisco il carattere '\' con '_' nel nome file + CustGeomFile = string.gsub(CustGeomFile, '\\', '_') + CustGeomFile = string.gsub(CustGeomFile, '/', '_') + -- concateno il file alla path + local sCustomPathFile = CustGeomPath..CustGeomFile + local nNewPart + local nNewLayer + local nNewEnt + local nTypeEnt + local sTypeInfo + local cColor + + -- provo ad inserire + MakeFaceGeom = not EgtInsertFile( sCustomPathFile) + + -- se fallito inserimento file dò un messaggio di errore + if MakeFaceGeom then + EC = ErrorBase + 10 + EM = string.format( EgtDoorsMsg[457], sCustomPathFile) + else + + nNewPart = EgtGetNext(Pz) -- nome nuovo pezzo + nNewLayer = EgtGetFirstInGroup( nNewPart) -- ottengo nuovo layer + + -- riloco tutti i nuovi layer dal nuovo pezzo al pezzo corrente + while nNewLayer do + + nNewEnt = EgtGetFirstInGroup( nNewLayer) -- ottengo nuova entità + + while nNewEnt do + + -- controllo se è un cerchio e se ha dei colori e le note giuste per cambiare lo spessore + nTypeEnt = EgtGetType( nNewEnt) + sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor') + cColor = EgtGetCalcColor( nNewEnt) + + if sTypeInfo and cColor and DGD.dT then + if string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + if AreSameColor(cColor,RED(),30) then -- se colore rosso allora spessore completo + EgtModifyCurveThickness(nNewEnt, -DGD.dT) + elseif AreSameColor(cColor,LIME(),30) then -- se colore verde allora metà spessore + EgtModifyCurveThickness(nNewEnt, -(DGD.dT/2)) + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 then + if DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + else -- altrimenti controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 then + if DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + end + end + elseif sTypeInfo and string.lower(sTypeInfo) == 'keyway' or string.lower(sTypeInfo) == 'secure' then + -- controllo che lo spessore non supera quello della porta, se lo supera lo setto = spessore porta + local dTh = EgtCurveThickness( nNewEnt) + if abs(dTh) > DGD.dT then + EgtModifyCurveThickness( nNewEnt, EgtIf( dTh > 0, DGD.dT, -DGD.dT)) + elseif abs(dTh) < DGD.dT then + -- se mantiene profondità e non è a spessore passante + if kbs and kbs > 1 then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'x') -- setto 'x' provvisoriamente + end + if pbs and pbs > 1 then + if DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( nNewEnt, 'ProbeSide', '1') + end + end + end + end + + EgtRelocateGlob( nNewEnt, Lg) -- riloco nel layer della serratura + nNewEnt = EgtGetFirstInGroup(nNewLayer) + end + nNewLayer = EgtGetNext(nNewLayer) + end + + -- cancello il nuovo pezzo + EgtErase(nNewPart) + end + end + + -- Costruzione della geometria KEYWAY + -- se dimensioni foro spioncino idonee + if D1 and T1 and LSU then + if D1 > 0 and T1 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_1 = EgtCircle( Lg, Point3d(0,0,0), D1/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_1, -T1) + EgtSetName(hint_1,LSU) + EgtSetInfo(hint_1,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + + if ms then -- se devo fare le viti Keyway + + if D2 and T2 and SCU then + + -- se dimensioni foro vite idonee + if D2 > 0 and T2 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not I2 then + I2 = D1 + end + + hint_2 = EgtCircle( Lg, Point3d(-((I2/2) * sin(AV)),((I2/2) * cos(AV)),0), D2/2 , GDB_RT.LOC) + hint_3 = EgtCircle( Lg, Point3d(((I2/2) * sin(AV)),-((I2/2) * cos(AV)),0), D2/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_2, -T2) + EgtModifyCurveThickness(hint_3, -T2) + EgtSetName(hint_2,SCU) + EgtSetName(hint_3,SCU) + EgtSetInfo(hint_2,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_3,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + + if mc then -- se fori vite a croce + hint_2 = EgtCircle( Lg, Point3d(-((I2/2) * sin(AV+90)),((I2/2) * cos(AV+90)),0), D2/2 , GDB_RT.LOC) + hint_3 = EgtCircle( Lg, Point3d(((I2/2) * sin(AV+90)),-((I2/2) * cos(AV+90)),0), D2/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_2, -T2) + EgtModifyCurveThickness(hint_3, -T2) + EgtSetName(hint_2,SCU) + EgtSetName(hint_3,SCU) + EgtSetInfo(hint_2,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_3,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + end + end + + -- Extra bores Keyway + for k = 1, 10 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] + local PY10 = tExtraBore[k][4] + local EB10 = tExtraBore[k][5] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not PX10 then + PX10 = 0 + end + + if not PY10 then + PY10 = 0 + end + + hint_3 = EgtCircle( Lg, Point3d(PX10,PY10,0), D10/2, GDB_RT.LOC) + EgtModifyCurveThickness(hint_3, -T10) + EgtSetName(hint_3,EB10) + EgtSetInfo(hint_3,'SideDoor','Keyway') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + end + + -- Costruzione della geometria lato Secure + -- se dimensioni foro spioncino idonee + if D3 and T3 and LSD then + if D3 > 0 and T3 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + hint_1 = EgtCircle( Lg, Point3d(0,0,0), D3/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_1, -T3) + EgtSetName(hint_1,LSD) + EgtSetInfo(hint_1,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + + if msd then -- se devo fare le viti + + -- se dimensioni foro vite idonee + if D4 and T4 and SCD then + if D4 > 0 and T4 ~= 0 then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer del foro serraura SECURE + EgtSetName(Lg,sCompoName) + end + + if not I4 then + I4 = D3 + end + + hint_2 = EgtCircle( Lg, Point3d(-((I4/2) * sin(AVd)),((I4/2) * cos(AVd)),0), D4/2 , GDB_RT.LOC) + hint_3 = EgtCircle( Lg, Point3d(((I4/2) * sin(AVd)),-((I4/2) * cos(AVd)),0), D4/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_2, -T4) + EgtModifyCurveThickness(hint_3, -T4) + EgtSetName(hint_2,SCD) + EgtSetName(hint_3,SCD) + EgtSetInfo(hint_2,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_3,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + + if mcd then -- se fori vite a croce + hint_2 = EgtCircle( Lg, Point3d(-((I4/2) * sin(AVd+90)),((I4/2) * cos(AVd-90)),0), D4/2 , GDB_RT.LOC) + hint_3 = EgtCircle( Lg, Point3d(((I4/2) * sin(AVd+90)),-((I4/2) * cos(AVd-90)),0), D4/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_2, -T4) + EgtModifyCurveThickness(hint_3, -T4) + EgtSetName(hint_2,SCD) + EgtSetName(hint_3,SCD) + EgtSetInfo(hint_2,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo(hint_3,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + end + end + + -- Extra bores Secure + for k = 11, 20 do + + local D10 = tExtraBore[k][1] + local T10 = tExtraBore[k][2] + local PX10 = tExtraBore[k][3] + local PY10 = tExtraBore[k][4] + local EB10 = tExtraBore[k][5] + + -- se dimensioni foro serratura idonee + if D10 and T10 and EB10 then + if D10 > 0 and T10 ~= 0 and EB10 ~= '' then + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + if not PX10 then + PX10 = 0 + end + + if not PY10 then + PY10 = 0 + end + + hint_3 = EgtCircle( Lg, Point3d(PX10,-PY10,0), D10/2 , GDB_RT.LOC) + EgtModifyCurveThickness(hint_3, -T10) + EgtSetName(hint_3,EB10) + EgtSetInfo(hint_3,'SideDoor','Secure') -- setto una nota per indicare su che lato della porta deve essere spostato + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if Lg then + EgtSetColor(Lg,AQUA()) + end + else + if Lg then + EgtSetColor(Lg,ORANGE()) + end + end + else -- altrimenti non Preview + + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer della cerniera + EgtSetInfo(Lg,'Type' ,'Viewer') + EgtSetInfo(Lg,'Nome' ,sCompoName) + + EgtSetInfo(Lg,'D1' ,D1) + EgtSetInfo(Lg,'T1' ,T1) + EgtSetInfo(Lg,'ms' ,ms) + EgtSetInfo(Lg,'D2' ,D2) + EgtSetInfo(Lg,'T2' ,T2) + EgtSetInfo(Lg,'I2' ,I2) + EgtSetInfo(Lg,'AV' ,AV) + EgtSetInfo(Lg,'mc' ,mc) + + EgtSetInfo(Lg,'D3' ,D3) + EgtSetInfo(Lg,'T3' ,T3) + EgtSetInfo(Lg,'msd' ,msd) + EgtSetInfo(Lg,'D4' ,D4) + EgtSetInfo(Lg,'T4' ,T4) + EgtSetInfo(Lg,'I4' ,I4) + EgtSetInfo(Lg,'AVd' ,AVd) + EgtSetInfo(Lg,'mcd' ,mcd) + EgtSetInfo(Lg,'est' ,est) + + EgtSetInfo(Lg,'CustGeomFile' ,CustGeomFile) + EgtSetInfo(Lg,'CustGeomPath' ,CustGeomPath) + + EgtSetInfo(Lg,'LSU' ,LSU) + EgtSetInfo(Lg,'SCU' ,SCU) + EgtSetInfo(Lg,'LSD' ,LSD) + EgtSetInfo(Lg,'SCD' ,SCD) + EgtSetInfo(Lg,'Path' ,sCompoPath) + end + + return EC, EM, Lg +end + +return Viewer diff --git a/LuaLibs/VisionCutOut.lua b/LuaLibs/VisionCutOut.lua new file mode 100644 index 0000000..c320437 --- /dev/null +++ b/LuaLibs/VisionCutOut.lua @@ -0,0 +1,1531 @@ +-- +-- 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 +-- +-- VisionCutOut.lua by EgalWare s.r.l. 2016.06.24 +-- Autore: Dario Sassi +-- VisionCutOut dati i valori 'L' e 'H' e con nome attributo + +-- 2017.10.18 V1.0a1 FM Start point path near lock side +-- 2017.10.18 V1.0a2 FM Modify bevel arc path name according to swing +-- 2017.12.07 V1.0a3 FM Add Cleancorner path +-- 2018.01.11 V1.0a4 FM Add Hatching +-- 2018.08.24 V1.0a5 FM Add internal radius on clean-corner paths +-- 2018.10.09 V1.0a6 FM Check better the error condition with radius on clean corner path +-- 2018.12.11 V1.0a7 FM Manage fillet on corner of rectangle shape and calculate also for hatching (drop) +-- 2018.12.12 V1.0a8 FM Apply hatching on circle shape too +-- 2019.10.02 V1.019 FM Manage steel option (disable generation of some geometries) +-- 2019.10.07 V1.01a FM Manage cut by saw +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.12.06 V2.001 FM Fix error on not initialized variable d into hatching section +-- 2020.04.29 V2.002 FM Update for aluminum material +-- 2021.01.22 V3.000 FM Manage better checking error on tools and dimension when produce flag is false +-- 2021.04.23 V3.001 FM Manage note to indicate if hatching is present +-- 2021.04.27 V3.002 FM Manage special region on hatching paths to remove pods under those +-- 2021.06.08 V3.003 FM Manage diamond shape +-- 2022.01.17 V3.004 FM Manage Split door along door height +-- 2022.04.28 V3.005 FM Manage Split door along door width +-- 2022.07.06 V3.006 FM Fix error on split door along door height +-- 2022.07.27 V3.007 FM Modification to use compiled code +-- 2022.09.23 V3.008 FM Manage side groove for clips +-- 2023.02.03 V3.009 FM Fix error on disabled clean cone parameter ccn +-- 2024.10.19 V3.010 FM Manage drop path with back and forth +-- 2024.11.14 V3.011 FM Manage new ConeCleanCorner path by CurrDoorCustomData DGC.Ccm parameter + +-- Tavola per definizione modulo (serve ma non usata) +local VisionCutOut = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local DimMin = 2. -- valore minimo lato + +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 + +local function CalcIntersect( DRP1, hint_ofs, pIni, pEnd, dExtraLen) + + if DRP1 and hint_ofs then + + -- calcolo intersezioni tra percorso offsettato e punto iniziale percorso + local ptInt = EgtIP( DRP1, hint_ofs, pIni) + -- se esiste intersezione muovo il punto al punto intersezione + if ptInt then + -- calcolo la lunghezza tra i due punti + local dDistPoint = dist( pIni, ptInt) + if dDistPoint > 0 then + EgtTrimExtendCurveByLen( DRP1, -(dDistPoint + dExtraLen), pIni) + end + end + -- calcolo intersezioni tra percorso offsettato e punto finale percorso + ptInt = EgtIP( DRP1, hint_ofs, pEnd) + -- se esiste intersezione muovo il punto al punto intersezione + if ptInt then + -- calcolo la lunghezza tra i due punti + local dDistPoint = dist( pEnd, ptInt) + if dDistPoint > 0 then + EgtTrimExtendCurveByLen( DRP1, -(dDistPoint + dExtraLen), pEnd) + end + end + end + + return DRP1 +end + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor(nCircle2, cColor2) + end + end + + return nLine +end + +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 DrawRectangleWithFillet ( Lg, L, H, dThickD, rf) + + local tHint = {} + local hint + local pIni, pEnd, pCen + + -- Costruzione della geometria principale + pIni = Point3d(((L/2)-rf),(H/2),dThickD) + pCen = Point3d(((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d((L/2),((H/2)-rf),dThickD) + 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 c'è stazio per una linea tra i due raccordi + pEnd = Point3d((L/2),-(H/2)+rf,dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(((L/2)-rf),-(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-((L/2)-rf),-(H/2),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),(-(H/2)+rf),dThickD) + pEnd = Point3d(-(L/2),(-(H/2)+rf),dThickD) + 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 c'è stazio per una linea tra i due raccordi + pEnd = Point3d(-(L/2),((H/2)-rf),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d(-((L/2)-rf),((H/2)-rf),dThickD) + pEnd = Point3d(-((L/2)-rf),(H/2),dThickD) + DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs(rf - (L/2)) > GEO.EPS_SMALL then -- se c'è stazio per una linea tra i due raccordi + pEnd = Point3d(((L/2)-rf),(H/2),dThickD) + 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 + EgtInvertCurve( hint) + end + end + + return hint +end + +----------------------------------------------------------------- +local function DrawDiamondWithFillet ( Lg, L, H, dThickD, rf, dRad, sLockSide) + + local tHint = {} + local hint + local pIni, pEnd, pCen + local nLin1, nLin2, nFill + local nLocKindGeom + local ptMid + + -- Costruzione della geometria principale + if rf < dRad then + -- aggiungo le linee + pIni = Point3d(0,(H/2),dThickD) + pEnd = Point3d((L/2),0,dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(0,-(H/2),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-(L/2),0,dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(0,(H/2),dThickD) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if rf > 0 then + -- aggiungo i raccordi + nLin1 = tHint[1] + nLin2 = tHint[2] + nFill = EgtCurveFillet( Lg, nLin1, EgtMP( nLin1), nLin2, EgtMP( nLin2), rf, true, GDB_RT.LOC) + table.insert( tHint, 2, nFill) + nLin1 = tHint[3] + nLin2 = tHint[4] + nFill = EgtCurveFillet( Lg, nLin1, EgtMP( nLin1), nLin2, EgtMP( nLin2), rf, true, GDB_RT.LOC) + table.insert( tHint, 4, nFill) + nLin1 = tHint[5] + nLin2 = tHint[6] + nFill = EgtCurveFillet( Lg, nLin1, EgtMP( nLin1), nLin2, EgtMP( nLin2), rf, true, GDB_RT.LOC) + table.insert( tHint, 6, nFill) + nLin1 = tHint[7] + nLin2 = tHint[1] + nFill = EgtCurveFillet( Lg, nLin1, EgtMP( nLin1), nLin2, EgtMP( nLin2), rf, true, GDB_RT.LOC) + table.insert( tHint, nFill) + end + if sLockSide then + if sLockSide == 'L' then + if rf > 0 then + ptMid = EgtMP( tHint[7]) + else + ptMid = EgtMP( tHint[4]) + end + else + ptMid = EgtMP( tHint[1]) + end + end + nLocKindGeom = 1 + else + pIni = Point3d(0,rf,dThickD) + pCen = Point3d(0,0,dThickD) + pEnd = Point3d(rf,0,dThickD) + DrawAddCircleDrawCircle( pCen, rf, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pCen = Point3d(0,0,dThickD) + pEnd = Point3d(0,-rf,dThickD) + DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pCen = Point3d(0,0,dThickD) + pEnd = Point3d(-rf,0,dThickD) + DrawAddCircleDrawCircle( pCen, rf, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pCen = Point3d(0,0,dThickD) + pEnd = Point3d(0,rf,dThickD) + DrawAddCircleDrawCircle( pCen, rf, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if sLockSide then + if sLockSide == 'L' then + ptMid = Point3d(-rf,0,dThickD) + else + ptMid = Point3d(rf,0,dThickD) + end + end + nLocKindGeom = 2 + 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 + EgtInvertCurve( hint) + end + if ptMid then + EgtChangeClosedCurveStartPoint( hint, ptMid, GDB_RT.GLOB) + end + end + + return hint, nLocKindGeom +end + +----------------------------------------------------------------- +local function DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, nIdPath, dTh) + + local nId, nId1, nId2, nId3, nId4 + + -- faccio gli offset in più e in meno e li unisco con le linee per creare il percorso + nId1 = EgtCopyGlob( nIdPath, Lg) + EgtOffsetCurve( nId1, 0.5) + nId3 = EgtCopyGlob( nIdPath, Lg) + EgtOffsetCurve( nId3, -0.5) + -- inverto il percorso 2 + EgtInvertCurve( nId3) + -- prendo i punti da collegare + local pIni = EgtEP( nId1) + local pEnd = EgtSP( nId3) + nId2 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = EgtEP( nId3) + pEnd = EgtSP( nId1) + nId4 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- creo percorso + nId = EgtCurveCompo( Lg, {nId1,nId2,nId3,nId4}, true) + EgtModifyCurveThickness( nId, dTh) + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( Lg, nId, true, 2) + -- cancello il percorso utilizzato + if nId then + EgtErase( nId) + end +end + +-- Funzione di sistemazione parametri +function VisionCutOut.AdjustParams( tMhPar) + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + local dMaxMat0 + local dMaxMat1 + local dMaxMat2 + local dMaxMat3 + local dNumMessage + local dNumLog = 0 + local sMessToOut = '' + local nTempT0 + local nTempT1 + local nTempT2 + local nTempT3 + local sMchngName0 + local sMchngName1 + local sMchngName2 + local sMchngName3 + local nThBl0 + local nThBl1 + local nThBl3 + + -- prendo parametro globale della direzione e se presente lo split porta + tMhPar.dir = DGD.DIR + tMhPar.split = DGD.SPLIT + + -- Assegno parametri da ddf + if tMhPar.split then + -- se non definita direzione di default è lungo l'altezza porta + if not tMhPar.dir then + tMhPar.dir = '0' + end + if tMhPar.dir == '0' then + tMhPar.L = DGD.dH + tMhPar.W = DGD.WIDTH + elseif tMhPar.dir == '1' then + tMhPar.L = DGD.WIDTH + -- riduco la larghezza della cava per non creare regioni interrotte + tMhPar.W = DGD.dW - ( 3 * DGD.dT * TAN3) + end + elseif tMhPar.split == nil then + if DGD.LENGTH then + tMhPar.L = DGD.LENGTH + end + if DGD.WIDTH then + tMhPar.W = DGD.WIDTH + end + if DGD.RADIUS then + tMhPar.R = DGD.RADIUS + end + end + tMhPar.T = DGD.dT + + -- verifico se presente il parametro DGC.Cmx ( massimo spessore per applicare la seconda modalità di ConeCleanCorner) e se ha i valori congruenti + if not DGC.Cmx then + tMhPar.Cmx = 0 + else + tMhPar.Cmx = abs(DGC.Cmx) + end + -- verifico se presente il parametro DGC.Ccm ( ConeCleanCorner mode) e se ha i valori congruenti (0 o 1) + if not DGC.Ccm then + tMhPar.Ccm = 0 + else + tMhPar.Ccm = abs( DGC.Ccm) + if tMhPar.Ccm > 1 then + tMhPar.Ccm = 0 + end + -- verifico se spessore porta ammette la seconda modalità, nel caso torno alla prima modalità + if tMhPar.T > tMhPar.Cmx then + tMhPar.Ccm = 0 + end + end + + -- disattivo la lama se la cava è più profonda di una certa quota + if ( tMhPar.split or tMhPar.split == nil) and tMhPar.MaxBd and tMhPar.T and tMhPar.T > tMhPar.MaxBd then + tMhPar.bl = false + dNumLog = -1194 + dNumMessage = 674 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, EgtToUiUnits(tMhPar.T), EgtToUiUnits(tMhPar.MaxBd)) + end + + -- disattivo la lama se è presente un raccordo + if tMhPar.R and tMhPar.R > 0 then + tMhPar.bl = false + end + + -- Assegno parametri da dati utensili in macchina + local MB = require( 'MachiningBase') + local sLBM + local nLBMi = 1 + local sDM + local nDMi = 1 + local dMaxCutBladeLen = 0 + local sCLCN + local nCLCNi = 1 + local sNotesMach = '' + local sCGM1 + local nCGM1i = 1 + + -- se porta steel o aluminum disabilito alcune geometrie non compatibili con il metallo + if FindMaterial( DGD.Material, 'steel') or FindMaterial( DGD.Material, 'aluminum') then + tMhPar.est = true + tMhPar.DM = nil + else + tMhPar.est = nil + end + + if tMhPar.DM then + sDM = tMhPar.DM + end + + if tMhPar.LBM then -- geometria con lama + sLBM = tMhPar.LBM + end + + if tMhPar.CLCN then -- pulitira spigolo con utensile conico + sCLCN = tMhPar.CLCN + end + + if tMhPar.GCM then + sCGM1 = tMhPar.GCM + end + + -- se devo disegnare le geometrie di lavorazione + if DGD.MachEn > 0 then + + -- parametri utensile per hatching + if ( tMhPar.split or tMhPar.split == nil) and sDM and tMhPar.d then + nTempT1, dMaxMat1, sMchngName1, nThBl1 = MB.GetToolDataFromAttrib( sDM, nDMi) + end + -- se ha fallito con la prima colonna riprovo con la seconda + -- (la lavorazione potrebbe essere messa sulla seconda colonna della MTAble) + if ( tMhPar.split or tMhPar.split == nil) and sDM and tMhPar.d and not( nTempT1 and sMchngName1) then + nDMi = 2 + nTempT1, dMaxMat1, sMchngName1, nThBl1 = MB.GetToolDataFromAttrib( sDM, nDMi) + end + + if ( tMhPar.split or tMhPar.split == nil) and sLBM and tMhPar.bl and tMhPar.d3 then + nTempT0, dMaxMat0, sMchngName0, nThBl0 = MB.GetToolDataFromAttrib( sLBM, nLBMi) + end + + if tMhPar.split == nil and sCLCN then + nTempT2, dMaxMat2, sMchngName2, _, sNotesMach = MB.GetToolDataFromAttrib( sCLCN, nCLCNi, true) + end + + -- se non c'è split e presente nome lavorazione su clip groove + if tMhPar.split == nil and sCGM1 then + nTempT3, dMaxMat3, sMchngName3, nThBl3 = MB.GetToolDataFromAttrib( sCGM1, nCGM1i, false, true) + end + + if DGD.bProoduce and not est and nTempT2 and nTempT2 < 0 then + dNumLog = -1193 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT2, sCLCN, nCLCNi, 0, dNumLog, sMchngName2) + else + -- cerco la nota + local nPosFound = string.find( sNotesMach, 'RadToClean') + if nPosFound then + local sParz = string.sub( sNotesMach, nPosFound) + nPosFound = string.find( sParz, ';') + local sTrimmed + if nPosFound then + sTrimmed = string.sub( sParz, 1, nPosFound-1) + else + sTrimmed = sParz + end + if sTrimmed and #sTrimmed > 0 then + local sValue = string.sub( sTrimmed, 12) + if sValue and #sTrimmed > 0 then + local dVal = tonumber( sValue) + if dVal and abs(dVal) > GEO.EPS_SMALL then + tMhPar.dCleanNote = dVal + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + else + tMhPar.dCleanNote = 0 + end + end + + if DGD.bProoduce and not est and ( tMhPar.split or tMhPar.split == nil) and tMhPar.d and nTempT1 and nTempT1 <= 0 then + dNumLog = -1198 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT1, sDM, nDMi, tMhPar.d, dNumLog, sMchngName1) + elseif not est and ( tMhPar.split or tMhPar.split == nil) and nTempT1 then + tMhPar.d = nTempT1 + -- se divido porta setto la larghezza/lunghezza cava + if tMhPar.split then + if tMhPar.dir == '0' then + tMhPar.W = nTempT1 + DGD.WIDTH = nTempT1 + elseif tMhPar.dir == '1' then + tMhPar.L = nTempT1 + DGD.LENGTH = nTempT1 + end + end + end + + if tMhPar.d3 and nTempT0 and nTempT0 <= 0 then -- lama + if DGD.bProoduce and tMhPar.bl then -- se utilizzo la lama + dNumLog = -1199 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT0, sLBM, nLBMi, tMhPar.d3, dNumLog, sMchngName0) + end + elseif nTempT0 then + tMhPar.d3 = nTempT0 + if nThBl0 and nThBl0 > 0 then + tMhPar.thb = nThBl0 + -- se divido porta setto la larghezza cava + if tMhPar.split then + if tMhPar.dir == '0' then + tMhPar.W = nThBl0 + DGD.WIDTH = nThBl0 + elseif tMhPar.dir == '1' then + tMhPar.L = nThBl0 + DGD.LENGTH = nThBl0 + end + end + end + end + + if DGD.bProoduce and not est and sCGM1 and nTempT3 and nTempT3 <= 0 then -- fresa side groove + dNumLog = -1192 + sMessToOut = sMessToOut .. '\n'.. GetMachToolErrorMessage( nTempT3, sCGM1, nCGM1i, 0, dNumLog, sMchngName3) + end + + -- se lo spessore porta è maggiore della capacità lama + if tMhPar.bl and tMhPar.T and dMaxMat0 and tMhPar.T >= dMaxMat0 then + -- se non split porta disabilito la lama ed emetto un warning + if not tMhPar.split then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1197 + dNumMessage = 672 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) + -- altrimenti se split limito l'affondamento alla massima profondità lama + else + tMhPar.T = dMaxMat0 + end + end + + -- se lo spessore porta è maggiore della capacità utensile hatching + if tMhPar.T and dMaxMat1 and tMhPar.T >= dMaxMat1 then + -- se non split porta disabilito la lavorazione ed emetto un warning + if not tMhPar.split then + tMhPar.DM = nil + dNumLog = -1196 + dNumMessage = 672 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0, EgtToUiUnits(tMhPar.T), EgtToUiUnits(dMaxMat0)) + -- altrimenti se split limito l'affondamento alla massima profondità fresa + else + tMhPar.T = dMaxMat1 + end + end + + -- se il blade è attivo calcolo se passa la lama nella sfinestratura + if tMhPar.bl and tMhPar.d3 and tMhPar.L and tMhPar.W then + + -- calcolo la massima impronta lama + local dBladeRadius = tMhPar.d3 / 2 + dMaxCutBladeLen = sqrt( (dBladeRadius * dBladeRadius) - ( ( dBladeRadius - tMhPar.T) * ( dBladeRadius - tMhPar.T))) + + -- se non split door e se l'impronta lama è maggiore della lunghezza o larghezza escludo la lama e do messaggio di warning + if ( not tMhPar.split and (2*dMaxCutBladeLen) >= tMhPar.L) or ( not tMhPar.split and (2*dMaxCutBladeLen) >= tMhPar.W) then + tMhPar.bl = false + tMhPar.LBM = nil + dNumLog = -1195 + dNumMessage = 673 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName0) + end + end + + -- se lo spessore fresa clip groove è maggiore dello spessore porta + if nThBl3 and nThBl3 >= DGD.dT then + dNumLog = -1191 + dNumMessage = 698 + sMessToOut = sMessToOut .. '\n'.. string.format(EgtDoorsMsg[dNumMessage], dNumLog, tMhPar.Nome, sMchngName3, nThBl3, DGD.dT) + tMhPar.GCM = nil + end + + -- se non split door e se il blade è attivo e utensile lama e c'è il clean corner, lo ricalcolo in funzione del raggio lama + if not tMhPar.split and tMhPar.bl and tMhPar.thb and tMhPar.thb > 0 and tMhPar.clc and tMhPar.clc > 0 then + if dMaxCutBladeLen > tMhPar.clc then + tMhPar.clc = dMaxCutBladeLen + end + end + + if tMhPar.CL and tMhPar.clc and tMhPar.clc > 0 and ( tMhPar.clc >= tMhPar.W or tMhPar.clc >= tMhPar.L) then + tMhPar.clc = nil + elseif not tMhPar.CL then + tMhPar.clc = nil + end + end + + if tMhPar.split then + if tMhPar.dir == '0' then + tMhPar.hml = DGD.dH * 1.5 + tMhPar.dml = 0.75 * tMhPar.L + tMhPar.dmw = 0.75 * tMhPar.W + elseif tMhPar.dir == '1' then + tMhPar.hml = DGD.dW * 1.5 + tMhPar.dml = 0.75 * tMhPar.L + tMhPar.dmw = 0.75 * tMhPar.W + end + end + + -- setto l'eventuale diametro fresa per clip groove + tMhPar.d4 = nTempT3 + tMhPar.th4 = nThBl3 + + if dNumLog ~= 0 then + return tMhPar, dNumLog, sMessToOut + end + + return tMhPar, 0, '' +end + +-- Funzione di disegno +function VisionCutOut.Draw( tVisPar, bPreview, bRunByCompo, nDrawMach) + + -- Assegno le dimensioni + local L = tVisPar.L + local W = tVisPar.W + local T = tVisPar.T + local R = tVisPar.R + local clc = tVisPar.clc + local ccr = tVisPar.ccr + local ccn = tVisPar.ccn + local hml = tVisPar.hml + local dml = tVisPar.dml + local dmw = tVisPar.dmw + local bl = tVisPar.bl + local dbl = tVisPar.dbl + local d = tVisPar.d -- hatching tool diameter + local d3 = tVisPar.d3 -- blade diameter + local ds = tVisPar.ds or false + local dRadToClean = tVisPar.dCleanNote or 0 + local dConeCleanMode = tVisPar.Ccm + local est = tVisPar.est + local dir = tVisPar.dir + local split = tVisPar.split + local spo = tVisPar.spo + -- tabelle gola laterale clip (clip side groove) + local tClipSideGroove = {} + -- inserimento dati nella tabella fori + table.insert( tClipSideGroove, { tVisPar.grl, tVisPar.grt, tVisPar.gsd, tVisPar.ctc, tVisPar.mci, tVisPar.sat, tVisPar.sab, tVisPar.sal, tVisPar.sah, tVisPar.GCM, tVisPar.d4, tVisPar.th4}) + -- Assegno i nomi + local LG = tVisPar.LG + local LM = tVisPar.LM + local CL = tVisPar.CL + local CLCN = tVisPar.CLCN + local DM = tVisPar.DM -- nome lavorazione hatchind + local LBM = tVisPar.LBM -- nome lavorazione con lama + -- variabili per messaggi e settaggi vari + local sCompoName = tVisPar.Nome + local nCompoNpar = tVisPar.Npar + local sCompoPath = tVisPar.Path + -- eventuale messaggio errore rilevato nell'adjust + local nCodAdj = tVisPar.nCod + local sCodAdj = tVisPar.sCod + -- variabili per messaggi e settaggi vari + local sNamePar1 = tVisPar.N1 or 'L' + local sNamePar2 = tVisPar.N2 or 'W' + local sNamePar3 = tVisPar.N3 or 'T' + local sNamePar4 = tVisPar.N4 or 'Radius' + local sNamePar5 = tVisPar.N5 or 'clc' + local sNamePar6 = tVisPar.N5 or 'ccr' + local sNamePar7 = tVisPar.N5 or 'gt1' + local sNamePar8 = tVisPar.N5 or 'gt2' + local sNamePar9 = tVisPar.N5 or 'gt3' + local sNamePar10 = tVisPar.N5 or 'gt4' + + -- RunByComponentInterface + local RC = true + -- Messaggi codice errori + local EM = ' ' + local EC = 0 + local ErrorBase = 1100 + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + if split and DM and LBM then + DM = LBM + end + + -- variabile spostamento rettangolo con cava split trasversale + local dPosX = 0 + if split and dir == '1' then + dPosX = T * TAN3 * 1.5 + end + + -- variabili calcolo diamond shape + local nIpo1, nIpo2, nIpo3, dTan, dAng, dRad + + if L and W then + -- se diamond shape + if ds then + if L > 0 and W > 0 then + nIpo1 = L/2 + nIpo2 = W/2 + nIpo3 = sqrt((nIpo1*nIpo1)+(nIpo2*nIpo2)) + dTan = nIpo2/nIpo1 + dAng = atan(dTan) + dRad = nIpo1 * sin(dAng) + -- se con raccordo + if R and R > 0 then + if R > dRad then + R = dRad + end + -- disabilito il clean corner + clc = 0 + ccr = 0 + end + else + R = 0 + end + else + if R and R > 0 then + -- se raccordo maggiore della metà del lato più corto lo ricalcolo + if 2*R > min(L,W) then + R = min(L,W)/2 + end + -- disabilito il clean corner + clc = 0 + ccr = 0 + end + end + end + + local EgtDoorsMsg = require( 'EgtDoorsMsg') + + -- variabile per gestione presenza hatching + local bExistsHatching = false + + -- Verifica delle dimensioni, le condizioni vengono verificate in base a quale geometria deve essere creata + if L and L < DimMin then + EC = 1 + EM = string.format(EgtDoorsMsg[407],sNamePar1,EgtToUiUnits(L),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'L' deve essere > DimMin + D = DimMin + elseif W and W < DimMin then + EC = 2 + EM = string.format(EgtDoorsMsg[407],sNamePar2,EgtToUiUnits(W),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'W' deve essere > DimMin + W = DimMin + elseif ( not L or not W) and R and R < DimMin then + EC = 3 + EM = string.format(EgtDoorsMsg[407],sNamePar4,EgtToUiUnits(R),'',EgtToUiUnits(DimMin), sCompoPath) -- il parametro 'R' deve essere > DimMin + R = DimMin +--[[ + elseif CL and clc and clc > 0 and ( 2*clc) >= W then + EC = 5 + EM = string.format(EgtDoorsMsg[407],sNamePar5..'*2',EgtToUiUnits(clc),sNamePar2,EgtToUiUnits(W), sCompoPath) -- il parametro 'clc*2' deve essere > W + clc = W/2-0.2 + elseif CL and clc and clc > 0 and ( 2*clc) >= L then + EC = 6 + EM = string.format(EgtDoorsMsg[407],sNamePar5..'*2',EgtToUiUnits(clc),sNamePar1,EgtToUiUnits(L), sCompoPath) -- il parametro 'clc*2' deve essere > L + clc = L/2-0.2 +]]-- + elseif not ds and CL and clc and ccr and clc > 0 and ccr > 0 and (2*(ccr*sin(45))) >= clc then + EC = 7 + EM = string.format(EgtDoorsMsg[407],sNamePar5,EgtToUiUnits(clc),'',EgtToUiUnits(2*(ccr*sin(45))), sCompoPath) -- il parametro 'clc' deve essere > 'crc' + clc = (2*(ccr*sin(45)))+0.2 + elseif tClipSideGroove[1][10] and tClipSideGroove[1][2] and tClipSideGroove[1][2] >= DGD.dT then + EC = 8 + EM = string.format(EgtDoorsMsg[699], sNamePar7, EgtToUiUnits( tClipSideGroove[1][2]), EgtToUiUnits(DGD.dT), sCompoPath) -- il parametro 'grt' deve essere < spessore porta + tClipSideGroove[1][2] = DGD.dT - 0.1 + 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 + + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName(Lg, sCompoName) + + local tHint = {} + local hint1, hint2 + local pIni, pEnd, pCen + local GId, MId, CLC1, CLC2, CLC3, CLC4, DRP1 + local CLCN1, CLCN2, CLCN3, CLCN4 + local nKindGeom + local bSingleMode = true + + -- Costruzione della geometria + if L and W then + if R and R > 0 then -- se c'e anche il raccordo + if ds then + GId = DrawDiamondWithFillet( Lg, W, L, T, R, dRad) + else + GId = DrawRectangleWithFillet ( Lg, W, L, T, R) + end + if GId then + EgtMove( GId, Point3d(W/2,-(L/2),0) - ORIG()) + end + else -- rettangolo o diamond senza raccordo + if ds then + GId = DrawDiamondWithFillet( Lg, W, L, T, 0, dRad) + if GId then + EgtMove( GId, Point3d(W/2,-(L/2),0) - ORIG()) + -- se ci sono i parametri per i percorsi clean corner + if CL and clc and clc > 0 and clc < nIpo3 then + -- angolo x-y0 + CLC1 = MakeClcPath( clc, 0, CL, Lg, -T, false, ds, nIpo1, nIpo2, nIpo3) + EgtMove( CLC1, Point3d(0,-(L/2),T) - ORIG()) + -- angolo x0y+ + CLC2 = MakeClcPath( clc, 0, CL, Lg, -T, false, ds, nIpo2, nIpo1, nIpo3) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d((W/2),0,T) - ORIG()) + -- angolo x+y0 + CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,-(L/2),0), Z_AX(), 180) + EgtMove( CLC3, Point3d(W,0,0) - ORIG()) + -- angolo x-y- + CLC4 = EgtCopyGlob( CLC2, Lg) + EgtRotate( CLC4, Point3d((W/2),0,0), Z_AX(), 180) + EgtMove( CLC4, Point3d(0,-L,0) - ORIG()) + end + end + else + GId = EgtRectangle2P( Lg, Point3d( dPosX, 0, T), Point3d( dPosX + W, -L, T), GDB_RT.GLOB) + -- Costruzione della geometria clean corner + if nDrawMach >= 0 then -- se abilitata geometria + -- se ci sono i parametri per i percorsi clean corner + if CL and clc and clc > 0 and clc < W and clc < L then + -- angolo x-y+ + CLC1 = MakeClcPath( clc, ccr, CL, Lg, -T) + EgtMove( CLC1, Point3d(0,0,T) - ORIG()) + -- angolo x+y+ + CLC2 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLC2, Point3d(W,0,0) - ORIG()) + -- angolo x+y- + CLC3 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLC3, Point3d(W,-L,0) - ORIG()) + -- angolo x-y- + CLC4 = EgtCopyGlob( CLC1, Lg) + EgtRotate( CLC4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLC4, Point3d(0,-L,0) - ORIG()) + end + -- se ci sono i parametri per i percorsi di clean corner con utensile conico + if CLCN and ccn and ccn > 0 and dRadToClean and dRadToClean > 0 then + -- angolo x-y+ + CLCN1 = MakeConeClcPath( CLCN, Lg, -T, dRadToClean, dConeCleanMode) + EgtMove( CLCN1, Point3d(0,0,T) - ORIG()) + -- angolo x+y+ + CLCN2 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN2, Point3d(0,0,0), Z_AX(), -90) + EgtMove( CLCN2, Point3d(W,0,0) - ORIG()) + -- angolo x+y- + CLCN3 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN3, Point3d(0,0,0), Z_AX(), 180) + EgtMove( CLCN3, Point3d(W,-L,0) - ORIG()) + -- angolo x-y- + CLCN4 = EgtCopyGlob( CLCN1, Lg) + EgtRotate( CLCN4, Point3d(0,0,0), Z_AX(), 90) + EgtMove( CLCN4, Point3d(0,-L,0) - ORIG()) + end + end + end + end + -- se non è diamond shape e clip groove presente + if not ds and tClipSideGroove and #tClipSideGroove == 1 then + + local GrLen = tClipSideGroove[1][1] + local GrTh = tClipSideGroove[1][2] + local GSDpth = tClipSideGroove[1][3] + local CenToCrn = tClipSideGroove[1][4] + local MaxClInt = tClipSideGroove[1][5] + local TopSide = tClipSideGroove[1][6] + local BotSide = tClipSideGroove[1][7] + local LckSide = tClipSideGroove[1][8] + local HngSide = tClipSideGroove[1][9] + local GeomName = tClipSideGroove[1][10] + local dDiamTool = tClipSideGroove[1][11] + local dThickTool = tClipSideGroove[1][12] + local sLenSide + local bLessDistance = false + local nDistMinToCorner + + -- se ci sono tutti i parametri + if GrLen and GrTh and GSDpth and CenToCrn and MaxClInt and GeomName then + + -- determino l'ordine delle facce da verificare + local pOrd = {} + + if DGD.Lock == 'L' then + pOrd = { 7, 8, 6, 9} + else + pOrd = { 7, 9, 6, 8} + end + + -- Clip side groove + for k = 1, 4 do + + -- se lato abilitato + if tClipSideGroove[1][pOrd[k]] then + + if pOrd[k] == 6 or pOrd[k] == 7 then + sLenSide = W + else + sLenSide = L + end + local nStartDist + local nCalcStep + local nClips = 0 + tHint = {} + + -- se ho almeno una linea + if ( sLenSide - CenToCrn) >= 0 then + + -- se ho un solo clip + if ( sLenSide <= ( 2 * CenToCrn)) or ( sLenSide <= MaxClInt) then + nClips = 1 + nStartDist = sLenSide / 2 + nCalcStep = 0 + -- se tolto il passo massimo rimane un valore <= della distanza da corner, + -- utilizzo la distanza da corner per calcolare il passo + elseif ( sLenSide - MaxClInt ) <= CenToCrn then + nClips = 2 + nStartDist = sLenSide / 3 + nCalcStep = nStartDist + -- se tolto il passo massimo rimane un valore <= del passo max, + -- utilippo + elseif ( sLenSide - ( 2 * CenToCrn)) <= MaxClInt then + nClips = 2 + nStartDist = CenToCrn + nCalcStep = sLenSide - ( 2 * CenToCrn) + -- calcolo quante linee inserire + else + local nTempClip = floor( ( sLenSide - ( 2 * CenToCrn)) / MaxClInt) + -- se il numero clip temporaneo per l'interasse + le distanze dal borda è inferiore alla lunghezza lato allora + -- sono prima del valore massimo + if ( nTempClip * MaxClInt) + ( 2 * CenToCrn) < ( sLenSide - GEO.EPS_SMALL * 10) then + nClips = nTempClip + 2 + else + nClips = nTempClip + 1 + end + + nStartDist = CenToCrn + nCalcStep = ( sLenSide - ( 2 * CenToCrn)) / ( nClips - 1) + end + + -- se la distanza minima è inferiore al raggio fresa do errore + nDistMinToCorner = nStartDist - ( GrLen / 2) + if nDrawMach > 0 and nDistMinToCorner <= ( dDiamTool / 2) + 2 then + bLessDistance = true + break + end + + -- disegno linee + for i = 1, nClips do + + pIni = Point3d( nStartDist + ( nCalcStep * ( i - 1)) - ( GrLen / 2), GSDpth, T/2) + pEnd = Point3d( nStartDist + ( nCalcStep * ( i - 1)) + ( GrLen / 2), GSDpth, T/2) + hint1 = DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + + if hint1 then + -- sposto il percorso sul lato definito + if pOrd[k] == 7 then -- se lato bottom + EgtRotate( hint1, Point3d(W/2,0,0), Z_AX(), 180) + EgtMove( hint1, Point3d(0,-L,0) - ORIG()) + elseif pOrd[k] == 8 then -- se lato lock + -- se lock a sinistra + if DGD.Lock == 'L' then + EgtRotate( hint1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( hint1, Point3d(0,-L,0) - ORIG()) + else + EgtRotate( hint1, Point3d(0,0,0), Z_AX(), -90) + EgtMove( hint1, Point3d(W,0,0) - ORIG()) + end + elseif pOrd[k] == 9 then -- se lato hinge + -- se lock a sinistra + if DGD.Lock == 'L' then + EgtRotate( hint1, Point3d(0,0,0), Z_AX(), -90) + EgtMove( hint1, Point3d(W,0,0) - ORIG()) + else + EgtRotate( hint1, Point3d(0,0,0), Z_AX(), 90) + EgtMove( hint1, Point3d(0,-L,0) - ORIG()) + end + end + EgtModifyCurveThickness( hint1, 0) + EgtSetName( hint1, GeomName) + + -- se spessore groove maggiore altezza utensile creo due percorsi + if nDrawMach > 0 and GrTh > ( dThickTool + 0.2) then + EgtMove( hint1, Point3d(0,0,( GrTh - dThickTool)/2) - ORIG()) + hint2 = EgtCopyGlob( hint1, Lg) + EgtMove( hint2, Point3d(0,0,-( GrTh - dThickTool)) - ORIG()) + end + end + end + end + end + end + + -- se distanza minima inferiore del raggio utensile do errore + if bLessDistance then + EC = (ErrorBase+6) + EM = string.format(EgtDoorsMsg[700], EgtToUiUnits(nDistMinToCorner),EgtToUiUnits( ( dDiamTool / 2) + 2)) + end + end + end + elseif R then + GId = EgtCircle( Lg, Point3d( 0, 0, T), R , GDB_RT.GLOB) + elseif split == nil then + EC = (ErrorBase+4) + EM = EgtDoorsMsg[408] -- mancano i parametri delle dimensioni + end + if GId then + EgtModifyCurveThickness( GId, -T) + EgtInvertCurve( GId) + EgtSetName( GId, LG) + end + if GId and ( split == nil or ( split and dir == '1')) then + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( Lg, GId, bSingleMode) + end + -- stampo messaggio con il valore del lato + if ds then + EgtOutText( 'Diamond shape Side Length: '..EgtNumToString( EgtIf( EgtUiUnitsAreMM(), nIpo3, nIpo3 / GEO.ONE_INCH), 4)) + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + if ( L and W) or R then -- se ci sono tutti i parametri necessari + if not split then + if L and W then -- se ci sono parametri minimi per il rettangolo + nKindGeom = 1 -- setto il tipo di geometria + if R and R > 0 then -- se c'e anche il parametro per il raccordo + if ds then + MId, nKindGeom = DrawDiamondWithFillet( Lg, W, L, T, R, dRad, DGD.Lock) + else + MId = DrawRectangleWithFillet ( Lg, W, L, T, R) + end + if MId then + EgtMove( MId, Point3d(W/2,-(L/2),0) - ORIG()) + end + if not ds then + -- se partenza su lato default ( che è il lato lock) + if not spo or spo == 0 or spo >= 4 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, - L /2, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( W, - L /2, T), GDB_RT.GLOB) + end + -- saltrimenti e partenza su lato top + elseif spo == 1 then + EgtChangeClosedCurveStartPoint( MId, Point3d( W /2, 0, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato bottom + elseif spo == 2 then + EgtChangeClosedCurveStartPoint( MId, Point3d( W /2, - L, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato hinge + elseif spo == 3 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( W, - L /2, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, - L /2, T), GDB_RT.GLOB) + end + end + end + else -- solo rettangolo o diamond senza raccordo + if ds then + MId, nKindGeom = DrawDiamondWithFillet( Lg, W, L, T, 0, dRad, DGD.Lock) + EgtMove( MId, Point3d(W/2,-(L/2),0) - ORIG()) + else + MId = EgtRectangle2P( Lg, Point3d( 0, 0, T), Point3d( W, -L, T), GDB_RT.GLOB) + -- se partenza su lato default ( che è il lato lock) + if not spo or spo == 0 or spo >= 4 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, - L /2, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( W, - L /2, T), GDB_RT.GLOB) + end + -- saltrimenti e partenza su lato top + elseif spo == 1 then + EgtChangeClosedCurveStartPoint( MId, Point3d( W /2, 0, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato bottom + elseif spo == 2 then + EgtChangeClosedCurveStartPoint( MId, Point3d( W /2, - L, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato hinge + elseif spo == 3 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( W, - L /2, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, - L /2, T), GDB_RT.GLOB) + end + end + end + end + elseif R then -- se c'è solo il parametro di raggio disegno la forma circolare + nKindGeom = 2 -- setto il tipo di geometria + MId = EgtCircle( Lg, Point3d( 0, 0, T), R , GDB_RT.GLOB) + -- se partenza su lato default ( che è il lato lock) + if not spo or spo == 0 or spo >= 4 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( -R, 0, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( R, 0, T), GDB_RT.GLOB) + end + -- saltrimenti e partenza su lato top + elseif spo == 1 then + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, R, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato bottom + elseif spo == 2 then + EgtChangeClosedCurveStartPoint( MId, Point3d( 0, -R, T), GDB_RT.GLOB) + -- saltrimenti e partenza su lato hinge + elseif spo == 3 then + if DGD.Lock == 'L' then + EgtChangeClosedCurveStartPoint( MId, Point3d( R, 0, T), GDB_RT.GLOB) + else + EgtChangeClosedCurveStartPoint( MId, Point3d( -R, 0, T), GDB_RT.GLOB) + end + end + end + else + if L and W then -- se ci sono parametri minimi per il rettangolo + nKindGeom = 1 -- setto il tipo di geometria + end + end + + -- se ci sono tutti i parametri per l'hatching + if DM and ( ( hml and dml) or dmw) then + + local hint_ofs + local bMakeDrop + + if not d then d = 0 end + + -- se esiste un diametro faccio l'offset del percorso esterno per calcolare eventuale intersezioni + if d > 0 then + -- offset + if not split then + hint_ofs = EgtOffsetCurveAdv( GId, EgtIf( ds, (d*55/64),(d*35/64)), GDB_OT.FILLET) + else + hint_ofs = EgtOffsetCurveAdv( GId, 0, GDB_OT.FILLET) + end + if hint_ofs then + EgtModifyCurveThickness( hint_ofs, 0) + end + end + + -- se l'utensile e i parametri per la lunghezza sono presenti + if d > 0 and hml and dml then + + local nStep -- numero di passate + local dStep -- passo ricalcolato + local dDistI -- distanza iniziale + local dDistF -- distanza finale + local dPos -- Posizione di partenza Y + bMakeDrop = false + + -- in base al tipo di geometria faccio i dovuti controlli + if nKindGeom == 1 then -- se e' un rettangolo + + local dDimGeom = L + if dir == '1' then + dDimGeom = W + end + + -- se lunghezza inferiore del limite inserisco le linee + if dDimGeom <= hml then + if not dir or dir == '1' then + if L > dml then -- se lunghezza e' maggiore del drop inserisco linee + -- determino quante linee inserire + nStep = ceil(L/dml) -- numero di passate + dStep = (L/nStep) -- passo ricalcolato + dDistI = dPosX + dDistF = dPosX + W + dPos = 0 + bMakeDrop = true + end + end + end + elseif nKindGeom == 2 then -- se e' un cerchio + -- se diametro inferiore del limite inserisco le linee + if (2*R) <= hml then + if (2*R) > dml then -- se diametro e' maggiore del drop inserisco linee + -- determino quante linee inserire + nStep = ceil((2*R)/dml) -- numero di passate + dStep = ((2*R)/nStep) -- passo ricalcolato + dDistI = -R + dDistF = R + dPos = R + bMakeDrop = true + end + end + end + + if bMakeDrop then + + local nPass = 1 + local nDir = 1 + bExistsHatching = bMakeDrop + if split then d = 0 end + + -- ciclo inserimento linee + while nPass < nStep do + + pIni = Point3d( EgtIf( nDir > 0, (dDistI+(d*9/16)), (dDistF-(d*9/16))),(dPos-(dStep*nPass)),T) + pEnd = Point3d( EgtIf( nDir > 0, (dDistF-(d*9/16)), (dDistI+(d*9/16))),(dPos-(dStep*nPass)),T) + hint1 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- calcolo intersezioni con il percorso di offset + hint1 = CalcIntersect( hint1, hint_ofs, pIni, pEnd, (d*1/64)) + -- se ho doppia linea + if dbl and dbl == 1 then + EgtTrimExtendCurveByLen( hint1, -(d/2), pEnd) + pIni = EgtSP( hint1) + pEnd = EgtEP( hint1) + -- seconda linea + hint2 = DrawAddLineDrawCircle( pEnd, pIni, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + DRP1 = EgtCurveCompo( Lg, {hint1,hint2}, true) + else + DRP1 = EgtCurveCompo( Lg, hint1, true) + end + EgtModifyCurveThickness( DRP1, -T) + EgtSetName( DRP1, DM) + EgtSetInfo( DRP1, 'DirectionCut', 'W') + if dbl and dbl == 1 then + EgtSetInfo( DRP1, 'DoubleLine', 1) + end + -- creo estrusi e superfici attorno alla linea di drop + DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, DRP1, -T) + + -- se non ho doppia linea creao linee di verso alternato + if not dbl or dbl == 0 then + nDir = -nDir + end + nPass = nPass + 1 + end -- end while + end + end + + if d > 0 and dmw then + + local nStep -- numero di passate + local dStep -- passo ricalcolato + local dDistI -- distanza iniziale + local dDistF -- distanza finale + local dPos -- Posizione di partenza X + bMakeDrop = false + + -- in base al tipo di geometria faccio i dovuti controlli + if nKindGeom == 1 then -- se e' un rettangolo + -- se lunghezza inferiore del limite inserisco le linee + if L <= hml then + if not dir or dir == '0' then + if W > dmw then -- se larghezza e' maggiore del drop inserisco linee + -- determino quante linee inserire + nStep = ceil(W/dmw) -- numero di passate + dStep = (W/nStep) -- passo ricalcolato + dDistI = 0 + dDistF = -L + dPos = 0 + bMakeDrop = true + end + end + end + elseif nKindGeom == 2 then -- se e' un cerchio + -- se diametro inferiore del limite inserisco le linee + if (2*R) <= hml then + if (2*R) > dmw then -- se diametro e' maggiore del drop inserisco linee + -- determino quante linee inserire + nStep = ceil((2*R)/dmw) -- numero di passate + dStep = ((2*R)/nStep) -- passo ricalcolato + dDistI = R + dDistF = -R + dPos = -R + bMakeDrop = true + end + end + end + + if bMakeDrop then + + local nPass = 1 + local nDir = 1 + bExistsHatching = bMakeDrop + if split then d = 0 end + + -- ciclo inserimento linee + while nPass < nStep do + + pIni = Point3d( ((dStep*nPass)+dPos), EgtIf( nDir > 0, (dDistI-(d*9/16)), (dDistF+(d*9/16))),T) + pEnd = Point3d( ((dStep*nPass)+dPos), EgtIf( nDir > 0, (dDistF+(d*9/16)), (dDistI-(d*9/16))),T) + hint1 = DrawAddLineDrawCircle( pIni, pEnd, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + -- calcolo intersezioni con il percorso di offset + hint1 = CalcIntersect( hint1, hint_ofs, pIni, pEnd, (d*1/64)) + -- se ho doppia linea + if dbl and dbl == 1 then + EgtTrimExtendCurveByLen( hint1, -(d/2), pEnd) + pIni = EgtSP( hint1) + pEnd = EgtEP( hint1) + -- seconda linea + hint2 = DrawAddLineDrawCircle( pEnd, pIni, Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + DRP1 = EgtCurveCompo( Lg, {hint1,hint2}, true) + else + DRP1 = EgtCurveCompo( Lg, hint1, true) + end + EgtModifyCurveThickness( DRP1, -T) + EgtSetName( DRP1, DM) + EgtSetInfo( DRP1, 'DirectionCut', 'H') + if dbl and dbl == 1 then + EgtSetInfo( DRP1, 'DoubleLine', 1) + end + -- creo estrusi e superfici attorno alla linea di drop + DrawRectangleAndMakeItsRegion( Lg, bPreview, Dm, DRP1, -T) + + -- se non ho doppia linea creao linee di verso alternato + if not dbl or dbl == 0 then + nDir = -nDir + end + nPass = nPass + 1 + end -- end while + end + end + + -- se esiste il percorso offsettato lo cancello + if hint_ofs then + EgtErase( hint_ofs) + end + end + + if MId then + EgtModifyCurveThickness( MId, -T) + EgtInvertCurve( MId) + + if bl then + EgtSetName( MId, LBM) + EgtSetInfo( MId, 'ByBlade', bl) + else + EgtSetName( MId, LM) + end + end + elseif split == nil then + EC = (ErrorBase+5) + EM = EgtDoorsMsg[408] -- mancano i parametri delle dimensioni + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if GId then + EgtSetColor( GId or GDB_ID.NULL, AQUA()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, AQUA()) + end + if CLC1 then + EgtSetColor( CLC1 or GDB_ID.NULL, AQUA()) + end + if CLC2 then + EgtSetColor( CLC2 or GDB_ID.NULL, AQUA()) + end + if CLC3 then + EgtSetColor( CLC3 or GDB_ID.NULL, AQUA()) + end + if CLC4 then + EgtSetColor( CLC4 or GDB_ID.NULL, AQUA()) + end + else + if GId then + EgtSetColor( GId or GDB_ID.NULL, ORANGE()) + end + if MId then + EgtSetColor( MId or GDB_ID.NULL, ORANGE()) + end + if CLC1 then + EgtSetColor( CLC1 or GDB_ID.NULL, ORANGE()) + end + if CLC2 then + EgtSetColor( CLC2 or GDB_ID.NULL, ORANGE()) + end + if CLC3 then + EgtSetColor( CLC3 or GDB_ID.NULL, ORANGE()) + end + if CLC4 then + EgtSetColor( CLC4 or GDB_ID.NULL, ORANGE()) + end + end + end + + -- Se non Preview + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + if not bPreview and EC == 0 then + if bRunByCompo then + -- scrivo i parametri nelle info del pezzo + WriteCompoDataToPart(Pz,sCompoName,nCompoNpar) + end + + -- scrivo note nel layer + EgtSetInfo( Lg, 'Type' , 'VisionCutOut') + EgtSetInfo( Lg, 'L' , L) + EgtSetInfo( Lg, 'H' , H) + EgtSetInfo( Lg, 'R' , R) + EgtSetInfo( Lg, 'T' , T) + EgtSetInfo( Lg, 'clc' , clc) + EgtSetInfo( Lg, 'ccr' , ccr) + EgtSetInfo( Lg, 'ccn' , ccn) + EgtSetInfo( Lg, 'hml' , hml) + EgtSetInfo( Lg, 'dml' , dml) + EgtSetInfo( Lg, 'dmw' , dmw) + EgtSetInfo( Lg, 'bl' , bl) + EgtSetInfo( Lg, 'dbl' , dbl) + EgtSetInfo( Lg, 'd' , d) + EgtSetInfo( Lg, 'd3' , d3) + EgtSetInfo( Lg, 'est' , est) + EgtSetInfo( Lg, 'dir' , dir) + EgtSetInfo( Lg, 'split' , split) + EgtSetInfo( Lg, 'ds' , ds) + EgtSetInfo( Lg, 'hatch' , bExistsHatching) + EgtSetInfo( Lg, 'LG' , LG) + EgtSetInfo( Lg, 'LM' , LM) + EgtSetInfo( Lg, 'CL' , CL) + EgtSetInfo( Lg, 'CLCN' , CLCN) + EgtSetInfo( Lg, 'DM' , DM) + EgtSetInfo( Lg, 'LBM' , LBM) + 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 VisionCutOut diff --git a/LuaLibs/_AssemblyDisp.lua b/LuaLibs/_AssemblyDisp.lua new file mode 100644 index 0000000..4ffc8f6 --- /dev/null +++ b/LuaLibs/_AssemblyDisp.lua @@ -0,0 +1,483 @@ +-- +-- 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 +-- +-- AssemblyDisp.lua by EgalWare s.r.l. 2017.11.14 +-- disposizione assemblato a raggruppamento + +-- Tavola per definizione modulo (serve ma non usata) +local AssemblyDisp = {} + +EgtEnableDebug( false) + +----------------------------------------------------------------- +local function GetFromPos( nIdPiece) + + local pPosPlaced = EgtGetInfo( nIdPiece, 'MoveedTo', 'p') + return pPosPlaced +end + +----------------------------------------------------------------- +local function GetPosToMove( nIdPiece) + + local pPosFrom = EgtGetInfo( nIdPiece, 'PosFromDoor', 'p') + return pPosFrom +end + +----------------------------------------------------------------- +local function GetTypePiece( nIdPiece) + + local nTypePiece = EgtGetInfo( nIdPiece, 'Piece Type', 'i') + local sAssembType = EgtGetInfo( nIdPiece, 'Assembly', 's') or '' + + -- se non trovate note esco con errore + if not ( nTypePiece and sAssembType) then + return + end + + -- comparo i valori per trovare corrispondenza certa + if nTypePiece == 1 and sAssembType == 'first' then + return nTypePiece + elseif nTypePiece == 2 and sAssembType == 'second' then + return nTypePiece + elseif nTypePiece == 3 and sAssembType == 'framesx' then + return nTypePiece + elseif nTypePiece == 4 and sAssembType == 'framedx' then + return nTypePiece + elseif nTypePiece == 5 and sAssembType == 'frametop' then + return nTypePiece + elseif nTypePiece == 6 and sAssembType == 'framebot' then + return nTypePiece + else + return + end +end + +----------------------------------------------------------------- +local function MovePieceOfAssemb( Pz, nPrevDisp, nDispose, dExtraMove, dSecondDoorGap) + + local bTypePiece = GetTypePiece( Pz) + local pPosAct = GetFromPos( Pz) + local pPosToMove = GetPosToMove( Pz) + local pCalcPos + + -- se manca qualche dato non faccio nulla + if not ( bTypePiece and pPosAct and pPosToMove) then + return + end + + -- se le disposizioni sono uguali non faccio nulla + if nPrevDisp == nDispose then + return + end + + if nDispose == 0 then -- se devo disporre come presentato dal Door + + if bTypePiece == 2 then -- se porta secondaria + + if nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( dSecondDoorGap,0,0) + end + + -- movimento + EgtMove( Pz, pPosAct - pCalcPos, GDB_RT.GRID) + -- assegno nota disposizione + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + else + + if bTypePiece == 3 then -- se frame sx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d(-dExtraMove,0,0) + end + + -- porto il pezzo a zero + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + -- riporto il pezzo nella posizione originaria + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtMove( Pz, Point3d(dThickPiece,0,0) - ORIG(), GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + -- muovo a posizione disposta + EgtMove( Pz, pPosAct - ORIG(), GDB_RT.GRID) + -- assegno nota disposta + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 4 then -- se frame dx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( ( dExtraMove + dSecondDoorGap),0,0) + end + + -- porto il pezzo a zero + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + -- riporto il pezzo nella posizione originaria + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d(dWidthPiece,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtMove( Pz, Point3d(-dWidthPiece,0,0) - ORIG(), GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + -- muovo a posizione disposta + EgtMove( Pz, pPosAct - ORIG(), GDB_RT.GRID) + -- assegno nota disposta + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 5 then -- se frame top + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( (dSecondDoorGap/2), dExtraMove,0) + end + + -- porto il pezzo a zero + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + -- riporto il pezzo nella posizione originaria + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(-dLengthPiece,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtMove( Pz, Point3d(0,-dLengthPiece,0) - ORIG(), GDB_RT.GRID) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia sinistra + EgtMove( Pz, Point3d(dThickPiece,0,0) - ORIG(), GDB_RT.GRID) + -- muovo a posizione disposta + EgtMove( Pz, pPosAct - ORIG(), GDB_RT.GRID) + -- assegno nota disposta + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 6 then -- se frame bottom + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( (dSecondDoorGap/2), -dExtraMove,0) + end + + -- porto il pezzo a zero + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + -- riporto il pezzo nella posizione originaria + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia sinistra + -- muovo a posizione disposta + EgtMove( Pz, pPosAct - ORIG(), GDB_RT.GRID) + -- assegno nota disposta + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + end + end + elseif nDispose == 1 then -- se devo disporre raggruppato + + if bTypePiece == 2 then -- se porta secondaria + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( dSecondDoorGap,0,0) + end + + EgtMove( Pz, pPosToMove - pCalcPos, GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + else + + if bTypePiece == 3 then -- se frame sx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( -dThickPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d(-dExtraMove,0,0) + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, pPosToMove - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 4 then -- se frame dx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( dWidthPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d( dWidthPiece,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( ( dExtraMove + dSecondDoorGap),0,0) + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, pPosToMove - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 5 then -- se frame top + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( -dThickPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia left + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtMove( Pz, Point3d(0,dLengthPiece,0) - ORIG(), GDB_RT.GRID) + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( (dSecondDoorGap/2), dExtraMove,0) + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, pPosToMove - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 6 then -- se frame bottom + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia left + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 2 then -- se disposizione attuale esplosa + pCalcPos = pPosToMove + Vector3d( (dSecondDoorGap/2), -dExtraMove,0) + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, pPosToMove - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + end + end + elseif nDispose == 2 then -- se devo disporre esploso + + if bTypePiece == 2 then -- se porta secondaria + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + elseif nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + end + + EgtMove( Pz, ( pPosToMove + Vector3d( dSecondDoorGap,0,0)) - pCalcPos, GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + else + + if bTypePiece == 3 then -- se frame sx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( -dThickPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, ( pPosToMove + Vector3d( -dExtraMove,0,0)) - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 4 then -- se frame dx + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'T', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'H', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( dWidthPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( Pz, Point3d( dWidthPiece,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, ( pPosToMove + Vector3d( ( dExtraMove + dSecondDoorGap),0,0)) - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 5 then -- se frame top + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, Point3d( -dThickPiece,0,0) - pCalcPos, GDB_RT.GRID) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia left + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtMove( Pz, Point3d(0,dLengthPiece,0) - ORIG(), GDB_RT.GRID) + elseif nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, ( pPosToMove + Vector3d( (dSecondDoorGap/2), dExtraMove,0)) - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + elseif bTypePiece == 6 then -- se frame bottom + + -- acquisisco le misure del pezzo relative al tipo di pezzo + local dWidthPiece = EgtGetInfo( Pz, 'H', 'd') + local dLengthPiece = EgtGetInfo( Pz, 'T', 'd') + local dThickPiece = EgtGetInfo( Pz, 'W', 'd') + + if nPrevDisp == 0 then -- se disposizione attuale disposta come door + pCalcPos = pPosAct + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( Pz, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia left + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nPrevDisp == 1 then -- se disposizione attuale raggruppata + pCalcPos = pPosToMove + -- prima devo portare il pezzo a zero e ruotarlo come originale + EgtMove( Pz, ORIG() - pCalcPos, GDB_RT.GRID) + end + + -- movimento a nuova posizione + EgtMove( Pz, ( pPosToMove + Vector3d( (dSecondDoorGap/2), -dExtraMove,0)) - ORIG(), GDB_RT.GRID) + -- assegno nota raggruppata + EgtSetInfo( Pz, 'DisposeAssembly', nDispose) + end + end + end +end + +----------------------------------------------------------------- +function AssemblyDisp.AssemblyDispose( nDisposeMain) + + -- ciclo per leggere i pezzi + local dExtraMove = 100 + local dSecondDoorGap = 0 + local Pz = EgtGetFirstPart() + + while Pz do + local bTypePiece = GetTypePiece( Pz) + if bTypePiece and bTypePiece == 2 then + dSecondDoorGap = dExtraMove / 2 + Pz = nil + else + -- passo al pezzo successivo + Pz = EgtGetNextPart( Pz) + end + end + + Pz = EgtGetFirstPart() + local nDispose + + while Pz do + + local nPrevDisp = EgtGetInfo( Pz, 'DisposeAssembly', 'i') + if nPrevDisp == nil then + nDispose = 1 + nPrevDisp = 0 + elseif nPrevDisp == 0 then + nDispose = 1 + elseif nPrevDisp == 1 then + nDispose = 2 + elseif nPrevDisp == 2 then + nDispose = 0 + end + + -- se il flag passato dal main non è nil prendo questo valore + if nDisposeMain ~= nil then nDispose = nDisposeMain end + + -- muovo il pezzo + MovePieceOfAssemb( Pz, nPrevDisp, nDispose, dExtraMove, dSecondDoorGap) + + -- passo al pezzo successivo + Pz = EgtGetNextPart( Pz) + end + + return true +end + +return AssemblyDisp + diff --git a/LuaLibs/_Latch.lua b/LuaLibs/_Latch.lua new file mode 100644 index 0000000..357dec6 --- /dev/null +++ b/LuaLibs/_Latch.lua @@ -0,0 +1,908 @@ +-- +-- 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 diff --git a/LuaLibs/_LatchCorner.lua b/LuaLibs/_LatchCorner.lua new file mode 100644 index 0000000..5fb2f90 --- /dev/null +++ b/LuaLibs/_LatchCorner.lua @@ -0,0 +1,768 @@ +-- +-- 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 +-- +-- _LatchCorner.lua by EgalWare s.r.l. 2016.07.11 +-- Autore: Filippo Monchi +-- Latch corner, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.05.15 V1.0a3 FM Add manage new mode to count entity also on curvecompo path to allow assign note on connection entity +-- 2019.10.11 V1.0a4 FM Manage steel option (disable to generate pocket paths and antisplint path, make closed and extend face 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 +-- 2024.07.19 V2.002 FM Set note 'NotCheckDir' to pocketing and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local _LatchCorner = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- Valori limite +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' +-- contatori +local nTotContEnt = 0 +local nTotContEnt_r = 0 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, nCounter_r) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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, nCounter_r) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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 _LatchCorner.Draw( EC, EM, tLatchParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tLatchParam.L + local H = tLatchParam.H + local T = tLatchParam.T + local d = tLatchParam.d + local p = tLatchParam.p + local sf = tLatchParam.sf + local rf = tLatchParam.rf + local d2 = tLatchParam.d2 + local jn = tLatchParam.jn + local L2 = tLatchParam.L2 + local H2 = tLatchParam.H2 + local cl = tLatchParam.cl + local D_X = tLatchParam.D_X + local est = tLatchParam.est + local invG = tLatchParam.invG + -- Assegno i nomi geometrie + local LG = tLatchParam.LG + local LM = tLatchParam.LM + local LA = tLatchParam.LA + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tLatchParam.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = true + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not 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 + + -- 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local tHint = {} + local hint1, hint2, hint3, hint4, hint5, hint5 + local hint, hintPk, hintAs1 + local pIni, pEnd, pCen, pStartStep + local nRadius = 0 + + -- se altezza supera lo spessore porta la riporto allo stesso valore + if H > dThickDoor then + H = dThickDoor + end + + -- creo lo stesso la geometria esterna perché viene utilizzata anche per creare il percorso di lavorazione + -- se non è previsto viene eliminato dopo + + -- Costruzione della geometria ( in senso orario) + if LG and (cl == 3 or cl == 2) and rf > GEO.EPS_SMALL then -- se cava arrotondata da entrambe i lati o a destra + + if est then + pIni = Point3d(-((d/2)+dExtraH),-((H/2)-(d/2)-dExtraH),0) + pEnd = Point3d(-((d/2)+dExtraH),H/2,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(0,H/2,0) + end + pEnd = Point3d((L-rf),H/2,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pCen = Point3d((L-rf),((H/2)-rf),0) + pEnd = Point3d(L,((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,(-(H/2)+rf),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + pCen = Point3d((L-rf),(-(H/2)+rf),0) + pEnd = Point3d((L-rf),-(H/2),0) + DrawAddCircleDrawCircle( pCen, rf, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if est then + pEnd = Point3d(-((d/2)+dExtraH),-H/2,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((d/2)+dExtraH),-((H/2)-(d/2)-dExtraH),0) + else + pEnd = Point3d(0,-H/2,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + elseif LG then -- altrimenti cava squadrata + + if est then + DrawAddLineDrawCircle( Point3d(-((d/2)+dExtraH),-((H/2)-(d/2)-dExtraH),0), Point3d(-((d/2)+dExtraH),H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(-((d/2)+dExtraH),H/2,0), Point3d(L,H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(L,H/2,0), Point3d(L,-H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(L,-H/2,0), Point3d(-((d/2)+dExtraH),-H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(-((d/2)+dExtraH),-H/2,0), Point3d(-((d/2)+dExtraH),-((H/2)-(d/2)-dExtraH),0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + else + DrawAddLineDrawCircle( Point3d(0,H/2,0), Point3d(L,H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(L,H/2,0), Point3d(L,-H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + DrawAddLineDrawCircle( Point3d(L,-H/2,0), Point3d(0,-H/2,0), + Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + end + end + -- trasformo in geometria composita i/il percorsi/o di contorno + if ( #tHint > 0) then + hint = EgtCurveCompo( Lg, tHint, true) + if hint then + EgtModifyCurveThickness( hint, -T) + EgtSetName( hint, LG) + if est then + EgtSetInfo( hint, 'StartFromExt', 1) + end + end + end + + --------------------------------------- + --------------------------------------- + -- Costruzione delle geometrie di lavorazione + --------------------------------------- + --------------------------------------- + if nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + local tPocketAs = {} + local nCaseNext + local dZedStart + local dZedWork + local nStep + local dStep + local nPass + local pStartStep + local nCase, nCaseNext + + -- geometria antischeggia + if d2 then -- se parametro valido + + if sf >= T then -- se passo unico + + local dPosX, dEndPosX, dIniPosX, dDeltaPosY + + if bStartAng then -- se lead-in con angolo + + if (L-nRadius) >= (d2*3/4) then + dEndPosX = (d2/4) + else + if nRadius >= (d2/2) then -- se raggio >= raggio fresa + dEndPosX = (L-nRadius) + else + dEndPosX = (L-(d2/2)) + end + end + + dPosX = dEndPosX - (d2/8) + dIniPosX = dPosX - (d2*7/8) + dDeltaPosY = ( (d2*7/8) / tan(30)) + + -- linea entrante inclinata + pIni = Point3d( dIniPosX, (-((H-d2)/2) + 0.2 + dDeltaPosY)*invG,0) + pEnd = Point3d(dPosX, (-((H-d2)/2) + 0.2)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in X + pIni = pEnd + pEnd = Point3d(dEndPosX, (-((H-d2)/2) + 0.2)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni = pEnd + pEnd = Point3d(dEndPosX, -((H-d2)/2)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-(d2*3/4),-((H-d2)/2)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + else -- lead-in diritto + + if (L-nRadius) >= (d2*3/4) then + dEndPosX = (d2/4) + else + if nRadius >= (d2/2) then -- se raggio >= raggio fresa + dEndPosX = (L-nRadius) + else + dEndPosX = (L-(d2/2)) + end + end + + dIniPosX = -(d2*3/4) + + pIni = Point3d(dIniPosX,-((H-d2)/2)*invG,0) + pEnd = Point3d(dEndPosX,-((H-d2)/2)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + end + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs1 then + EgtModifyCurveThickness(hintAs1, -T) + EgtSetName(hintAs1,LA) + end + end + else -- altrimenti più passate + + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + local tMVar = {} + local tMVar2 = {} + local nConEnt + local sKindVar + local dPosX, dEndPosX, dIniPosX, dDeltaPosY + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if bStartAng then -- se lead-in con angolo + + if (L-nRadius) >= (d2*3/4) then + dEndPosX = (d2/4) + else + if nRadius >= (d2/2) then -- se raggio >= raggio fresa + dEndPosX = (L-nRadius) + else + dEndPosX = (L-(d2/2)) + end + end + + dPosX = dEndPosX - (d2/8) + dIniPosX = dPosX - (d2*7/8) + dDeltaPosY = ( (d2*7/8) / tan(30)) + + -- linea entrante inclinata + pIni = Point3d( dIniPosX, (-((H-d2)/2) + 0.2 + dDeltaPosY)*invG,dZedWork) + pEnd = Point3d(dPosX, (-((H-d2)/2) + 0.2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in X + pIni = pEnd + pEnd = Point3d(dEndPosX, (-((H-d2)/2) + 0.2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni = pEnd + pEnd = Point3d(dEndPosX, -((H-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-(d2*3/4),-((H-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d( pIni:getX(), (-((H-d2)/2) + 0.2 + dDeltaPosY)*invG, dZedWork) + else -- lead-in diritto + + if (L-nRadius) >= (d2*3/4) then + dEndPosX = (d2/4) + else + if nRadius >= (d2/2) then -- se raggio >= raggio fresa + dEndPosX = (L-nRadius) + else + dEndPosX = (L-(d2/2)) + end + end + + dIniPosX = -(d2*3/4) + + pIni = Point3d(dIniPosX,(-((H-d2)/2) + 0.2)*invG,dZedWork) + pEnd = Point3d(dEndPosX,(-((H-d2)/2) + 0.2)*invG,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(dEndPosX, -((H-d2)/2)*invG, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(dIniPosX, pIni:getY(), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(pIni:getX(),(-((H-d2)/2) + 0.2)*invG, dZedWork) + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi scendo in z + if nPass <= nStep then + + local pIniLoc = pEnd + pEnd = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + 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 + EgtSetName(hintAs1,LA) + end + end + end + end + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + + if not est then -- se non c'è lavorazione steel + + -- 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 offset + nCase = 4 + end + + local nDirVers = 1 + local tPocket = {} + local tMVar = {} + local nConEnt + local sKindVar + -- resetto contatori entità + nTotContEnt = 0 + nTotContEnt_r = 0 + nRadius = H/2 + nPass = 1 + dZedStart = 0 + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if nCase == 1 then -- solo 1 passaggio in centro + + if nDirVers == 1 then -- se passata di andata + + pIni = Point3d(-(d*3/4),0,dZedWork) + pStartStep = pIni + pEnd = Point3d((L-(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pIni = pEnd + pEnd = Point3d((L-(d/2)),0,(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + end + else -- altrimenti passata di ritorno + + pIni = Point3d((L-(d/2)),0,dZedWork) + pEnd = Point3d(-(d*3/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pIni = pEnd + pEnd = Point3d(-(d*3/4),0,(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + end + end + + if nPass == nStep then + + if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + pIni = pEnd + pEnd = Point3d((L2-(d/2))+D_X,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + -- calcolo l'ampiezza dell'offset + nRadius = nRadius - (d/2) + + -- offset + hint_ofs = EgtOffsetCurveAdv( hint, (d/2), GDB_OT.FILLET) + + if hint_ofs and hint_ofs > 0 then + + -- 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 bStartOppo then + pIni = Point3d(-(d*3/4),(-((H-d)/2) + 0.2)*invG,dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(-dExtraH,(-((H-d)/2) + 0.2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea traversa in Y per andare sul vecchio punto iniziale (in Y) + pIni = pEnd + pEnd = Point3d(-dExtraH,((H-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + else + -- prima linea entrante + pIni = Point3d(-(d*3/4),((H-d)/2)*invG,dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d(-dExtraH,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d((L-(d*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd = Point3d(-dExtraH,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + local nDistYcentr = (d*p) + local bContinue + + -- se percorso offset esiste + if hint_ofs and hint_ofs > 0 then + + -- faccio l'offset del raggio fresa + nRadius = nRadius - nDistYcentr + bContinue = nRadius > 0 + + -- se percorso offset esiste + while bContinue do + + hint_ofs2 = EgtOffsetCurveAdv( hint_ofs, nDistYcentr*invG, GDB_OT.FILLET) + + if hint_ofs2 and hint_ofs2 > 0 then + + -- linea congiunzione tra osset + pIni = pEnd + pEnd = EgtSP( hint_ofs2) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pEnd = EgtEP( hint_ofs2) + hint_ofs = hint_ofs2 + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + + -- calcolo nuovo passo in Y e indice direzione + nRadius = nRadius - nDistYcentr + bContinue = nRadius > 0 + else + bContinue = false + end + end -- end while + end + end + + if nPass == nStep then + + if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + -- carcolo 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))+D_X,0,dZedWork) + else + pEnd = Point3d((-(d*3/4))+D_X,((H2-d)/2)*invG,dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + nRadius = H/2 + nDirVers = -nDirVers + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep and nCase > 1 then + + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,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) + 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 + 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 hintPk then + EgtSetColor(hintPk,AQUA()) + end + else + if hint then + EgtSetColor(hint,ORANGE()) + end + if hintAs1 then + EgtSetColor(hintAs1,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 percorsi antisplint e svuotatura + if hintAs1 then + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + end + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + end + + return hint, hintPk, hintAs1 +end + +return _LatchCorner diff --git a/LuaLibs/_LatchStrike.lua b/LuaLibs/_LatchStrike.lua new file mode 100644 index 0000000..3a1a319 --- /dev/null +++ b/LuaLibs/_LatchStrike.lua @@ -0,0 +1,753 @@ +-- +-- 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 +-- +-- _LatchStrike.lua by EgalWare s.r.l. 2016.07.11 +-- Autore: Filippo Monchi +-- Latch strike, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2017.02.20 V1.0a1 FM Manage step face and radius face features +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2019.10.11 V1.0a3 FM Manage steel option (disable to generate pocket paths and antisplint path, make closed and extend face 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 +-- 2024.07.19 V2.002 FM Set note 'NotCheckDir' to pocketing and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local LatchStrike = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- Valori limite +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + + if idTable then + table.insert( idTable, nLine) + -- se devo inserire una variazione nell'entità + if sMVar then + nNumLine = #idTable + end + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine, nNumLine, sMVar +end + +local function 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 LatchStrike.Draw( EC, EM, tLatchParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tLatchParam.L + local H = tLatchParam.H + local T = tLatchParam.T + local d = tLatchParam.d + local p = tLatchParam.p + local sf = tLatchParam.sf + local R = tLatchParam.rf + local d2 = tLatchParam.d2 + local jn = tLatchParam.jn + local L2 = tLatchParam.L2 + local H2 = tLatchParam.H2 + local D = tLatchParam.D + local D_X = tLatchParam.D_X + local invG = tLatchParam.invG + local est = tLatchParam.est + -- Assegno i nomi geometrie + local LG = tLatchParam.LG + local LM = tLatchParam.LM + local LA = tLatchParam.LA + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tLatchParam.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = tLatchParam.staro + if bStartOppo == nil then + bStartOppo = true + end + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not 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 R or abs(R) <= GEO.EPS_SMALL then + R = 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local hint1, hint2 + local hint, hintPk, hintAs1, hintAs2 + local pIni, pEnd, pCen + local bThD + + -- se altezza supera lo spessore porta la riporto allo stesso valore e resetto eventuale raccordo + if H >= dThickDoor then + H = dThickDoor + R = 0 + bThD = true + end + + if nDrawMach ~= 1 then -- se abilitata geometria esterna + + local tHint = {} + + -- Costruzione della geometria ( in senso orario) + if est then + pIni = Point3d(-((L/2)-(d/2)-dExtraH)*invG,((d/2)+dExtraH),0) + pEnd = Point3d((L/2*invG),((d/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pIni = Point3d((L/2*invG),0,0) + end + + if R > 0 then + pEnd = Point3d(L/2*invG,(-H+R),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L/2)-R)*invG,-H,0) + pCen =Point3d(((L/2)-R)*invG,(-H+R),0) + DrawAddCircleDrawCircle( pCen, R, EgtIf( invG > 0, 0, 180),-90*invG, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if est and bThD then + pEnd = Point3d(L/2*invG,-(H+(d/2)+dExtraH),0) + else + pEnd = Point3d(L/2*invG,-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if R > 0 then + pEnd = Point3d((-(L/2)+R)*invG,-H,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-(L/2)*invG,(-H+R),0) + pCen =Point3d((-(L/2)+R)*invG,(-H+R),0) + DrawAddCircleDrawCircle( pCen, R, -90,-90*invG, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if est and bThD then + pEnd = Point3d(-(L/2)*invG,-(H+(d/2)+dExtraH),0) + else + pEnd = Point3d(-(L/2)*invG,-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if est then + pEnd = Point3d(-L/2*invG,((d/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)-(d/2)-dExtraH)*invG,((d/2)+dExtraH),0) + else + pEnd = Point3d(-L/2*invG,0,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + hint = EgtCurveCompo( Lg, tHint, true) + EgtModifyCurveThickness( hint, -T) + EgtSetName( hint, LG) + if est then + EgtSetInfo( hint, 'StartFromExt', 1) + 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 tPocketAs = {} + local tPocketAs2 = {} + local pIni2 + local pEnd2 + local nCaseNext + local dZedStart + local dZedWork + local nStep + local dStep + local nPass + local pStartStep + + -- geometria antischeggia + if d2 then -- se parametro valido + + nStep = ceil(T/sf) -- 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 + if nStep == 1 then + dZedWork = 0 + else + dZedWork = -T + end + 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) + end + else + dEndPosY = -H+(d2/2) + 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)*invG, dIniPosY, dZedWork) + pEnd = Point3d((-((L-d2)/2) + 0.2)*invG, 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)*invG, 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)*invG, 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)*invG,(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)*invG, pIni:getY(), dZedWork) + + if H == dThickDoor and dEndPosY2 then + + -- linea entrante inclinata + pIni2 = Point3d((((L-d2)/2) - 0.2 - dDeltaPosX)*invG, dIniPosY2,dZedWork) + pEnd2 = Point3d((((L-d2)/2) - 0.2)*invG, 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)*invG, 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)*invG, 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)*invG,-(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)*invG, 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) + end + else + dEndPosY = -H+(d2/2) + end + + dIniPosY = (d2*3/4) + dIniPosY2 = -(H+(d2*3/4)) + + pIni = Point3d((-((L-d2)/2) + 0.2)*invG, dIniPosY, dZedWork) + pEnd = Point3d((-((L-d2)/2) + 0.2)*invG, 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(-((L-d2)/2)*invG, 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)*invG, pIni:getY(), dZedWork) + + if H == dThickDoor and dEndPosY2 then + + pIni2 = Point3d((((L-d2)/2) - 0.2)*invG, dIniPosY2, dZedWork) + pEnd2 = Point3d((((L-d2)/2) - 0.2)*invG, 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)*invG, 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)*invG, 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 H == dThickDoor then + pIniLoc = pEnd2 + pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar2, {nConEnt,sKindVar}) + end + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs1 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs1, -T) + else + 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 + EgtSetName(hintAs1,LA) + end + end + + if ( #tPocketAs2 > 0) then + hintAs2 = EgtCurveCompo( Lg, tPocketAs2, true) + if hintAs2 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs2, -T) + else + 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 + EgtSetName(hintAs2,LA) + end + end + end + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + + if not est then -- se non c'è lavorazione steel + + local tPocket = {} + local tMVar = {} + local nConEnt + local sKindVar + nPass = 1 + dZedStart = 0 + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if bStartOppo then + pIni = Point3d((-((L-d)/2) + 0.2)*invG,(d*3/4),dZedWork) + pStartStep = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + -- linea in Y con centro utensile fuori + pEnd = Point3d((-((L-d)/2) + 0.2)*invG,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)*invG,dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(((L-d)/2)*invG,(d*3/4),dZedWork) + pStartStep = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + end + + local bDrawCircle = EgtIf( bStartOppo, false, true) + + if ( H <= (d/2) or ( L <= (d*2))) then -- se cava troppo bassa o stretta + -- linea entrante in Y + pEnd = Point3d(((L-d)/2)*invG,-H+(d/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) + -- linea traversa in X + 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()) + -- linea di risalita in Y + pIni = pEnd + pEnd = Point3d(-((L-d)/2)*invG,(d*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + else + + if H == dThickDoor then + pEnd = Point3d(((L-d)/2)*invG,-H-dExtraH,dZedWork) + else + if R > (d/2) then + pEnd = Point3d(((L-d)/2)*invG,(-H+R),dZedWork) + else + pEnd = Point3d(((L-d)/2)*invG,-H+(d/2),dZedWork) + end + end + -- linea entrante in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) + pIni = pEnd + + if H == dThickDoor then + pEnd = Point3d(-((L-d)/2)*invG,-H-dExtraH,dZedWork) + else + if R > (d/2) then + -- raccordo 1 + pEnd = Point3d(((L/2)-R)*invG,-H+(d/2),dZedWork) + pCen = Point3d(((L/2)-R)*invG,(-H+R),dZedWork) + DrawAddCircleDrawCircle( pCen, (R-(d/2)), EgtIf( invG > 0,0,180),-90*invG, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-((L/2)-R)*invG,-H+(d/2),dZedWork) + else + pEnd = Point3d(-((L-d)/2)*invG,-H+(d/2),dZedWork) + end + end + -- linea traversa in X + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + + if R > (d/2) then + -- raccordo 2 + pEnd = Point3d(-((L-d)/2)*invG,(-H+R),dZedWork) + pCen = Point3d(-((L/2)-R)*invG,(-H+R),dZedWork) + DrawAddCircleDrawCircle( pCen, (R-(d/2)), -90,-90*invG, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + end + + -- linea di risalita in Y + pEnd = Point3d(-((L-d)/2)*invG,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)*invG,dExtraH,dZedWork) + else + pEnd = Point3d((((L*2)-(d*3))/4)*invG,dExtraH,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pIni = pEnd + + local nDirVers = EgtIf( bStartOppo, 1, -1) + local nDistYcentr = (d*p) + local nPosYcentr = nDistYcentr - dExtraH + local bContinue + local nDeltaXPk = 0 + + if H == dThickDoor 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 + + -- ciclo passate svuotatura + while bContinue do + + pEnd = Point3d((-nDirVers * ((((L*2)-(d*3))/4)-nDeltaXPk)*invG),-nPosYcentr,dZedWork) + + -- 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)*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 + if H == dThickDoor 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 + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + nDirVers = -nDirVers + -- ricalcolo punti per linea successiva + pIni = pEnd + end + end -- end while + + -- se più passi o non ho concatenamenti seguenti, aggiungo linea di risalita in Y + if ( nStep > 1 and (nPass + 1) <= nStep) or not jn then + pIni = pEnd + pEnd = Point3d(pIni:getX(), (d*3/4), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) -- linea di ritorno in Y + end + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep then + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep: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 + + if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + -- carcolo 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+(H2/2)),dZedWork) + else + pEnd = Point3d(((((L2-d)/2)*invG)+D_X),-(D+(d/2)),dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- trasformo in geometria composita + if ( #tPocket > 0) then + hintPk = EgtCurveCompo( Lg, tPocket, true) + if hintPk then + EgtModifyCurveThickness(hintPk, 0) + if sf < T then -- se passi multipli + -- 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 + end + EgtSetName(hintPk,LM) + 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 + 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 + end + else -- altrimenti non Preview + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + -- assegno nota su percorsi antisplint e svuotatura + if hintAs1 then + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + end + if hintAs2 then + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + end + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + end + + return hint, hintPk, hintAs1, hintAs2 +end + +return LatchStrike diff --git a/LuaLibs/_Mortise.lua b/LuaLibs/_Mortise.lua new file mode 100644 index 0000000..6dff5d4 --- /dev/null +++ b/LuaLibs/_Mortise.lua @@ -0,0 +1,1294 @@ +-- +-- 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 +-- +-- _Mortise.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Mortise, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2021.05.10 V2.001 FM Spliet case 3 pocket in 2 (now there are 5 cases) with better optimization for central line pocket +-- 2021.12.01 V2.002 FM Manage side probe option if variable DGC.Pms > 2 +-- 2024.04.29 V2.003 FM Verify step value (parameter 's') <> 0 +-- 2024.07.19 V2.004 FM Set note 'NotCheckDir' to pocketing paths + +-- Tavola per definizione modulo (serve ma non usata) +local _Mortise = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor(nCircle2, cColor2) + end + end + + return nLine +end + +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 _Mortise.Draw( EC, EM, tMortiseParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local T = tMortiseParam.T + local L2 = tMortiseParam.L2 + local H2 = tMortiseParam.H2 + local T2 = tMortiseParam.T2 + local s = tMortiseParam.s + local d = tMortiseParam.d + local p = tMortiseParam.p + local jn = tMortiseParam.jn + local d2 = tMortiseParam.d3 + local p2 = tMortiseParam.p3 + local invG = tMortiseParam.invG + local mkrev = tMortiseParam.mkrev + local jne = tMortiseParam.jne + local jnt = tMortiseParam.jnt + local L3 = tMortiseParam.L3 + local H3 = tMortiseParam.H3 + local TE = tMortiseParam.TE + local D_X = tMortiseParam.D_X + local smr = tMortiseParam.smr + local pbs = tMortiseParam.pbs + -- Assegno i nomi dei layer + local LGM = tMortiseParam.LGM + local LMM = tMortiseParam.LMM + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tMortiseParam.Nome + -- RunByComponetInterface + local RC = true + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + + if not bRunByCompo then + RC = false + end + + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + if not smr then + smr = 0 + end + + if not TE then + TE = T + 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local tHint = {} + local hint1, hint2, hint3, hint4, hint5 + local hint_2, hintPk2, hintPk2_r + local pIni, pEnd, pCen + local invGy = 1 + + if nDrawMach ~= 1 and LGM then -- se abilitata geometria esterna + + -- Costruzione della geometria + pIni = Point3d(0,(H2/2),0) + if smr > 0 then + pEnd = Point3d((L2/2)-0.5,(H2/2),0) + else + pEnd = Point3d(L2/2,(H2/2),0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + if smr > 0 then + pEnd = Point3d((L2/2),(H2/2)-0.5,0) + pCen = Point3d((L2/2)-0.5,(H2/2)-0.5,0) + DrawAddCircleDrawCircle( pCen, 0.5, 90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((L2/2),-(H2/2)+0.5,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d((L2/2)-0.5,-(H2/2),0) + pCen = Point3d((L2/2)-0.5,-(H2/2)+0.5,0) + DrawAddCircleDrawCircle( pCen, 0.5, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d((L2/2),-(H2/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if smr < 0 then + pEnd = Point3d(-(L2/2)+0.5,-(H2/2),0) + else + pEnd = Point3d(-(L2/2),-(H2/2),0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + if smr < 0 then + pEnd = Point3d(-(L2/2),-(H2/2)+0.5,0) + pCen = Point3d(-(L2/2)+0.5,-(H2/2)+0.5,0) + DrawAddCircleDrawCircle( pCen, 0.5, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-(L2/2),(H2/2)-0.5,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(-(L2/2)+0.5,(H2/2),0) + pCen = Point3d(-(L2/2)+0.5,(H2/2)-0.5,0) + DrawAddCircleDrawCircle( pCen, 0.5, 180,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(-(L2/2),(H2/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + pEnd = Point3d(0,(H2/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + + hint_2 = EgtCurveCompo( Lg, tHint, true) + EgtModifyCurveThickness(hint_2, -T2) + EgtSetName(hint_2,LGM) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_2, 'ProbeSide', '1') + end + end + + ---------------------------------------------- + ---------------------------------------------- + -- Costruzione delle geometrie di lavorazione + ---------------------------------------------- + ---------------------------------------------- + local nOrigInvG = invG + local nOrigInvGy = invGy + if nDrawMach > 0 and LMM and s then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + local tPocket2 = {} + local tPocket2_r = {} + local pIni_r, pEnd_r + local pEnd2, pEnd2_r + local nCase + local nCaseNext + local dZedStart + local dZedWork + local dZedStartTw + + --------------------------------------- + -- geometria svuotatura giro interno + --------------------------------------- + local nStep + local dStep + local dPerim + local nDirVers + local nPass + + if jn then -- svuotature unite calcolo il numero di passi in Z + + -- individuo in che caso sono + if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H2-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H2-d) > ( d*0.98)) and ( (H2-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + -- se sfrido rimenente è <= 1 lo tolgo alla fine + if ((H2-d) <= ( d*1.10)) or ( H2 - (2*d)) <= 2 then + nCase = 3 + else + nCase = 4 + end + elseif (H2-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag + nCase = 5 + end + + dPerim = 2*( H2 + L2 -(2*d)) + -- 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 = T2-T + end + nStep = ceil((T2-T)/s) -- numero di passate + dStep = ((T2-T)/nStep) -- passo ricalcolato + dZedStart = -T + dZedStartTw = -TE + else -- svuotature separate ricalcolo i casi e il numero di passi in Z + + -- individuo in che caso sono + if abs(H2-d2) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H2-d2) <= ( d2*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H2-d2) > ( d2*0.98)) and ( (H2-d2) <= (d2*(1+p2))) then -- passaggio di contornatura + un passaggio centrale + -- se sfrido rimenente è <= 1 lo tolgo alla fine + if ((H2-d2) <= ( d2*1.10)) or ( H2 - (2*d2)) <= 2 then + nCase = 3 + else + nCase = 4 + end + elseif (H2-d2) > (d2*(1+p2)) then -- passaggio di contornatura + passaggi zig zag + nCase = 5 + end + + dPerim = 2*( H2 + L2 -(2*d2)) + -- 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 = T2 + end + nStep = ceil(T2/s) -- numero di passate + dStep = (T2/nStep) -- passo ricalcolato + dZedStart = 0 + dZedStartTw = 0 + end + + if jn then -- svuotature unite + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + nDirVers = 1 + local nDoubleStep = nStep * 2 + pEnd = Point3d(-((L2-d)/2)*invG,0,dZedStart) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(((L2-d)/2)*invG,0,dZedStart) + end + + while nPass <= nDoubleStep do + + -- primo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = dZedStart - ((dStep * nPass)/2) + if nPass == nDoubleStep then + dZedWork = -T2 + end + pEnd = Point3d((-nDirVers*((L2-d)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers*((L2-d)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = -T2 + pEnd = Point3d((-nDirVers*((L2-d)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers*((L2-d)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + pIni = pEnd + + if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + if jnt then -- se ho cava doppia e devo risalire in Z + + if ( nDeltaMovX > (L2-d)) then + nDeltaMovX = (L2-d) + end + -- Uscita in Z inizio + dZedWork = dZedStartTw + + pEnd = Point3d(-nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + pIni = pEnd + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + + -- calcolo in che caso sono con la prossima geometria + if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro + nCaseNext = 1 + else + nCaseNext = 0 + end + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = pEnd_r + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + else + + -- Uscita in Z0 + dZedWork = 0 + + if ( nDeltaMovX > (L2-d)) then + nDeltaMovX = (L2-d) + end + pEnd = Point3d(-nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(nDirVers*(((L2-d)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) or ( nCase == 5) then + + nPass = 1 + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedStart) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedStart) + end + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2-d)/dPerim)) + end + pEnd = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2+L2-(2*d))/dPerim)) + end + pEnd = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*H2)+L2-(3*d))/dPerim)) + end + pEnd = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + end + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + pIni = pEnd + pEnd = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(-((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2)*invG,-((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + + if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d)/2 + end + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2),dZedWork) + pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio il passaggio centrale + if nCase == 3 and nPass == nStep then -- passaggio di contornatura centrale finale + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) + pEnd2 = Point3d(-(((L2*2)-(d*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) + pEnd2_r = Point3d((((L2*2)-(d*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + end + + if nCase == 4 then -- passaggio di contornatura + un passaggio centrale e inverto la direzione + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- settima linea ritorno a posizione iniziale +-- pIni = pEnd +-- pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2),dZedWork) + -- cambio il posizionamento della posizione iniziale + pIni = pEnd + invG = -invG -- setto per cambiare la posizione del percorso di inizio + invGy = -invGy -- setto per cambiare il senso di direzione della svuotatura + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + + if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d)/2 + end + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2)*invGy,dZedWork) + pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY)*invGy, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + elseif nCase == 5 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = -1 + local nDistYcentr = (d*p) + local nPosYcentr = ((H2-d)/2) - nDistYcentr + local bContinue = nPosYcentr > -(((H2-d)/2)-(d/2)) + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + end + + -- ciclo passate svuotatura + while bContinue do + + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- linea passata in X + pIni = pEnd + pEnd = Point3d((nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -(((H2-d)/2)-(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 * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-(-nDirVers * (((L2*2)-(d*3))/4))*invG,nPosYcentr,dZedWork) + end + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L2-d)/2)*invG,((H2-d)/2),dZedWork) + + if ( nDeltaMovX > ((L2-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d)/2 + end + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY), EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d)/2)*invG,((H2-d)/2),dZedWork) + pEnd2_r = Point3d(-(((L2-d)/2)-nDeltaMovX)*invG,(((H2-d)/2)-nDeltaMovY), EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + pIni = pEnd + + if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + if jnt then -- se ho cava doppia e devo risalire in Z + -- Uscita in Z0 + dZedWork = dZedStartTw + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + pIni = pEnd2 + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + pEnd_r = pEnd2_r + end + end + + -- calcolo in che caso sono con la prossima geometria + if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro + nCaseNext = 1 + else + nCaseNext = 0 + end + + -- se sono nel caso che ho continuato ad invertire le posizionei + if nCase == 4 then + invG = nOrigInvG + invGy = nOrigInvGy + end + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = pEnd_r + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + else + -- Uscita in Z0 + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + end + else -- svuotature separate + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedStart) -- nuovo punto finale + end + + 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 = -T2 + end + pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = -T2 + pEnd = Point3d((-nDirVers*((L2-d2)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers*((L2-d2)/2))*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + pIni = pEnd + + if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + if jnt then -- se ho cava doppia e devo risalire in Z + + if ( nDeltaMovX > (L2-d2)) then + nDeltaMovX = (L2-d2) + end + -- Uscita in Z0 + dZedWork = dZedStartTw + + pEnd = Point3d(-nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + pIni = pEnd + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + + -- calcolo in che caso sono con la prossima geometria + if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro + nCaseNext = 1 + else + nCaseNext = 0 + end + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2),dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = pEnd_r + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2),dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + else + + -- Uscita in Z0 + dZedWork = 0 + + if ( nDeltaMovX > (L2-d2)) then + nDeltaMovX = (L2-d2) + end + pEnd = Point3d(-nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(nDirVers*(((L2-d2)/2)-nDeltaMovX)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) or ( nCase == 5) then + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedStart) -- nuovo punto finale + end + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2-d2)/dPerim)) + end + pEnd = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2+L2-(2*d2))/dPerim)) + end + pEnd = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*H2)+L2-(3*d2))/dPerim)) + end + pEnd = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + end + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + -- prima linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(-((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2)*invG,-((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + + if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d2)/2 + end + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) + pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio il passaggio centrale + if nCase == 3 and nPass == nStep then -- passaggio di contornatura centrale finale + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) + pEnd2 = Point3d(-(((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) + pEnd2_r = Point3d((((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + end + + if nCase == 4 then -- passaggio di contornatura + un passaggio centrale e inverto la direzione + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L2*2)-(d2*3))/4)*invG,0,dZedWork) + pEnd2 = Point3d(-(((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d2*3))/4)*invG,0,dZedWork) + pEnd2_r = Point3d((((L2*2)-(d2*3))/4)*invG,0, EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- settima linea ritorno a posizione iniziale +-- pIni = pEnd +-- pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) + pIni = pEnd + invG = -invG -- setto per cambiare la posizione del percorso di inizio + invGy = -invGy -- setto per cambiare il senso di percorrenza del percorso + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + + if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d2)/2 + end + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2)*invGy,dZedWork) + pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY)*invGy,EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + elseif nCase == 5 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = -1 + local nDistYcentr = (d2*p2) + local nPosYcentr = ((H2-d2)/2) - nDistYcentr + local bContinue = nPosYcentr > -(((H2-d2)/2)-(d2/2)) + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + end + + -- ciclo passate svuotatura + while bContinue do + + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- linea passata in X + pIni = pEnd + pEnd = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -(((H2-d2)/2)-(d2/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 * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers * (((L2*2)-(d2*3))/4))*invG,nPosYcentr,dZedWork) + end + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) + + if ( nDeltaMovX > ((L2-d2)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L2-d2)/2 + end + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY),EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2-d2)/2)*invG,((H2-d2)/2),dZedWork) + pEnd2_r = Point3d(-(((L2-d2)/2)-nDeltaMovX)*invG,(((H2-d2)/2)-nDeltaMovY),EgtIf(jnt,dZedStartTw,0)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + pIni = pEnd + + if jne then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + if jnt then -- se ho cava doppia e devo risalire in Z + -- Uscita in Z0 + dZedWork = dZedStartTw + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + pIni = pEnd2 + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + pEnd_r = pEnd2_r + end + end + + -- calcolo in che caso sono con la prossima geometria + if abs(H3-d) < 0.03 then -- solo 1 passaggio in centro + nCaseNext = 1 + else + nCaseNext = 0 + end + + -- se sono nel caso che ho continuato ad invertire le posizionei + if nCase == 4 then + invG = nOrigInvG + invGy = nOrigInvGy + end + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d((-(((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd = Point3d(((((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = pEnd_r + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L3-d)/2)*invG)+D_X),0,dZedWork) + else + pEnd_r = Point3d((-(((L3-d)/2)*invG)+D_X),((H3-d)/2)*invGy,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + else + -- Uscita in Z0 + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + end + end + + -- trasformo in geometria composita i/il percorsi/o di svuotatura + -- secondo percorso + if ( #tPocket2 > 0) then + hintPk2 = EgtCurveCompo( Lg, tPocket2, true) + if hintPk2 then + EgtModifyCurveThickness(hintPk2, 0) + EgtSetName(hintPk2,LMM) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2, 'ProbeSide', '1') + end + end + end + + if ( #tPocket2_r > 0) then + hintPk2_r = EgtCurveCompo( Lg, tPocket2_r, true) + if hintPk2_r then + EgtModifyCurveThickness(hintPk2_r, 0) + EgtSetName(hintPk2_r,(LMM..'_R')) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2_r, 'ProbeSide', '1') + end + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint_2 then + EgtSetColor(hint_2,AQUA()) + end + if hintPk2 then + EgtSetColor(hintPk2,AQUA()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,AQUA()) + end + else + if hint_2 then + EgtSetColor(hint_2,ORANGE()) + end + if hintPk2 then + EgtSetColor(hintPk2,ORANGE()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,ORANGE()) + end + end + else -- altrimenti non Preview + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + -- assegno nota su percorsi svuotatura + if hintPk2 then + EgtSetInfo( hintPk2, 'NotCheckDir', '1') + end + if hintPk2_r then + EgtSetInfo( hintPk2_r, 'NotCheckDir', '1') + end + end + + return hint_2, hintPk2, hintPk2_r +end + +return _Mortise diff --git a/LuaLibs/_MortiseCorner.lua b/LuaLibs/_MortiseCorner.lua new file mode 100644 index 0000000..4aa1995 --- /dev/null +++ b/LuaLibs/_MortiseCorner.lua @@ -0,0 +1,954 @@ +-- +-- 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 +-- +-- _MortiseCorner.lua by EgalWare s.r.l. 2016.06.14 +-- Autore: Filippo Monchi +-- Mortise, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2024.07.19 V2.001 FM Set note 'NotCheckDir' to pocketing paths + +-- Tavola per definizione modulo (serve ma non usata) +local _MortiseCorner = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local dExtraH = 0.5 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor(nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor(nCircle2, cColor2) + end + end + + return nLine +end + +-- Funzione di disegno +function _MortiseCorner.Draw( EC, EM, tMortiseParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local T = tMortiseParam.T + local L2 = tMortiseParam.L2 + local H2 = tMortiseParam.H2 + local T2 = tMortiseParam.T2 + local s = tMortiseParam.s + local d = tMortiseParam.d + local p = tMortiseParam.p + local jn = tMortiseParam.jn + local d2 = tMortiseParam.d3 + local p2 = tMortiseParam.p3 + local invG = tMortiseParam.invG + local mkrev = tMortiseParam.mkrev + local jne = tMortiseParam.jne + local L3 = tMortiseParam.L3 + local H3 = tMortiseParam.H3 + local D_X = tMortiseParam.D_X + local pbs = tMortiseParam.pbs + -- Assegno i nomi dei layer + local LGM = tMortiseParam.LGM + local LMM = tMortiseParam.LMM + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tMortiseParam.Nome + -- RunByComponetInterface + local RC = true + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + + if not bRunByCompo then + RC = false + end + + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local hint1, hint2, hint3, hint4, hint5 + local hint_2, hintPk2, hintPk2_r + + if nDrawMach ~= 1 then -- se abilitata geometria esterna + + -- Costruzione della geometria cerniera secondaria + hint1 = DrawAddLineDrawCircle( Point3d(-L2/2,0,0), Point3d(-L2/2,H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint2 = DrawAddLineDrawCircle( Point3d(-L2/2,H2/2,0), Point3d(L2/2,H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint3 = DrawAddLineDrawCircle( Point3d(L2/2,H2/2,0), Point3d(L2/2,-H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint4 = DrawAddLineDrawCircle( Point3d(L2/2,-H2/2,0), Point3d(-L2/2,-H2/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint5 = DrawAddLineDrawCircle( Point3d(-L2/2,-H2/2,0), Point3d(-L2/2,0,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint_2 = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) + EgtModifyCurveThickness(hint_2, -T2) + EgtSetName(hint_2,LGM) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint_2, 'ProbeSide', '1') + 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 tPocket2 = {} + local tPocket2_r = {} + local pIni, pEnd + local pIni_r, pEnd_r + local pEnd2, pEnd2_r + local nCase + local nCaseNext + local dZedStart + local dZedWork + + --------------------------------------- + -- geometria svuotatura giro interno + --------------------------------------- + local nStep + local dStep + local dPerim + local nDirVers + local nPass + + if jn then -- svuotature unite calcolo il numero di passi in Z + + -- individuo in che caso sono + if abs(H2-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H2-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H2-d) > ( d*0.98)) and ( (H2-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (H2-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag + nCase = 4 + end + + dPerim = 2*( H2 + L2 -(d*3/2))+(d*3/2) + nStep = ceil((T2-T)/s) -- numero di passate + dStep = ((T2-T)/nStep) -- passo ricalcolato + dZedStart = -T + else -- svuotature separate ricalcolo i casi e il numero di passi in Z + + -- individuo in che caso sono + if abs(H2-d2) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H2-d2) <= ( d2*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H2-d2) > ( d2*0.98)) and ( (H2-d2) <= (d2*(1+p2))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (H2-d2) > (d2*(1+p2)) then -- passaggio di contornatura + passaggi zig zag + nCase = 4 + end + + dPerim = 2*( H2 + L2 -(d2*3/2))+(d2*3/2) + nStep = ceil(T2/s) -- numero di passate + dStep = (T2/nStep) -- passo ricalcolato + dZedStart = 0 + end + + if jn then -- svuotature unite + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + pEnd = Point3d(((L2-d)/2),0,dZedStart) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(((L2-d)/2),0,dZedStart) + end + + while nPass <= nStep do + + -- primo mezzo passo + pIni = pEnd + dZedWork = dZedStart - (dStep * ( nPass - 0.5)) + pEnd = Point3d(-((L2/2)+dExtraH),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+dExtraH),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- secondo mezzo passo + pIni = pEnd + dZedWork = dZedStart - (dStep * nPass) + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(((L2-d)/2),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + pIni = pEnd + dZedWork = -T2 + pEnd = Point3d(-((L2/2)+dExtraH),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+dExtraH),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + pIni = pEnd + + -- Uscita in Z0 + dZedWork = 0 + + pEnd = Point3d((-((L2/2)+dExtraH)-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-((L2/2)+dExtraH)-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, 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 + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedStart) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedStart) + end + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((L2-(d/2)+(d*3/4))/dPerim)) + end + pEnd = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2+L2-(d*3/2)+(d*3/4))/dPerim)) + end + pEnd = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*L2)+H2-(2*d)+(2*(d*3/4)))/dPerim)) + end + pEnd = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + end + if nCase == 3 then + pEnd = Point3d(-((L2/2)+(d*3/4)),0,dZedWork) + elseif nCase == 4 then + pEnd = Point3d(-((L2/2)+(d*3/4)),(((H2-d)/2)-(d2*p))*invG,dZedWork) + else + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + if nCase == 3 then + pEnd_r = Point3d(-((L2/2)+(d*3/4)),0,dZedWork) + elseif nCase == 4 then + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-(((H2-d)/2)-(d2*p))*invG,dZedWork) + else + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + pIni = pEnd + pEnd = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d)/2),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d)/2),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- quinta linea passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = 1 + local nDistYcentr = (d*p) + local nPosYcentr = ((H2-d)/2) - nDistYcentr + local bContinue = nPosYcentr > -((H2-d)/2) + local dXVal + local bNotFirst = false + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * ((L2/2)+(d*3/4))),nPosYcentr*invG,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * ((L2/2)+(d*3/4))),-nPosYcentr*invG,dZedWork) + end + + -- ciclo passate svuotatura + while bContinue do + + if bNotFirst then -- non faccio il primo posizionamento perchè già posizionato nel giro esterno + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + else + bNotFirst = true + end + + -- linea passata in X + pIni = pEnd + if nDirVers > 0 then + dXVal = (((L2*2)-(d*3))/4) + else + dXVal = ((L2/2)+(d*3/4)) + end + + pEnd = Point3d((nDirVers * dXVal),nPosYcentr*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers * dXVal),-nPosYcentr*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -((H2-d)/2) + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + -- ricalcolo punti per linea successiva + pIni = pEnd + if nDirVers > 0 then + dXVal = (((L2*2)-(d*3))/4) + else + dXVal = ((L2/2)+(d*3/4)) + end + nDirVers = -nDirVers + pEnd = Point3d((-nDirVers * dXVal),nPosYcentr*invG,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * dXVal),-nPosYcentr*invG,dZedWork) + end + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d*3/4)),((H2-d)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d*3/4)),-((H2-d)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d*3/4))-nDeltaMovX),-(((H2-d)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + pIni = pEnd + + -- Uscita in Z0 + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + else -- svuotature separate + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + dZedStart = 0 + pEnd = Point3d(((L2-d2)/2),0,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(((L2-d2)/2),0,dZedStart) -- nuovo punto finale + end + + while nPass <= nStep do + + -- primo mezzo passo + pIni = pEnd + dZedWork = dZedStart - (dStep * ( nPass - 0.5)) + pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- secondo mezzo passo + pIni = pEnd + dZedWork = dZedStart - (dStep * nPass) + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(((L2-d2)/2),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + pIni = pEnd + dZedWork = -T2 + pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + pIni = pEnd + + -- Uscita in Z0 + dZedWork = 0 + + pEnd = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, 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 + dZedStart = 0 + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d2/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedStart) -- nuovo punto finale + end + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((L2-(d2/2)+(d2*3/4))/dPerim)) + end + pEnd = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H2+L2-(d2*3/2)+(d2*3/4))/dPerim)) + end + pEnd = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*L2)+H2-(2*d2)+(2*(d2*3/4)))/dPerim)) + end + pEnd = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T2 + end + end + if nCase == 3 then + pEnd = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + elseif nCase == 4 then + pEnd = Point3d(-((L2/2)+(d2*3/4)),(((H2-d2)/2)-(d2*p))*invG,dZedWork) + else + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + if nCase == 3 then + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),0,dZedWork) + elseif nCase == 4 then + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-(((H2-d2)/2)-(d2*p))*invG,dZedWork) + else + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + -- prima linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(((L2-d2)/2),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(((L2-d2)/2),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- quinta linea passata centrale + pIni = pEnd + pEnd = Point3d((((L2*2)-(d2*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, LIME(), LIME()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((((L2*2)-(d2*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + end + + -- sesta linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = 1 + local nDistYcentr = (d2*p) + local nPosYcentr = ((H2-d2)/2) - nDistYcentr + local bContinue = nPosYcentr > -((H2-d2)/2) + local dXVal + local bNotFirst = false + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * ((L2/2)+(d2*3/4))),nPosYcentr*invG,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * ((L2/2)+(d2*3/4))),-nPosYcentr*invG,dZedWork) + end + + -- ciclo passate svuotatura + while bContinue do + + if bNotFirst then -- non faccio il primo posizionamento perchè già posizionato nel giro esterno + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + else + bNotFirst = true + end + + -- linea passata in X + pIni = pEnd + if nDirVers > 0 then + dXVal = (((L2*2)-(d2*3))/4) + else + dXVal = ((L2/2)+(d2*3/4)) + end + pEnd = Point3d((nDirVers * dXVal),nPosYcentr*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, YELLOW(), YELLOW()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((nDirVers * dXVal),-nPosYcentr*invG,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + end + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -((H2-d2)/2) + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + -- ricalcolo punti per linea successiva + pIni = pEnd + if nDirVers > 0 then + dXVal = (((L2*2)-(d2*3))/4) + else + dXVal = ((L2/2)+(d2*3/4)) + end + nDirVers = -nDirVers + pEnd = Point3d((-nDirVers * dXVal),nPosYcentr*invG,dZedWork) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d((-nDirVers * dXVal),-nPosYcentr*invG,dZedWork) + end + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(-((L2/2)+(d2*3/4)),((H2-d2)/2)*invG,dZedWork) + + if ( nDeltaMovY > ((H2-d2)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H2-d2)/2 + end + + pEnd2 = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(-((L2/2)+(d2*3/4)),-((H2-d2)/2)*invG,dZedWork) + pEnd2_r = Point3d((-((L2/2)+(d2*3/4))-nDeltaMovX),-(((H2-d2)/2)-nDeltaMovY)*invG,0) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + pIni = pEnd + + -- Uscita in Z0 + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket2, bPreview, Dm, (d2/2), false, true, GREEN(), GREEN()) + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + DrawAddLineDrawCircle( pIni_r, pEnd2_r, Lg, tPocket2_r, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + end + end + + -- trasformo in geometria composita i/il percorsi/o di svuotatura + -- secondo percorso + if ( #tPocket2 > 0) then + hintPk2 = EgtCurveCompo( Lg, tPocket2, true) + if hintPk2 then + EgtModifyCurveThickness(hintPk2, 0) + EgtMove( hintPk2, Point3d(L2/2,0,0) - ORIG()) + EgtSetName(hintPk2,LMM) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2, 'ProbeSide', '1') + end + end + end + + if ( #tPocket2_r > 0) then + hintPk2_r = EgtCurveCompo( Lg, tPocket2_r, true) + if hintPk2_r then + EgtModifyCurveThickness(hintPk2_r, 0) + EgtMove( hintPk2_r, Point3d(L2/2,0,0) - ORIG()) + EgtSetName(hintPk2_r,(LMM..'_R')) + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk2_r, 'ProbeSide', '1') + end + end + end + end + + if hint_2 then + EgtMove( hint_2, Point3d(L2/2,0,0) - ORIG()) + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint_2 then + EgtSetColor(hint_2,AQUA()) + end + if hintPk2 then + EgtSetColor(hintPk2,AQUA()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,AQUA()) + end + else + if hint_2 then + EgtSetColor(hint_2,ORANGE()) + end + if hintPk2 then + EgtSetColor(hintPk2,ORANGE()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,ORANGE()) + end + end + else -- altrimenti non Preview + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase( Dm) + end + -- assegno nota su percorsi svuotatura + if hintPk2 then + EgtSetInfo( hintPk2, 'NotCheckDir', '1') + end + if hintPk2_r then + EgtSetInfo( hintPk2_r, 'NotCheckDir', '1') + end + end + + return hint_2, hintPk2, hintPk2_r +end + +return _MortiseCorner diff --git a/LuaLibs/_OPivot.lua b/LuaLibs/_OPivot.lua new file mode 100644 index 0000000..33f23c8 --- /dev/null +++ b/LuaLibs/_OPivot.lua @@ -0,0 +1,3528 @@ +-- +-- 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 +-- +-- _OPivot.lua by EgalWare s.r.l. 2019.06.04 +-- Autore: Filippo Monchi +-- _OPivot, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2019.06.04 V1.001 FM First version +-- 2019.07.29 V1.002 FM Manage new differents pivot models and submodels: Offset pivot with submodel 2 3 4, +-- OffsetInpermediate with submodel 3 +-- the defalult and old one is submodel (1) for all model +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2024.07.19 V2.001 FM Set note 'NotCheckDir' to pocketing and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local OPivot = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- Valori limite +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' +-- contatori +local nTotContEnt = 0 +local nTotContEnt_r = 0 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, + nCounter_r, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nLine = EgtLine(nGroup, pInitial, pFinal, nReference) + local nNumLine + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r and nLine then + nTotContEnt_r = nTotContEnt_r + 1 + elseif nLine then + nTotContEnt = nTotContEnt + 1 + end + + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , nReference) + 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, nCounter_r, sReference) + + local nReference = GDB_RT.LOC + if sReference and sReference == 'grid' then + nReference = GDB_RT.GRID + end + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, nReference) + local nNumCircle + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r and nCircle then + nTotContEnt_r = nTotContEnt_r + 1 + elseif nCircle then + nTotContEnt = nTotContEnt + 1 + end + + 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 , nReference) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, EgtEP( nCircle), nRad , nReference) + EgtSetColor( nCircle2, cColor2) + end + end + + return nCircle, nNumCircle, sMVar +end + +local function DrawSingleAntiSplintPath( bRotHor, tTableRef, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + + local pIni, pEnd + + if bStartAng then + + if bRotHor then -- se antisplint ruotato + + -- linea entrante inclinata + pIni = Point3d(-((dLevelX/2)+dIniPosY)*invG*nInvX, -(((dLevelYRot-dD)/2) - 0.2 - dDeltaPosX)*nInvY,dZedWork) + pEnd = Point3d(-((dLevelX/2)+dPosY)*invG*nInvX, -(((dLevelYRot-dD)/2) - 0.2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linea entrante in X + pIni = pEnd + pEnd = Point3d(-((dLevelX/2)+dEndPosY)*invG*nInvX, -(((dLevelYRot-dD)/2) - 0.2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linee tangente al percorso + pIni = pEnd + pEnd = Point3d(-((dLevelX/2)+dEndPosY)*invG*nInvX, -((dLevelYRot-dD)/2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-((dLevelX/2)+(dD*3/4))*invG*nInvX,-((dLevelYRot-dD)/2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + pIni = pEnd + pEnd = Point3d(pIni:getX(), -(((dLevelYRot-dD)/2) - 0.2 - dDeltaPosX)*nInvY, dZedWork) + else -- antisplint normale + + -- linea entrante inclinata + pIni = Point3d(-(((dLevelX-dD)/2) - 0.2 - dDeltaPosX)*invG*nInvX, (dLevelY+dIniPosY)*nInvY,dZedWork) + pEnd = Point3d(-(((dLevelX-dD)/2) - 0.2)*invG*nInvX, (dLevelY+dPosY)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linea entrante in Y + pIni = pEnd + pEnd = Point3d(-(((dLevelX-dD)/2) - 0.2)*invG*nInvX, (dLevelY+dEndPosY)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linea a tangere il percorso + pIni = pEnd + pEnd = Point3d(-((dLevelX-dD)/2)*invG*nInvX, (dLevelY+dEndPosY)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-((dLevelX-dD)/2)*invG*nInvX,(dLevelY+(dD*3/4))*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + pIni = pEnd + pEnd = Point3d(-(((dLevelX-dD)/2) - 0.2 - dDeltaPosX)*invG*nInvX, pIni:getY(), dZedWork) + end + else -- se entrata singola + + if bRotHor then -- se antisplint ruotato + + if nStep == 1 then + pIni = Point3d(-((dLevelX/2)+dIniPosY)*invG*nInvX, -((dLevelYRot-dD)/2)*nInvY,dZedWork) + pEnd = Point3d(-((dLevelX/2)+dEndPosY)*invG*nInvX, -((dLevelYRot-dD)/2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE()) + else + pIni = Point3d(-((dLevelX/2)+dIniPosY)*invG*nInvX, (-((dLevelYRot-dD)/2)+0.2)*nInvY,dZedWork) + pEnd = Point3d(-((dLevelX/2)+dEndPosY)*invG*nInvX, (-((dLevelYRot-dD)/2)+0.2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + pIni = pEnd + pEnd = Point3d(-((dLevelX/2)+dEndPosY)*invG*nInvX, -((dLevelYRot-dD)/2)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(-((dLevelX/2)+dIniPosY)*invG*nInvX, pIni:getY(), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(pIni:getX(), (-((dLevelYRot-dD)/2)+0.2)*nInvY, dZedWork) + end + else -- antisplint normale + + if nStep == 1 then + pIni = Point3d(-((dLevelX-dD)/2)*invG*nInvX, (dLevelY+dIniPosY)*nInvY,dZedWork) + pEnd = Point3d(-((dLevelX-dD)/2)*invG*nInvX, (dLevelY+dEndPosY)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE(), nil, nil, 'grid') + else + pIni = Point3d(-(((dLevelX-dD)/2) - 0.2)*invG*nInvX, (dLevelY+dIniPosY)*nInvY,dZedWork) + pEnd = Point3d(-(((dLevelX-dD)/2) - 0.2)*invG*nInvX, (dLevelY+dEndPosY)*nInvY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), true, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + -- faccio il ritorno alla posizione di partenza + pIni = pEnd + pEnd = Point3d(-((dLevelX-dD)/2)*invG*nInvX, (dLevelY+dEndPosY)*nInvY, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + pIni = pEnd + pEnd = Point3d( pIni:getX(), (dLevelY+dIniPosY)*nInvY, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tTableRef, bPreview, Dm, (dD/2), false, true, ORANGE(), ORANGE(), nil, nil, 'grid') + + pIni = pEnd + pEnd = Point3d(-(((dLevelX-dD)/2) - 0.2)*invG*nInvX, pIni:getY(), dZedWork) + end + end + end + + return tTableRef, pIni, pEnd + +end + +local function DrawAddAntiSplintPath( dD, dTh, subtype, dLen, dHei, + dHeiHor, bStartAng, stn, invG, Lg, + bPreview, Dm, bEqualTh, sLabel, sLabelR, + dStp, dMainZedStart, bOpzFour, B_SK, bOnKnuckle) + + local nStep + local dStep + local nPass + local dZedWork, dZedStart + + local tPocketAs = {} + local tPocketAs_r = {} + local tPocketAs2 = {} + local tPocketAs2_r = {} + local pIni, pIni2, pEnd, pEnd2 + local pIni_r, pIni2_r, pEnd_r, pEnd2_r + + local tMVar = {} + local tMVar2 = {} + local tMVar_r = {} + local tMVar2_r = {} + local nConEnt + local sKindVar + local dPosY, dEndPosY, dIniPosY, dDeltaPosX + local dLevelX, dLevelY, dLevelYRot + local hintAs1, hintAs2, hintAs3, hintAs4 + + nStep = ceil(dTh/dStp) -- numero di passate + dStep = (dTh/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = dMainZedStart + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + if nStep == 1 then + dZedWork = dZedStart + else + dZedWork = dMainZedStart-dTh + end + end + + if subtype == 2 or subtype == 3 then + dLevelX = dLen + dLevelY = dHei + dLevelYRot = dHeiHor + else + if bOpzFour then + dLevelX = dLen + dLevelY = 0 + dLevelYRot = dHeiHor + else + dLevelX = dLen + dLevelY = dHei-(dHeiHor/2) + dLevelYRot = dHeiHor + end + end + + if bStartAng then -- se lead-in con angolo + + dEndPosY = -(dD/4) + dPosY = dEndPosY + (dD/8) + dIniPosY = dPosY + (dD*7/8) + dDeltaPosX = ( (dD*7/8) / tan(30)) + local nInvX, nInvY + + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + + local bRotGeom = false + + if bOnKnuckle then + if B_SK then + nInvX = -1 + nInvY = -1 + else + nInvX = 1 + nInvY = 1 + end + else + nInvX = 1 + nInvY = 1 + if B_SK and stn then + bRotGeom = true + end + end + + tPocketAs, pIni, pEnd = DrawSingleAntiSplintPath( bRotGeom, tPocketAs, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + -- se il percorso è altro come spessore porta + if bEqualTh and not stn then + + if bOnKnuckle then + if B_SK then + nInvX = 1 + nInvY = 1 + else + nInvX = -1 + nInvY = -1 + end + else + nInvX = -1 + nInvY = -1 + end + tPocketAs2, pIni2, pEnd2 = DrawSingleAntiSplintPath( false, tPocketAs2, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + end + else -- se il pivot sborda + + local bRotGeom = false + + if bEqualTh then -- se il pivot è passante + if bOnKnuckle then + if B_SK then + nInvX = 1 + nInvY = 1 + else + nInvX = -1 + nInvY = -1 + end + else + nInvX = -1 + nInvY = -1 + end + tPocketAs2, pIni2, pEnd2 = DrawSingleAntiSplintPath( bRotGeom, tPocketAs2, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + else -- altrimenti il pivot non è passante, faccio geometria ruotata + + bRotGeom = true -- setto per ruotare geometria + + if bOnKnuckle then + if B_SK then + nInvX = -1 + nInvY = 1 + else + nInvX = 1 + nInvY = 1 + end + else + nInvX = 1 + nInvY = 1 + if B_SK then + bRotGeom = false + end + end + tPocketAs, pIni, pEnd = DrawSingleAntiSplintPath( bRotGeom, tPocketAs, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else -- lead-in diritto + + dEndPosY = -(dD/4) + dIniPosY = (dD*3/4) + + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + + local bRotGeom = false + + if bOnKnuckle then + if B_SK then + nInvX = -1 + nInvY = -1 + else + nInvX = 1 + nInvY = 1 + end + else + nInvX = 1 + nInvY = 1 + if B_SK and stn then + bRotGeom = true + end + end + + tPocketAs, pIni, pEnd = DrawSingleAntiSplintPath( bRotGeom, tPocketAs, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + -- se il percorso è altro come spessore porta + if bEqualTh and not stn then + + if bOnKnuckle then + if B_SK then + nInvX = 1 + nInvY = 1 + else + nInvX = -1 + nInvY = -1 + end + else + nInvX = -1 + nInvY = -1 + end + tPocketAs2, pIni2, pEnd2 = DrawSingleAntiSplintPath( false, tPocketAs2, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + end + else -- se il pivot sborda + + local bRotGeom = false + + if bEqualTh then -- se il pivot è passante + if bOnKnuckle then + if B_SK then + nInvX = 1 + nInvY = 1 + else + nInvX = -1 + nInvY = -1 + end + else + nInvX = -1 + nInvY = -1 + end + tPocketAs2, pIni2, pEnd2 = DrawSingleAntiSplintPath( bRotGeom, tPocketAs2, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + else -- altrimenti il pivot non è passante, faccio geometria ruotata + + bRotGeom = true -- setto per ruotare geometria + + if bOnKnuckle then + if B_SK then + nInvX = -1 + nInvY = 1 + else + nInvX = 1 + nInvY = 1 + end + else + nInvX = 1 + nInvY = 1 + if B_SK then + bRotGeom = false + end + end + tPocketAs, pIni, pEnd = DrawSingleAntiSplintPath( bRotGeom, tPocketAs, dLevelX, dD, dDeltaPosX, + invG, dLevelY, dPosY, dIniPosY, dEndPosY, + dZedWork, Lg, Dm, bPreview, dLevelYRot, + nInvX, nInvY, bStartAng, nStep) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi scendo in z + if nPass <= nStep then + + local pIniLoc + + if #tPocketAs > 0 then + pIniLoc = pEnd + pEnd = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (dD/2), false, true, + ORANGE(), ORANGE(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nConEnt,sKindVar}) + end + + if bEqualTh and #tPocketAs2 > 0 then + pIniLoc = pEnd2 + pEnd2 = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni2, pEnd2, Lg, tPocketAs2, bPreview, Dm, (dD/2), false, true, + ORANGE(), ORANGE(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nConEnt,sKindVar}) + end + + if mkrev then -- se abilitato anche il percorso inverso + end + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs1 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs1, -dTh) + else + 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 + EgtSetName(hintAs1, sLabel) + end + end + + if ( #tPocketAs2 > 0) then + hintAs3 = EgtCurveCompo( Lg, tPocketAs2, true) + if hintAs3 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs3, -dTh) + else + EgtModifyCurveThickness( hintAs3, 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( hintAs3, 'MVar', sListEnt) end + end + EgtSetName(hintAs3, sLabel) + end + end + + if ( #tPocketAs_r > 0) then + hintAs2 = EgtCurveCompo( Lg, tPocketAs_r, true) + if hintAs2 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs2, -dTh) + else + EgtModifyCurveThickness( hintAs2, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end + end + EgtSetName(hintAs2, sLabelR) + end + end + + if ( #tPocketAs2_r > 0) then + hintAs4 = EgtCurveCompo( Lg, tPocketAs2_r, true) + if hintAs4 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs4, -dTh) + else + EgtModifyCurveThickness( hintAs4, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar2_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2_r[i][1], 0) .. ', ' .. 'code=' .. tMVar2_r[i][2] .. '}' + if i < #tMVar2_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs4, 'MVar', sListEnt) end + end + EgtSetName(hintAs4, sLabelR) + end + end + + return hintAs1, hintAs2, hintAs3, hintAs4 +end + +local function CkeckRadiusRemain( dLenghtX, dLengthY, dDiam, dOffsVal, nOffsMade) + + local dRemainX, rRemainY + + dRemainX = ((dLenghtX/2)-(dDiam/2)-(dOffsVal*nOffsMade)) + rRemainY = ( dLengthY -(dDiam/2)-(dOffsVal*nOffsMade)) + + return dRemainX, rRemainY +end + +-- Funzione di disegno +function OPivot.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tPivotParam.L + local H = tPivotParam.H + local T = tPivotParam.T + local L3 = tPivotParam.L3 + local H3 = tPivotParam.H3 + local T3 = tPivotParam.T3 + local radius = tPivotParam.rad + local D_SK = tPivotParam.D_SK + local B_SK = tPivotParam.B_SK + local d = tPivotParam.d + local p = tPivotParam.p + local p3 = tPivotParam.p3 + local sf = tPivotParam.sf + local s3 = tPivotParam.s3 + local d2 = tPivotParam.d2 + local d3 = tPivotParam.d3 + local d4 = tPivotParam.d4 + local jn = tPivotParam.jn + local L2 = tPivotParam.L2 + local H2 = tPivotParam.H2 + local invG = tPivotParam.invG + local mkrev = tPivotParam.mkrev + local stn = tPivotParam.stn + local stnb = tPivotParam.stnb + local ech = tPivotParam.ech + local ptype = tPivotParam.type + local subtype = tPivotParam.stype + local bEqualTh = tPivotParam.bETh + -- Assegno i nomi geometrie + local LG = tPivotParam.LG + local LM = tPivotParam.LM + local LA = tPivotParam.LA + local LGV = tPivotParam.LGV + local LMV = tPivotParam.LMV + local LAV = tPivotParam.LAV + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tPivotParam.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = true + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not 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 radius or abs(radius) <= GEO.EPS_SMALL then + radius = 0 + end + + -- se tipo intermediate e sottotipo 3, lo risetto perchè le geometrie sono come quelle del sottotipo 2 + if ptype == 2 and subtype == 3 then + subtype = 2 + 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + -- variabili geometrie restituite in uscita + local hint -- disegno geometrie principale (o del knuckle) + local hintPk -- disegno svuotatura principale (o del knuckle) + local hintAs1 -- percorso antischeggia normale ( o sul knuckle) + local hintAs2 -- percorso antischeggia reverso ( o sul knuckle) + local hintPk_r -- disegno svuotatura principale reverso (o del knuckle) + local hintAs3 -- secondo percorso anticheggia normale su spessore passante del knuckle + local hintAs4 -- secondo percorso anticheggia reverso su spessore passante del knuckle + local hint2 -- disegno geometrie body + local hintPk2 -- disegno svuotatura body + local hintAs1b -- percorso antischeggia normale ( o sul knuckle) + local hintAs2b -- percorso antischeggia reverso ( o sul knuckle) + local hintPk2_r -- disegno svuotatura reverso body + local hintAs3b -- secondo percorso anticheggia normale su spessore passante del knuckle + local hintAs4b -- secondo percorso anticheggia reverso su spessore passante del knuckle + -- variabili punto + local pIni, pEnd, pCentr + + -- creo lo stesso la geometria esterna perché viene utilizzata anche per creare il percorso di lavorazione + -- se non è previsto viene eliminato dopo + + local tPocket = {} +-- stn = false +-- stnb = false + + -- setto la griglia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + -- Costruzione della geometria del knuckle pivot ( in senso orario) + if T3 and LG then + + if subtype == 2 or subtype == 3 then + + if stn then + + if invG < 0 then + + if B_SK then + -- mezza linea verso destra +-- pIni = Point3d(0,H3+dExtraH,0) +-- pEnd = Point3d((L3/2),H3+dExtraH,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + + pIni = Point3d((L3/2),H3+dExtraH,0) + pEnd = Point3d((L3/2),-(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-((L3/2)+(d3/2)+dExtraH),-(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-((L3/2)+(d3/2)+dExtraH),H3+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- pEnd = Point3d(0,H3+dExtraH,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + else + + -- mezza linea verso sinistra +-- pIni = Point3d(0,-(H3+dExtraH),0) +-- pEnd = Point3d(-(L3/2),-(H3+dExtraH),0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + + pIni = Point3d(-(L3/2),-(H3+dExtraH),0) + pEnd = Point3d(-(L3/2),(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(((L3/2)+(d3/2)+dExtraH),(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(((L3/2)+(d3/2)+dExtraH),-(H3+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- pEnd = Point3d(0,-(H3+dExtraH,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + else + + if B_SK then + + -- mezza linea verso sinistra +-- pIni = Point3d(0,-(H3+dExtraH),0) +-- pEnd = Point3d(-((L3/2)+(d3/2)+dExtraH),-(H3+dExtraH),0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + + pIni = Point3d(-((L3/2)+(d3/2)+dExtraH),-(H3+dExtraH),0) + pEnd = Point3d(-((L3/2)+(d3/2)+dExtraH),(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d((L3/2),(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d((L3/2),-(H3+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- pEnd = Point3d(0,-(H3+dExtraH),0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + else + + -- mezza linea verso destra +-- pIni = Point3d(0,H3+dExtraH,0) +-- pEnd = Point3d(((L3/2)+(d3/2)+dExtraH),H3+dExtraH,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + + pIni = Point3d(((L3/2)+(d3/2)+dExtraH),H3+dExtraH,0) + pEnd = Point3d(((L3/2)+(d3/2)+dExtraH),-(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-(L3/2),-(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-(L3/2),H3+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- pEnd = Point3d(0,H3+dExtraH,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + end + else + + -- mezza linea verso destra +-- pIni = Point3d(0,H3+dExtraH,0) +-- pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),H3+dExtraH,0), Point3d((L3/2),H3+dExtraH,0)) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + + pIni = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),H3+dExtraH,0), Point3d((L3/2),H3+dExtraH,0)) + pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),-(H3+(d3/2)+dExtraH),0), Point3d((L3/2),-(H3+(d3/2)+dExtraH),0)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-(L3/2),-(H3+(d3/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d(-(L3/2),H3+dExtraH,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- pEnd = Point3d(0,H3,0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + else -- sottotipo 4 + +-- -- linea verso destra +-- pIni = Point3d(0,(H3-(H/2)),0) +-- if ech then +-- pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)),(H3-(H/2)),0), Point3d((L3/2)-dExtraH,(H3-(H/2)),0)) +-- else +-- pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),(H3-(H/2)),0), Point3d(L3/2,(H3-(H/2)),0)) +-- end +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + +-- if ech then + -- arco orario verso destra +-- pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),(H3-(H/2)-dExtraH),0), Point3d((L3/2),(H3-(H/2)-dExtraH),0)) +-- pCentr = EgtIf( stn, Point3d(((L3/2)+(d3/2)),(H3-(H/2)-dExtraH),0), Point3d((L3/2)-dExtraH,(H3-(H/2)-dExtraH),0)) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + + pIni = EgtIf( stn, Point3d((((L3+d3)/2)+dExtraH),(H3-(H/2))+dExtraH,0), Point3d((L3/2),(H3-(H/2))+dExtraH,0)) + + if ech then + pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),-(H/2)+dExtraH,0), Point3d((L3/2),-(H/2)+dExtraH,0)) + else + pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)+dExtraH),-(H/2),0), Point3d((L3/2),-(H/2),0)) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + if ech then + -- arco orario verso sinistra + pEnd = EgtIf( stn, Point3d(((L3/2)+(d3/2)),-(H/2),0), Point3d((L3/2)-dExtraH,-(H/2),0)) + pCentr = EgtIf( stn, Point3d(((L3/2)+(d3/2)),-(H/2)+dExtraH,0), Point3d((L3/2)-dExtraH,-(H/2)+dExtraH,0)) + DrawAddCircleDrawCircle( pCentr, dExtraH, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + pEnd = Point3d(-(L3/2),-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- if ech then +-- pEnd = Point3d(-(L3/2),(H3-(H/2)-dExtraH),0) +-- else + pEnd = Point3d(-(L3/2),(H3-(H/2))+dExtraH,0) +-- end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- if ech then +-- -- arco orario verso destra +-- pEnd = Point3d(-(L3/2)+dExtraH,(H3-(H/2)),0) +-- pCentr = Point3d(-(L3/2)+dExtraH,(H3-(H/2)-dExtraH),0) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + +-- pEnd = Point3d(0,(H3-(H/2)),0) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + + hint = EgtCurveCompo( Lg, tPocket, true) + EgtModifyCurveThickness( hint, -T3) + EgtSetName( hint, LG) + end + + tPocket = {} + local stx + + -- Costruzione della geometria del corpo pivot ( in senso orario) + if T and LGV then + + if subtype == 2 or subtype == 3 then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + end + + if subtype == 2 or subtype == 3 then + + if not H3 then H3 = DGD.dT end + if not L3 then L3 = 0 end + + local dXval + local dXdim + + if subtype == 2 then + dXdim = L3 +-- dXval = -((L-L3)/2) + dXval = dXdim/2 + stx = stn + else +-- dXval = 0 + dXval = H/2 + dXdim = H + stx = stnb + end + + if stx then +-- pIni = Point3d(dXval, dExtraH,H3) + pIni = EgtIf( B_SK, Point3d( dXval, dExtraH,H3), Point3d( (dXval+(d/2)+dExtraH), dExtraH,H3)) + + -- mezza linea verso destra +-- if ech then +-- pEnd = EgtIf( B_SK, Point3d((dXdim/2)-dExtraH,0,H3), Point3d(((dXdim+d)/2),0,H3)) +-- else +-- pEnd = EgtIf( B_SK, Point3d((dXdim/2),0,H3), Point3d((((dXdim+d)/2)+dExtraH),0,H3)) +-- end +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + +-- if ech then + -- arco orario verso destra +-- pEnd = EgtIf( B_SK, Point3d((dXdim/2),-dExtraH,H3), Point3d(((dXdim/2)+(d/2)+dExtraH),-dExtraH,H3)) +-- pCentr = EgtIf( B_SK, Point3d((dXdim/2)-dExtraH,-dExtraH,H3), Point3d(((dXdim/2)+(d/2)),-dExtraH,H3)) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + + local dYval + if subtype == 2 then + dYval = H + else + dYval = L + end + + if B_SK then + if radius > 0 then + pEnd = Point3d((dXdim/2),-dYval+radius,H3) + else + pEnd = Point3d((dXdim/2),-dYval,H3) + end + else + if ech then + pEnd = Point3d(((dXdim/2)+(d/2)+dExtraH),-dYval+dExtraH,H3) -- considero un raccordino seguente + else + pEnd = Point3d(((dXdim/2)+(d/2)+dExtraH),-dYval,H3) + end + end + + -- linea discendente + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if B_SK then + if radius > 0 then + pEnd = Point3d((dXdim/2)-radius,-dYval,H3) + pCentr = Point3d((dXdim/2)-radius,-dYval+radius,H3) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + else + if ech then + pEnd = Point3d(((dXdim/2)+(d/2)),-dYval,H3) + pCentr = Point3d(((dXdim/2)+(d/2)),-dYval+dExtraH,H3) + DrawAddCircleDrawCircle( pCentr, dExtraH, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + end + + if subtype == 2 then + dXval = (dXdim/2)-L + else + dXval = -(dXdim/2) + end + + -- linea verso sinistra + if B_SK then + if ech then + pEnd = Point3d( dXval-(d/2),-dYval,H3) + else + pEnd = Point3d( dXval-(d/2)-dExtraH,-dYval,H3) + end + else + if radius > 0 then + pEnd = Point3d( dXval+radius,-dYval,H3) + else + pEnd = Point3d( dXval,-dYval,H3) + end + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if B_SK then + if ech then + pEnd = Point3d( dXval-(d/2)-dExtraH,-dYval+dExtraH,H3) + pCentr = Point3d( dXval-(d/2),-dYval+dExtraH,H3) + DrawAddCircleDrawCircle( pCentr, dExtraH, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + else + if radius > 0 then + pEnd = Point3d( dXval,-dYval+radius,H3) + pCentr = Point3d( dXval+radius,-dYval+radius,H3) + DrawAddCircleDrawCircle( pCentr, radius, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + end + + -- linea risale in Y + if B_SK then +-- if ech then +-- pEnd = Point3d( dXval-(d/2)-dExtraH,-dExtraH,H3) +-- else +-- pEnd = Point3d( dXval-(d/2)-dExtraH,0,H3) +-- end + pEnd = Point3d( dXval-(d/2)-dExtraH,dExtraH,H3) + else +-- if ech then +-- pEnd = Point3d( dXval,-dExtraH,H3) +-- else +-- pEnd = Point3d( dXval,0,H3) +-- end + pEnd = Point3d( dXval,dExtraH,H3) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + if B_SK then +-- if ech then +-- pEnd = Point3d( dXval-(d/2),dExtraH,H3) +-- pCentr = Point3d( dXval-(d/2), 0,H3) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + +-- if subtype == 2 then +-- pEnd = Point3d(-((L-dXdim)/2),0,H3) +-- else +-- pEnd = Point3d(0,0,H3) +-- end + else +-- if ech then +-- pEnd = Point3d( dXval+dExtraH,0,H3) +-- pCentr = Point3d( dXval+dExtraH,-dExtraH,H3) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + +-- if subtype == 2 then +-- pEnd = Point3d(-((L-dXdim)/2),0,H3) +-- else +-- pEnd = Point3d(0,0,H3) +-- end + end + +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + else +-- pIni = Point3d(dXval, dExtraH,H3) + pIni = Point3d( dXval, dExtraH,H3) + + -- mezza linea verso destra +-- if ech then +-- pEnd = Point3d((dXdim/2)-dExtraH,0,H3) +-- else +-- pEnd = Point3d((dXdim/2),0,H3) +-- end +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + +-- if ech then + -- arco orario verso destra +-- pEnd = Point3d((dXdim/2),-dExtraH,H3) +-- pCentr = Point3d((dXdim/2)-dExtraH,-dExtraH,H3) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + + local dYval + if subtype == 2 then + dYval = H + else + dYval = L + end + + if radius > 0 then + pEnd = Point3d((dXdim/2),-dYval+radius,H3) + else + pEnd = Point3d((dXdim/2),-dYval,H3) + end + + -- linea discendente + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if radius > 0 then + pEnd = Point3d((dXdim/2)-radius,-dYval,H3) + pCentr = Point3d((dXdim/2)-radius,-dYval+radius,H3) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + if subtype == 2 then + dXval = (dXdim/2)-L + else + dXval = -(dXdim/2) + end + + -- linea verso sinistra + if radius > 0 then + pEnd = Point3d( dXval+radius,-dYval,H3) + else + pEnd = Point3d( dXval,-dYval,H3) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if radius > 0 then + pEnd = Point3d( dXval,-dYval+radius,H3) + pCentr = Point3d( dXval+radius,-dYval+radius,H3) + DrawAddCircleDrawCircle( pCentr, radius, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + -- linea risale in Y +-- if ech then +-- pEnd = Point3d( dXval,-dExtraH,H3) +-- else +-- pEnd = Point3d( dXval,0,H3) +-- end + pEnd = Point3d( dXval,dExtraH,H3) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- if ech then +-- pEnd = Point3d( dXval+dExtraH,0,H3) +-- pCentr = Point3d( dXval+dExtraH,-dExtraH,H3) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + +-- if subtype == 2 then +-- pEnd = Point3d(-((L-dXdim)/2),0,H3) +-- else +-- pEnd = Point3d(0,0,H3) +-- end + +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + else -- sottotipo 4 + + stx = stnb + pIni = EgtIf( stnb, Point3d((H/2)+(d/2)+dExtraH,dExtraH,(L3/2)), Point3d((H/2),dExtraH,(L3/2))) +-- pIni = Point3d(0,0,(L3/2)) + + -- mezza linea verso destra +-- if ech then +-- pEnd = EgtIf( stnb, Point3d((H/2)+(d/2),0,(L3/2)), Point3d((H/2)-dExtraH,0,(L3/2))) +-- else +-- pEnd = EgtIf( stnb, Point3d((H/2)+(d/2)+dExtraH,0,(L3/2)), Point3d((H/2),0,(L3/2))) +-- end +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + +-- if ech then +-- pEnd = EgtIf( stnb, Point3d((H/2)+(d/2)+dExtraH,-dExtraH,(L3/2)), Point3d((H/2),-dExtraH,(L3/2))) +-- pCentr = EgtIf( stnb, Point3d((H/2)+(d/2),-dExtraH,(L3/2)), Point3d((H/2)-dExtraH,-dExtraH,(L3/2))) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + + -- linea discesa in Y + if stnb then + if ech then + pEnd = Point3d((H/2)+(d/2)+dExtraH,-L+dExtraH,(L3/2)) + else + pEnd = Point3d((H/2)+(d/2)+dExtraH,-L,(L3/2)) + end + else + if radius > 0 then + pEnd = Point3d((H/2),-L+radius,(L3/2)) + else + pEnd = Point3d((H/2),-L,(L3/2)) + end + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if stnb then + if ech then + pEnd = Point3d((H/2)+(d/2),-L,(L3/2)) + pCentr = Point3d((H/2)+(d/2),-L+dExtraH,(L3/2)) + DrawAddCircleDrawCircle( pCentr, dExtraH, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + else + if radius > 0 then + pEnd = Point3d((H/2)-radius,-L,(L3/2)) + pCentr = Point3d((H/2)-radius,-L+radius,(L3/2)) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + end + + -- linea verso sinistra + if radius > 0 then + pEnd = Point3d(-(H/2)+radius,-L,(L3/2)) + else + pEnd = Point3d(-(H/2),-L,(L3/2)) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- arco orario verso sinistra + if radius > 0 then + pEnd = Point3d(-(H/2),-(L-radius),(L3/2)) + pCentr = Point3d(-(H/2)+radius,-(L-radius),(L3/2)) + DrawAddCircleDrawCircle( pCentr, radius, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + -- linea risalita in Y +-- if ech then +-- pEnd = Point3d(-(H/2),-dExtraH,(L3/2)) +-- else +-- pEnd = Point3d(-(H/2),0,(L3/2)) +-- end + pEnd = Point3d(-(H/2),dExtraH,(L3/2)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + +-- if ech then +-- pEnd = Point3d(-(H/2)+dExtraH,0,(L3/2)) +-- pCentr = Point3d(-(H/2)+dExtraH,-dExtraH,(L3/2)) +-- DrawAddCircleDrawCircle( pCentr, dExtraH, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd +-- end + + -- ultima mezza linea verso destra +-- pEnd = Point3d(0,0,(L3/2)) +-- DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED(), nil, nil, 'grid') +-- pIni = pEnd + end + + hint2 = EgtCurveCompo( Lg, tPocket, true) + EgtModifyCurveThickness( hint2, -T) + EgtSetName( hint2, LGV) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + + -- debug +-- nDrawMach = 0 + + ---------------------------------------------- + ---------------------------------------------- + -- 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 bOnKnuckle = true + + -- geometria antischeggia percorso principale o knuckle + if d4 and hint then -- se parametro valido + + hintAs1, hintAs2, hintAs3, hintAs4 = DrawAddAntiSplintPath( d4, T3, subtype, L3, H3, + H, bStartAng, stn, invG, Lg, + bPreview, Dm, bEqualTh, LA, (LA..'_R'), + s3, 0, nil, B_SK, bOnKnuckle) + end + + -- geometria antischeggia percorso body + if d2 and hint2 then -- se parametro valido + + local dLocXStart, dLocYStart, dLocZStart, dLocYAmp + local bOpzFour + + if subtype == 2 or subtype == 3 then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + if subtype == 2 then + if invG > 0 then + dLocXStart = (L*2)-L3 + else + dLocXStart = L3 + end + dLocYAmp = H*2 + else + dLocXStart = H + dLocYAmp = L*2 + end + dLocYStart = 0 + dLocZStart = H3 + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + dLocXStart = H -- larghezza cava (posizione z globale) + dLocYStart = H/2 -- partenza Y (posizione y globale) + dLocYAmp = L*2 + dLocZStart = L3/2 + bOpzFour = true + end + + bOnKnuckle = false + hintAs1b, hintAs2b, hintAs3b, hintAs4b = DrawAddAntiSplintPath( d2, T, subtype, dLocXStart, dLocYStart, + dLocYAmp, bStartAng, stnb, invG, Lg, + bPreview, Dm, false, LAV, (LAV..'_R'), + sf, dLocZStart, bOpzFour, B_SK, bOnKnuckle) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + local tPocket = {} + local tPocket_r = {} + local tPocket2 = {} + local tPocket2_r = {} + local tMVar = {} + local tMVar2 = {} + local tMVar_r = {} + local tMVar2_r = {} + local pIni, pIni2, pEnd, pEnd2 + local nCase, nCaseNext + local dZedStart, dZedWork + local nRadius, hint_ofs, hint_ofs_r, hint_ofs2, hint_ofs2_r + local pIni_r, pEnd_r + local nStep + local dStep + local nPass + local pStartStep + local pStartStep_r + + ------------------------------------ + -- se è presente geometria knuckle + ------------------------------------ + if d3 and hint then + + local dDimMin + local dDimMin2 + + if subtype == 2 or subtype == 3 then + -- individuo in che caso sono + if L3 > (H3*2) then + local dLenComp = EgtIf( stn, L3+(d3/2)+dExtraH,L3) + dDimMin = max( ((H3*2)+(d3/2)+dExtraH), dLenComp) + dDimMin2 = min( ((H3*2)+(d3/2)+dExtraH), dLenComp) + dDimMin2 = dDimMin2 * 2 + else -- se larghezza più stretta dell'altezza + dDimMin2 = min( ((H3*2)+(d3/2)+dExtraH), EgtIf( stn, L3+(d3/2)+dExtraH,L3)) + dDimMin = dDimMin2 + end + else + -- individuo in che caso sono + dDimMin = max( H3, EgtIf( stn, L3+(d3/2)+dExtraH,L3)) + dDimMin2 = min( H3, EgtIf( stn, L3+(d3/2)+dExtraH,L3)) + + -- se il minimo è sull'altezza cava che sborda sempre sul lato dell'altezza lo raddoppio + if abs( dDimMin2 - H3) < GEO.EPS_SMALL then + dDimMin2 = dDimMin2 * 2 + end + end + + if abs(dDimMin-d3) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (dDimMin-d3) <= ( d3*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((dDimMin-d3) > ( d3*0.98)) and ( (dDimMin-d3) <= (d3*(1+p3))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (dDimMin-d3) > (d3*(1+p3)) then -- passaggio di contornatura + passaggi offset + nCase = 4 + end + + local nDirVers = 1 + local nConEnt + local sKindVar + local dLocPosY + local dLocPosX + + -- resetto contatori entità + nTotContEnt = 0 + nTotContEnt_r = 0 + nRadius = dDimMin2/2 + nPass = 1 + dZedStart = 0 + nStep = ceil(T3/s3) -- numero di passate + dStep = (T3/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T3 + end + + if nCase == 1 then -- solo 1 passaggio in centro + + if nDirVers == 1 then -- se passata di andata + if subtype == 2 or subtype == 3 then + dLocPosY = (H3+(d3*3/4)) + else + dLocPosY = (H3-(H/2)+(d3*3/4)) + end + pIni = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY, dZedWork) + pStartStep = pIni + if subtype == 4 then + dLocPosY = ((H-d3)/2) + end + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else -- altrimenti passata di ritorno + + if subtype == 2 or subtype == 3 then + dLocPosY = (H3+(d3*3/4)) + else + dLocPosY = ((H-d3)/2) + end + pIni = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY, dZedWork) + if subtype == 4 then + dLocPosY = (H3-(H/2)+(d3*3/4)) + end + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + -- calcolo l'ampiezza dell'offset + nRadius = nRadius - (d3/2) + + -- offset + hint_ofs = EgtOffsetCurveAdv( hint, (d3/2), GDB_OT.FILLET) + + if hint_ofs and hint_ofs > 0 then + + if mkrev then -- se abilitato anche il percorso inverso + -- copia del percorso offsettato + hint_ofs_r = EgtCopyGlob( hint_ofs, Lg) + end + + -- 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 bStartOppo then + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + if subtype == 2 or subtype == 3 then + if B_SK then + if not stn then + dLocPosY = (H3+(d3*3/4)) + else + dLocPosY = -(H3+(d3*3/4)) + end + else + dLocPosY = (H3+(d3*3/4)) + end + if B_SK then + if not stn then + pIni = Point3d(-((L3-d3)/2)*invG, dLocPosY,dZedWork) + else + pIni = Point3d((((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + end + else + pIni = Point3d(-(((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + end + pStartStep = pIni + -- linea in Y con centro utensile fuori + if B_SK then + if not stn then + dLocPosY = H3+dExtraH + else + dLocPosY = -(H3+dExtraH) + end + else + dLocPosY = H3+dExtraH + end + if B_SK then + if not stn then + pEnd = Point3d(-((L3-d3)/2)*invG, dLocPosY,dZedWork) + else + pEnd = Point3d((((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + end + else + pEnd = Point3d(-(((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + if B_SK then + if not stn then + dLocPosX = -((L3-d3)/2)*invG + else + dLocPosX = -((L3/2)+dExtraH)*invG + end + else + dLocPosX = ((L3-d3)/2)*invG + end + pEnd = Point3d( dLocPosX, dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- altro sottotipo + dLocPosY = (H3-(H/2)+(d3*3/4)) + pIni = Point3d(-(((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + dLocPosY = (H3-(H/2))+dExtraH + pEnd = Point3d(-(((L3-d3)/2) - 0.2)*invG, dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + if stn then -- se è aperto dall'altro lato + dLocPosX = ((L3/2)+dExtraH)*invG + else + dLocPosX = ((L3-d3)/2)*invG + end + pEnd = Point3d( dLocPosX, dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + else -- se il pivot sborda faccio geometria opposta o ruotata in base al sottotipo + + if subtype == 2 or subtype == 3 then -- inserimento opposto + + if B_SK then + + pIni = Point3d(-(((L3-d3)/2) - 0.2)*invG, (H3+(d3*3/4)),dZedWork) + pStartStep = pIni + -- linea in Y opposta con centro utensile fuori + pEnd = Point3d(-(((L3-d3)/2) - 0.2)*invG, (H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea in X opposta con centro utensile fuori + pEnd = Point3d(((L3/2)+dExtraH)*invG, (H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + else + + pIni = Point3d((((L3-d3)/2) - 0.2)*invG, -(H3+(d3*3/4)),dZedWork) + pStartStep = pIni + -- linea in Y opposta con centro utensile fuori + pEnd = Point3d((((L3-d3)/2) - 0.2)*invG, -(H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea in X opposta con centro utensile fuori + pEnd = Point3d(-((L3-d3)/2)*invG, -(H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- altro tipo: inserimento sul fianco + + pIni = Point3d(-((L3/2)+(d3*3/4))*invG, (-((H-d3)/2)+0.2),dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(-((H-d3)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni = pEnd + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((L3-d3)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + else -- se attacco al vecchio punto + + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + + -- prima linea entrante + if subtype == 2 or subtype == 3 then + dLocPosY = (H3+(d3*3/4)) + dLocPosX = ((L3-d3)/2)*invG + else + dLocPosY = (H3-(H/2)+(d3*3/4)) + if stn then -- se è aperto dall'altro lato + dLocPosX = ((L3/2)+dExtraH)*invG + else + dLocPosX = ((L3-d3)/2)*invG + end + end + pIni = Point3d( dLocPosX, dLocPosY,dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- se il pivot sborda faccio geometria opposta o ruotata in base al sottotipo + + if subtype == 2 or subtype == 3 then -- inserimento opposto + + pIni = Point3d((((L3-d3)/2) - 0.2)*invG, -(H3+(d3*3/4)),dZedWork) + pStartStep = pIni + -- linea in Y opposta con centro utensile fuori + pEnd = Point3d((((L3-d3)/2) - 0.2)*invG, -(H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea in X opposta con centro utensile fuori + pEnd = Point3d(-((L3-d3)/2)*invG, -(H3+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- inserimento sul fianco + + -- prima linea entrante + pIni = Point3d(-((L3/2)+(d3*3/4))*invG,(-((H-d3)/2)+0.2),dZedWork) + pStartStep = pIni + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(-((H-d3)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni = pEnd + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((L3-d3)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + + if subtype == 2 or subtype == 3 then + + -- linea posizionamento passata centrale + if B_SK then + if not stn then + dLocPosY = H3+dExtraH + else + dLocPosY = -(H3+dExtraH) + end + else + dLocPosY = H3+dExtraH + end + pIni = pEnd + if B_SK then + if not stn then + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + else + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + else + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + if B_SK then + if not stn then + dLocPosY = (H3+dExtraH) + else + dLocPosY = -(H3+dExtraH) + end + else + dLocPosY = (H3+dExtraH) + end + if B_SK then + if not stn then + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + else + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + end + else + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + if B_SK then + if not stn then + dLocPosY = H3+dExtraH + else + dLocPosY = -(H3+dExtraH) + end + else + dLocPosY = H3+dExtraH + end + if B_SK then + if not stn then + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + else + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + else + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + -- linea posizionamento passata centrale + dLocPosY = (H3-(H/2))+dExtraH + pIni = pEnd + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + dLocPosY = ((H-d3)/2)-0.2 + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + dLocPosY = (H3-(H/2))+dExtraH + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + else -- il pivot sborda, inserimento opposto + + if subtype == 2 or subtype == 3 then + + -- linea posizionamento passata centrale + if B_SK then + dLocPosY = -(H3+dExtraH) + else + dLocPosY = H3+dExtraH + end + pIni = pEnd + if B_SK then + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + else + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + pEnd = Point3d( pIni:getX(), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd = Point3d( pIni:getX(), -dLocPosY+dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else -- altrimenti altro sottotipo + + -- linea posizionamento passata centrale + dLocPosY = (H3-(H/2)) + pIni = pEnd + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY+dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + dLocPosY = ((H-d3)/2)-0.2 + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), -dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + dLocPosY = (H3-(H/2)) + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY+dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + local nDistYcentr = (d3*p3) + local bContinue + + -- se percorso offset esiste + if hint_ofs and hint_ofs > 0 then + + -- faccio l'offset del raggio fresa + nRadius = nRadius - nDistYcentr + bContinue = nRadius > 0 + nCountOfs = 0 + local nInvOffs = 1 + local bFailOfs = false + local dCompareX = L3 + local dCompareY = H3 + local dRemX, dRemY + + if stn then + dCompareX = L3+(d3/2)+dExtraH + end + if subtype == 2 or subtype == 3 then + dCompareY = H3*2 + end + + -- se percorso offset esiste + while bContinue do + + hint_ofs2 = EgtOffsetCurveAdv( hint_ofs, nDistYcentr*invG*nInvOffs, GDB_OT.FILLET) + + if hint_ofs2 and hint_ofs2 > 0 then + + nCountOfs = nCountOfs + 1 + + -- linea congiunzione tra offset + pIni = pEnd + -- inverto il percorso + EgtInvertCurve(hint_ofs2) + pEnd = EgtSP( hint_ofs2, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs2, GDB_RT.GRID) + hint_ofs = hint_ofs2 + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + + if mkrev then -- se abilitato anche il percorso inverso + + end + + -- calcolo nuovo passo in Y e indice direzione + nRadius = nRadius - nDistYcentr + if nRadius > 0 then + dRemX, dRemY = CkeckRadiusRemain( dCompareX, dCompareY, d3, nDistYcentr, (nCountOfs+1)) + if (dRemX and dRemX > (d3/4)) or ( dRemY and dRemY > d3) then + bContinue = true + else + bContinue = false + end + else + bContinue = false + end + nInvOffs = -nInvOffs + else + bContinue = false + bFailOfs = true + end + end -- end while + + if p > 0.75 then -- se la percentuale di sovrapposizione è alta + + local nMakeExtraPass = 0 + -- ricalcolo le rimanenze + dRemX, dRemY = CkeckRadiusRemain( dCompareX, dCompareY, d3, nDistYcentr, nCountOfs) + + -- calcolo in quale direzione ha collassato + if dRemX > dRemY then -- se larghezza risultante maggiore + if dRemY > d3 then -- se la passata precedente è maggiore del diametro utensile + nMakeExtraPass = 2 -- passata orizzontale + end + else -- altezza risultante maggiore della larghezza + if dRemX > (d3/2.02) then -- se la passata precedente è maggiore del raggio utensile + nMakeExtraPass = 1 -- passata verticale + end + end + + if nMakeExtraPass == 1 then -- se passata verticale + + if subtype == 2 or subtype == 3 then + + -- linea posizionamento passata centrale + if B_SK then + if invG > 0 then + dLocPosY = -(H3+dExtraH) + else + dLocPosY = (H3+dExtraH) + end + else + dLocPosY = H3+dExtraH + end + pIni = pEnd + if B_SK then + if invG > 0 then + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + else + pEnd = Point3d( EgtIf( stn, -(((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + else + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + pEnd = Point3d( pIni:getX(), -dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd = Point3d( pIni:getX(), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else -- altrimenti atro sottotipo + + -- linea posizionamento passata centrale + dLocPosY = (H3-(H/2))+dExtraH + pIni = pEnd + pEnd = Point3d( EgtIf( stn, (((d3/2)+dExtraH)/2), 0), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + dLocPosY = ((H-d3)/2)-0.2 + pEnd = Point3d( pIni:getX(), -dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + dLocPosY = (H3-(H/2))+dExtraH + pEnd = Point3d( pIni:getX(), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + elseif nMakeExtraPass == 2 then -- se passata orizzontale + + if subtype == 2 or subtype == 3 then + -- linea posizionamento passata orizzontale + pIni = pEnd + if B_SK then + if invG > 0 then + dLocPosY = -(H3+dExtraH) + else + dLocPosY = (H3+dExtraH) + end + pEnd = Point3d( EgtIf( stn, -((L3+(d3/2)+dExtraH)/2), -((L3/2)-(d3*3/4))), dLocPosY,dZedWork) + else + dLocPosY = (H3+dExtraH) + pEnd = Point3d( EgtIf( stn, ((L3+(d3/2)+dExtraH)/2), ((L3/2)-(d3*3/4))), dLocPosY,dZedWork) + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linea posizionamento in Y + if B_SK then + if invG > 0 then + dLocPosY = (H3-(d3/2)) + else + dLocPosY = -(H3-(d3/2)) + end + else + dLocPosY = -(H3-(d3/2)) + end + pEnd = Point3d( pIni:getX(), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linea attraversamento in X + if B_SK then + if invG > 0 then + pEnd = Point3d( ((L3/2)-(d3*3/4)), pIni:getY(),dZedWork) + else + pEnd = Point3d( -((L3/2)-(d3*3/4)), pIni:getY(),dZedWork) + end + else + pEnd = Point3d( -((L3/2)-(d3*3/4)), pIni:getY(),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- risalgo in Y fuori dalla svuotatura + if B_SK then + if invG > 0 then + dLocPosY = -(H3+(d3*3/4)) + else + dLocPosY = (H3+(d3*3/4)) + end + else + dLocPosY = (H3+(d3*3/4)) + end + pEnd = Point3d( pIni:getX(), dLocPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + dLocPosY = (H3-(H/2)) + + -- linea posizionamento passata orizzontale + pIni = pEnd + pEnd = Point3d( EgtIf( stn, (((L3+d3)/2)+dExtraH)-(d3*3/4), (L3/2)-(d3*3/4)), dLocPosY+dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linea posizionamento in Y + pEnd = Point3d( pIni:getX(), dLocPosY-(d3/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linea attraversamento in X + pEnd = Point3d( -((L3/2)-(d3*3/4)), pIni:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- risalgo in Y fuori dalla svuotatura + pEnd = Point3d( pIni:getX(), dLocPosY+(d3*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + end + end + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + nRadius = dDimMin2/2 + nDirVers = -nDirVers + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep and nCase > 1 then + + pIni = pEnd + if not stn or ( stn and invG > 0) then -- se il pivot non sborda + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + else -- se il pivot sborda faccio geometria opposta o ruotata in base al sottotipo + if subtype == 2 or subtype == 3 then -- inserimento opposto + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + else -- inserimento sul fianco + pEnd = Point3d(pStartStep:getX(),pIni:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d3/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar, {nTotContEnt,sKindVar}) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end -- end while + end + + + ------------------------------------- + -- se è presente la geometria body + ------------------------------------- + + if d and hint2 then + + local dDimMin + local dDimMin2 + local nDirVers = 1 + local nConEnt + local sKindVar + local dLocXStart, dLocYStart, dLocZStart, dLocXAmp, dLocYAmp + + if subtype == 2 or subtype == 3 then + + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + dLocZStart = H3 + + if subtype == 2 then + dLocXAmp = L + dLocYAmp = H + else + dLocXAmp = H + dLocYAmp = L + end + + -- individuo in che caso sono + if dLocXAmp > dLocYAmp then + local dLenComp = EgtIf( stx, dLocXAmp+(d/2)+dExtraH,dLocXAmp) + dDimMin = max( dLocYAmp, dLenComp) + dDimMin2 = min( dLocYAmp, dLenComp) + dDimMin2 = dDimMin2 * 2 + else -- se larghezza più stretta dell'altezza + local dLenComp = EgtIf( stx, dLocXAmp+(d/2)+dExtraH,dLocXAmp) + dDimMin2 = min( dLocYAmp, dLenComp) + dDimMin = dDimMin2 + + if abs( dDimMin2 - dLocYAmp) < GEO.EPS_SMALL then -- se il minimo è sull'altezza + + if dLenComp/dDimMin2 >= 2 then -- se lunghezza è più del doppio dell'altezza + dDimMin2 = dDimMin2 * 2 + end + end + end + else + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + dLocZStart = L3/2 + + -- individuo in che caso sono + dLocXAmp = L + dLocYAmp = H + dDimMin = min( L, EgtIf( stx, H+(d/2)+dExtraH,H)) + dDimMin2 = dDimMin + end + + if abs(dDimMin-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (dDimMin-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((dDimMin-d) > ( d*0.98)) and ( (dDimMin-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (dDimMin-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi offset + nCase = 4 + end + + -- resetto contatori entità + nTotContEnt = 0 + nTotContEnt_r = 0 + nRadius = dDimMin2/2 + nPass = 1 + dZedStart = dLocZStart + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then +-- if nStep == 1 then +-- dZedWork = dZedStart +-- else + dZedWork = dLocZStart-T +-- end + end + + if nCase == 1 then -- solo 1 passaggio in centro + + if nDirVers == 1 then -- se passata di andata + + if subtype == 2 then + + if bStartOppo then + + if invG > 0 then + + pIni = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + pStartStep = pIni + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pEnd = Point3d(((L3-d)/2),-H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + if stx then + pIni = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pIni = Point3d(((L3-d)/2),(d*3/4),dZedWork) + end + pStartStep = pIni + if stx then + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + else + pEnd = Point3d(((L3-d)/2),-H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + else + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + else -- codice vetusto: da verificare + + if invG > 0 then + + if stx then + pIni = Point3d(((L3/2)+(d*3/4)),-H+(d/2), dZedWork) + else + pIni = Point3d(((L3-d)/2),(d*3/4), dZedWork) + end + pStartStep = pIni + if stx then + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + else + pEnd = Point3d(((L3-d)/2), -H+(d/2), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + else + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + pIni = Point3d((((L3+d)/2) - L), (d*3/4), dZedWork) + pStartStep = pIni + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pEnd = Point3d(((L3-d)/2),-H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + elseif subtype == 3 then + + pIni = Point3d( EgtIf( stx, -((d/2)+dExtraH)*invG, 0), (d*3/4), dZedWork) + pStartStep = pIni + pEnd = Point3d( EgtIf( stx, -((d/2)+dExtraH)*invG, 0), -L+(d/2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + elseif subtype == 4 then + + pIni = Point3d( EgtIf( stx, ((d/2)+dExtraH), 0)*invG, (d*3/4), dZedWork) + pStartStep = pIni + pEnd = Point3d( EgtIf( stx, ((d/2)+dExtraH), 0)*invG, -(L-(d/2)), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + else -- altrimenti passata di ritorno + + if subtype == 2 then + + if bStartOppo then + + if invG > 0 then + + if stx then + pIni = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pIni = Point3d(((L3-d)/2), -H+(d/2), dZedWork) + end + pEnd = Point3d((((L3+d)/2) - L),-H+(d/2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + if stx then + pIni = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + else + pIni = Point3d((((L3+d)/2) - L), -H+(d/2),dZedWork) + pEnd = Point3d(((L3-d)/2),-H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pEnd = Point3d(((L3-d)/2),(d*3/4),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + else -- codice vetusto, da verificare + + if invG > 0 then + + if stx then + pIni = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + pEnd = Point3d((((L3+d)/2) - L), -H+(d/2), dZedWork) + else + pIni = Point3d((((L3+d)/2) - L), -H+(d/2),dZedWork) + pEnd = Point3d(((L3-d)/2),-H+(d/2),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pEnd = Point3d(((L3-d)/2),(d*3/4),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + else + + if stx then + pIni = Point3d(((L3/2)+(d*3/4)),-H+(d/2),dZedWork) + else + pIni = Point3d(((L3-d)/2), -H+(d/2), dZedWork) + end + pEnd = Point3d((((L3+d)/2) - L),-H+(d/2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d((((L3+d)/2) - L), (d*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + elseif subtype == 3 then + + pIni = Point3d( EgtIf( stx, -((d/2)+dExtraH)*invG, 0), -L+(d/2), dZedWork) + pEnd = Point3d( EgtIf( stx, -((d/2)+dExtraH)*invG, 0), (d*3/4), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + elseif subtype == 4 then + + pIni = Point3d( EgtIf( stx, ((d/2)+dExtraH), 0)*invG, -(L-(d/2)), dZedWork) + pEnd = Point3d( EgtIf( stx, ((d/2)+dExtraH), 0)*invG, (d*3/4), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d( pIni:getX(), pIni:getY(), (dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, nil, 'grid') + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + -- calcolo l'ampiezza dell'offset + nRadius = nRadius - (d/2) + + -- offset + hint_ofs = EgtOffsetCurveAdv( hint2, (d/2), GDB_OT.FILLET) + + if hint_ofs and hint_ofs > 0 then + + if mkrev then -- se abilitato anche il percorso inverso + -- copia del percorso offsettato + hint_ofs_r = EgtCopyGlob( hint_ofs, Lg) + end + + -- muovo la geometria in Z + EgtMove( hint_ofs, Point3d(0,0, dZedWork-dLocZStart) - ORIG(), GDB_RT.GRID) + + -- se flag inverso, inverto la geometria, solo qui non nelle altre copie + if invG < 0 then + EgtInvertCurve(hint_ofs) + end + + if bStartOppo then + if subtype == 2 then + if invG > 0 then + if B_SK and stx then -- se knuckle è opposto e sborda faccio geometria ruotata + + pIni = Point3d( ((L3/2) - L - (d*3/4)), -(H-(d/2)-0.2),dZedWork) + pStartStep = pIni + pEnd = Point3d(((L3/2) - L - dExtraH), -(H-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(((L3/2) - L - dExtraH), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + if stx then + pEnd = Point3d( (((L3+d)/2) - L), dExtraH,dZedWork) + else + pEnd = Point3d( (((L3-d)/2) - L), dExtraH,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + else -- altrimenti diritta + + pIni = Point3d((((L3+d)/2) - L + 0.2), (d*3/4),dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d((((L3+d)/2) - L + 0.2), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + if stx then + pEnd = Point3d(((L3/2)+dExtraH),dExtraH,dZedWork) + else + pEnd = Point3d(((L3-d)/2), dExtraH,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else + if stx and not B_SK then -- se il pivot sborda e il knukle non è opposto, faccio geometria ruotata + pIni = Point3d(((L3/2)+(d*3/4)), -(H-(d/2)-0.2),dZedWork) + pStartStep = pIni + pEnd = Point3d(((L3/2) + dExtraH), -(H-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(((L3/2) + dExtraH), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((L3-d)/2), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + else -- altrimenti geometria dritta + pIni = Point3d(((L3-d)/2),(d*3/4),dZedWork) + pStartStep = pIni + pEnd = Point3d(((L3-d)/2), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + end + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + elseif subtype == 3 then + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + + pIni = Point3d(-(((H-d)/2) - 0.2)*invG, (d*3/4),dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d(-(((H-d)/2) - 0.2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(((H-d)/2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- se il pivot sborda faccio geometria ruotata + + pIni = Point3d(-((H/2)+(d*3/4))*invG, -(L-(d/2)-0.2),dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(-((H/2)+dExtraH)*invG, -(L-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(-((H/2)+dExtraH)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((H-d)/2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + elseif subtype == 4 then + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + + pIni = Point3d(-(((H-d)/2)-0.2)*invG, (d*3/4),dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d(-(((H-d)/2)-0.2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(((H-d)/2)*invG,dExtraH, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else -- se il pivot sborda faccio geometria ruotata + + pIni = Point3d(-((H/2)+(d*3/4))*invG,-(L-(d/2)-0.2), dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(-((H/2)+dExtraH)*invG,-(L-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d( -((H/2)+dExtraH)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((H-d)/2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket2, hint_ofs) + else -- se attacco al vecchio punto, codice vetusto: da verificare + if subtype == 2 then + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + + -- prima linea entrante + pIni = Point3d(((L3-d)/2)*invG, (d*3/4),dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else + + pIni = Point3d(((L3/2) - L - (d*3/4))*invG, -(H-(d/2)-0.2),dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(((L3/2) - L - dExtraH)*invG, -(H-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(((L3/2) - L - dExtraH)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((L3-d)/2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + elseif subtype == 3 then + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + + -- prima linea entrante + pIni = Point3d(((H-d)/2)*invG, (d*3/4),dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else + + pIni = Point3d(-((H/2)+(d*3/4))*invG, -(L-(d/2)-0.2),dZedWork) + pStartStep = pIni + -- linea in X con centro utensile fuori + pEnd = Point3d(-((H/2)+dExtraH)*invG, -(L-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pEnd = Point3d(-((H/2)+dExtraH)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(((H-d)/2)*invG, dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + elseif subtype == 4 then + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + + pIni = Point3d(-(d*3/4), ((H-d)/2)*invG,dZedWork) + pStartStep = pIni + -- prima linea entrante + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + else + + pIni = Point3d( L-(d/2)-0.2, -((H/2)+(d*3/4))*invG,dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d( L-(d/2)-0.2,-((H/2)+dExtraH)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linee traverse in X e poi Y per andare sul vecchio punto iniziale (in Y) + pEnd = Point3d( -dExtraH,-((H/2)+dExtraH)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + pEnd = Point3d(-dExtraH,((H-d)/2)*invG,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pIni = pEnd + -- linea entrante a prendere il percorso di offset + pEnd = EgtSP( hint_ofs, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs, GDB_RT.GRID) + end + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket2, hint_ofs) + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + if subtype == 2 then + + local nMakeExtraPass = 0 + local dRemX = L + local dRemY = H + if stx then + dRemX = dRemX + (d/2) + end + + -- calcolo in quale direzione ha collassato + if dRemX > dRemY then -- se larghezza risultante maggiore + nMakeExtraPass = 2 -- passata orizzontale + else -- altezza risultante maggiore della larghezza + nMakeExtraPass = 1 -- passata verticale + end + + if nMakeExtraPass == 1 then -- se passata verticale + + -- linea posizionamento passata centrale + pIni = pEnd + if B_SK then + pEnd = Point3d( EgtIf( stx, -((L - (L3 - (d/2) - dExtraH))/2), -((L-L3)/2)), dExtraH, dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((L3 - (L - (d/2) - dExtraH))/2), ((L3-L)/2)), dExtraH, dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + if B_SK then + pEnd = Point3d( EgtIf( stx, -((L - (L3 - (d/2) - dExtraH))/2), -((L-L3)/2)), -(H-(d/2)-dExtraH), dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((L3 - (L - (d/2) - dExtraH))/2), ((L3-L)/2)), -(H-(d/2)-dExtraH), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della svuotatura + if nPass < nStep then + if B_SK then + pEnd = Point3d( EgtIf( stx, -((L - (L3 - (d/2) - dExtraH))/2), -((L-L3)/2)), (d*3/4), dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((L3 - (L - (d/2) - dExtraH))/2), ((L3-L)/2)), (d*3/4), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + elseif nMakeExtraPass == 2 then -- se passata orizzontale + + -- linea posizionamento passata centrale + pIni = pEnd + if B_SK then + pEnd = Point3d( EgtIf( stx, -((L3+(d/2)+dExtraH)/2), -(L3-d)/2), dExtraH, dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((L3+(d/2)+dExtraH)/2), (L3-d)/2), dExtraH, dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + if B_SK then + pEnd = Point3d( EgtIf( stx, -((L3+(d/2)+dExtraH)/2), -(L3-d)/2), -(H/2), dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((L3+(d/2)+dExtraH)/2), (L3-d)/2), -(H/2), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + if B_SK then + pEnd = Point3d( -((L3/2)-L+(d/2)), -(H/2), dZedWork) + else + pEnd = Point3d( (L3/2)-L+(d/2), -(H/2), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della svuotatura + if nPass < nStep then + if B_SK then + pEnd = Point3d( -((L3/2)-L+(d/2)), (d*3/4), dZedWork) + else + pEnd = Point3d( (L3/2)-L+(d/2), (d*3/4), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + elseif subtype == 3 then + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), -(L-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + elseif subtype == 4 then + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), -(L-(d/2)-0.2), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), dExtraH, dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + local nDistYcentr = (d*p) + local nDistYcentrRad + local bContinue + + if subtype == 2 or subtype == 3 then + nDistYcentrRad = nDistYcentr + else + if L > H then -- la lunghezza L è sulla X e la H sulla Y + nDistYcentrRad = nDistYcentr + else + nDistYcentrRad = nDistYcentr/2 + end + end + + -- se percorso offset esiste + if hint_ofs and hint_ofs > 0 then + + -- faccio l'offset del raggio fresa + nRadius = nRadius - nDistYcentrRad + bContinue = nRadius > 0 + nCountOfs = 0 + local nInvOffs = 1 + local bFailOfs = false + local dCompareX = dLocXAmp + local dCompareY = dLocYAmp + local dRemX, dRemY + + if stx then + dCompareX = dLocXAmp+(d/2)+dExtraH + end + + -- se percorso offset esiste + while bContinue do + + hint_ofs2 = EgtOffsetCurveAdv( hint_ofs, nDistYcentr*invG*nInvOffs, GDB_OT.FILLET) + + if hint_ofs2 and hint_ofs2 > 0 then + + nCountOfs = nCountOfs + 1 + + -- linea congiunzione tra offset + pIni = pEnd + -- inverto il percorso + EgtInvertCurve(hint_ofs2) + pEnd = EgtSP( hint_ofs2, GDB_RT.GRID) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pEnd = EgtEP( hint_ofs2, GDB_RT.GRID) + hint_ofs = hint_ofs2 + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket2, hint_ofs) + + if mkrev then -- se abilitato anche il percorso inverso + + end + + -- calcolo nuovo passo in Y e indice direzione + nRadius = nRadius - nDistYcentrRad + if nRadius > 0 then + dRemX, dRemY = CkeckRadiusRemain( dCompareX, dCompareY, d, nDistYcentrRad, (nCountOfs+1)) + if (dRemX and dRemX > (d/4)) or ( dRemY and dRemY > d) then + bContinue = true + else + bContinue = false + end + else + bContinue = false + end + nInvOffs = -nInvOffs + else + bContinue = false + bFailOfs = true + end + end -- end while + + if subtype == 2 or subtype == 3 then + + if p > 0.75 then -- se la percentuale di sovrapposizione è alta + + local nMakeExtraPass = 0 + -- ricalcolo le rimanenze + dRemX, dRemY = CkeckRadiusRemain( dCompareX, dCompareY, d, nDistYcentrRad, nCountOfs) + + -- calcolo in quale direzione ha collassato + if dRemX > dRemY then -- se larghezza risultante maggiore + if dRemY > d then -- se la passata precedente è maggiore del diametro utensile + nMakeExtraPass = 2 -- passata orizzontale + end + else -- altezza risultante maggiore della larghezza + if dRemX > (d/2.03) then -- se la passata precedente è maggiore del raggio utensile + nMakeExtraPass = 1 -- passata verticale + end + end + + if nMakeExtraPass == 1 then -- se passata verticale + + -- linea posizionamento passata centrale + pIni = pEnd + if subtype == 2 then + if B_SK then + pEnd = Point3d( EgtIf( stx, (((L3-dLocXAmp)-((d/2)+dExtraH))/2), ((L3-dLocXAmp)/2)), dExtraH,dZedWork) + else + pEnd = Point3d( EgtIf( stx, (((L3-dLocXAmp)+((d/2)+dExtraH))/2), ((L3-dLocXAmp)/2)), dExtraH,dZedWork) + end + else + pEnd = Point3d( EgtIf( stx, (((d/2)+dExtraH)/2), 0), dExtraH,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- linee passata centrale + pEnd = Point3d( pIni:getX(), -(dLocYAmp-(d/2)-0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd = Point3d( pIni:getX(), dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + elseif nMakeExtraPass == 2 then -- se passata orizzontale + + -- linea posizionamento passata orizzontale + pIni = pEnd + if subtype == 2 then + pEnd = Point3d( EgtIf( stx, ((L3+(d/2)+dExtraH)/2), (L3/2)-(d*3/4)), dExtraH,dZedWork) + else + pEnd = Point3d( EgtIf( stx, ((dLocXAmp+(d/2)+dExtraH)/2), (dLocXAmp/2)-(d*3/4)), dExtraH,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + pEnd = Point3d( pIni:getX(), -(d/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + if subtype == 2 then + pEnd = Point3d( ((L3/2)-L+(d*3/4)), pIni:getY(),dZedWork) + else + pEnd = Point3d( -((dLocXAmp/2)-(d*3/4)), pIni:getY(),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + -- risalgo in Y fuori dalla svuotatura + pEnd = Point3d( pIni:getX(), (d*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, nil, 'grid') + pIni = pEnd + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end + elseif subtype == 4 then + end + end + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + nRadius = dDimMin2/2 + nDirVers = -nDirVers + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep and nCase > 1 then + + pIni = pEnd + if not stx or ( stx and invG > 0) then -- se il pivot non sborda + if B_SK and stx then -- se il knuckle è opposto faccio come se sborda (attacco ruotato) + pEnd = Point3d(pStartStep:getX(),pIni:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + else -- altrimenti non sborda (attacco normale) + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + end + else -- se il pivot sborda faccio geometria ruotata + if B_SK then -- se il knuckle è opposto faccio come se non sborda (attacco normale) + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + else -- altrimenti sborda (attacco ruotato) + pEnd = Point3d(pStartStep:getX(),pIni:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket2, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, nil, 'grid') + table.insert( tMVar2, {nTotContEnt,sKindVar}) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + end + end + end -- end while + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + + -- 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) + end + end + + if ( #tPocket2 > 0) then + hintPk2 = EgtCurveCompo( Lg, tPocket2, true) + if hintPk2 then + EgtModifyCurveThickness(hintPk2, 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( hintPk2, 'MVar', sListEnt) end + EgtSetName(hintPk2,LMV) + end + end + + if ( #tPocket_r > 0) then + hintPk_r = EgtCurveCompo( Lg, tPocket_r, true) + if hintPk_r then + EgtModifyCurveThickness(hintPk_r, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPk_r, 'MVar', sListEnt) end + EgtSetName(hintPk_r,(LM..'_R')) + end + end + + if ( #tPocket2_r > 0) then + hintPk2_r = EgtCurveCompo( Lg, tPocket2_r, true) + if hintPk2_r then + EgtModifyCurveThickness(hintPk2_r, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar2_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar2_r[i][1], 0) .. ', ' .. 'code=' .. tMVar2_r[i][2] .. '}' + if i < #tMVar2_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPk2_r, 'MVar', sListEnt) end + EgtSetName(hintPk2_r,(LMV..'_R')) + end + end + + -- se variabile inversione negativa inverto la direzione del percorso geometrico principale + if invG < 0 then + if hint then + EgtInvertCurve(hint) + end + if hint2 then + EgtInvertCurve(hint2) + end + end + end + + -- se c'è lo spostamento opposto del percorso body + if D_SK > 0 then + if hint2 then + EgtMove( hint2, Point3d(D_SK,0,0) - ORIG()) + end + if hintPk2 then + EgtMove( hintPk2, Point3d(D_SK,0,0) - ORIG()) + end + if hintAs1b then + EgtMove( hintAs1b, Point3d(D_SK,0,0) - ORIG()) + end + if hintAs2b then + EgtMove( hintAs2b, Point3d(D_SK,0,0) - ORIG()) + end + if hintPk2_r then + EgtMove( hintPk2_r, Point3d(D_SK,0,0) - ORIG()) + end + if hintAs3b then + EgtMove( hintAs3b, Point3d(D_SK,0,0) - ORIG()) + end +-- DEBUG +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + if hintAs4b then + EgtMove( hintAs4b, Point3d(D_SK,0,0) - ORIG()) + 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 + + if hint2 then + -- cancello il percorso + EgtErase( hint2) + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + -- geometrie knuckle + if hint then + EgtSetColor(hint,AQUA()) + end + if hintPk then + EgtSetColor(hintPk,AQUA()) + end + if hintAs1 then + EgtSetColor(hintAs1,AQUA()) + end + if hintAs2 then + EgtSetColor(hintAs2,AQUA()) + end + if hintPk_r then + EgtSetColor(hintPk_r,AQUA()) + end + if hintAs3 then + EgtSetColor(hintAs3,AQUA()) + end + if hintAs4 then + EgtSetColor(hintAs4,AQUA()) + end + -- geometrie body + if hint2 then + EgtSetColor(hint2,AQUA()) + end + if hintPk2 then + EgtSetColor(hintPk2,AQUA()) + end + if hintAs1b then + EgtSetColor(hintAs1b,AQUA()) + end + if hintAs2b then + EgtSetColor(hintAs2b,AQUA()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,AQUA()) + end + if hintAs3b then + EgtSetColor(hintAs3b,AQUA()) + end + if hintAs4b then + EgtSetColor(hintAs4b,AQUA()) + end + else + -- geometrie knuckle + if hint then + EgtSetColor(hint,ORANGE()) + end + if hintPk then + EgtSetColor(hintPk,ORANGE()) + end + if hintAs1 then + EgtSetColor(hintAs1,ORANGE()) + end + if hintAs2 then + EgtSetColor(hintAs2,ORANGE()) + end + if hintPk_r then + EgtSetColor(hintPk_r,ORANGE()) + end + if hintAs3 then + EgtSetColor(hintAs3,ORANGE()) + end + if hintAs4 then + EgtSetColor(hintAs4,ORANGE()) + end + -- geometrie body + if hint2 then + EgtSetColor(hint2,ORANGE()) + end + if hintPk2 then + EgtSetColor(hintPk2,ORANGE()) + end + if hintAs1b then + EgtSetColor(hintAs1b,ORANGE()) + end + if hintAs2b then + EgtSetColor(hintAs2b,ORANGE()) + end + if hintPk2_r then + EgtSetColor(hintPk2_r,ORANGE()) + end + if hintAs3b then + EgtSetColor(hintAs3b,ORANGE()) + end + if hintAs4b then + EgtSetColor(hintAs4b,ORANGE()) + end + end + else -- altrimenti non Preview + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + -- assegno nota su percorsi antisplint e svuotatura + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + if hintAs1 then + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + end + if hintAs2 then + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + end + if hintPk_r then + EgtSetInfo( hintPk_r, 'NotCheckDir', '1') + end + if hintAs3 then + EgtSetInfo( hintAs3, 'NotCheckDir', '1') + end + if hintAs4 then + EgtSetInfo( hintAs4, 'NotCheckDir', '1') + end + if hintPk2 then + EgtSetInfo( hintPk2, 'NotCheckDir', '1') + end + if hintAs1b then + EgtSetInfo( hintAs1b, 'NotCheckDir', '1') + end + if hintAs2b then + EgtSetInfo( hintAs2b, 'NotCheckDir', '1') + end + if hintPk2_r then + EgtSetInfo( hintPk2_r, 'NotCheckDir', '1') + end + if hintAs3b then + EgtSetInfo( hintAs3b, 'NotCheckDir', '1') + end + if hintAs4b then + EgtSetInfo( hintAs4b, 'NotCheckDir', '1') + end + end + + return hint, hintPk, hintAs1, hintAs2, hintPk_r, hintAs3, hintAs4, + hint2, hintPk2, hintAs1b, hintAs2b, hintPk2_r, hintAs3b, hintAs4b +end + + +return OPivot diff --git a/LuaLibs/_OverHeadArm.lua b/LuaLibs/_OverHeadArm.lua new file mode 100644 index 0000000..d63d76e --- /dev/null +++ b/LuaLibs/_OverHeadArm.lua @@ -0,0 +1,1458 @@ +-- +-- 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 +-- +-- _OverHeadArm.lua by EgalWare s.r.l. 2016.06.29 +-- Autore: Filippo Monchi +-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi + +-- 2016.09.21 V1.0a1 FM Add warning messages +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.12.10 V1.0a3 FM Add geometry for calculate box without Arm volume (when strike) +-- 2019.10.16 V1.0a4 FM Manage steel option +-- 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.12.17 V2.002 FM Fix error on draw exit line in particular case (arm height allow only single passage) +-- 2020.05.25 V2.003 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 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 and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local _OverHeadArm = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +-- Valori limite +local dExtraH = 0.5 +local dExtraL = 1.0 +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 _OverHeadArm.Draw( EC, EM, tOHArm, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tOHArm.L + local H = tOHArm.H + local T = tOHArm.T + local R = tOHArm.rf + local d = tOHArm.d + local p = tOHArm.p + local s = tOHArm.sf + local d2 = tOHArm.d2 + local DS = tOHArm.DS + local OS = tOHArm.OS + local est = tOHArm.est + local bEqualTh = tOHArm.bETh + local smr = tOHArm.smr + local kbs = tOHArm.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tOHArm.pbs + local fhb = tOHArm.fhb + local drf = tOHArm.drf + local dws = tOHArm.Dws + -- Assegno i nomi geometrie + local LG = tOHArm.LG + local LM = tOHArm.LM + local LA = tOHArm.LA + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHArm.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = true + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not s or abs(s) <= GEO.EPS_SMALL then + s = T + end + + -- radius face: per compatibilità con tutti i componenti, se non è definito lo setto a 0 + if not R or abs(R) <= GEO.EPS_SMALL then + R = 0 + end + + if not smr then + smr = 0 + end + + local Dm, Dor + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName( Lg, sCompoName) + end + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName( Dm, DM) + Dor = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte l'origine + EgtSetName( Dor, DM) + end + + local hint1, hint2, hint, hintPk, hintAs, hintAs2 + local pIni, pEnd, pCen + local pIni2, pEnd2, pCentr2 + local nIdSideBoxUp + + -- disegno cerchio origine + if Dor then + local nCircleOri = EgtCircle( Dor, Point3d(0,0,0), d/4 , GDB_RT.LOC) + EgtSetColor( nCircleOri, NAVY()) + end + + if nDrawMach ~= 1 then -- se abilitata geometria esterna + + local tHint = {} + + -- Costruzione della geometria ( in senso orario) + if bEqualTh then -- se cava alta come lo spessore porta disegno un contorno chiuso + + if est then + pIni = Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0) + if OS > 0 then -- se cava aperta a destra + pEnd = Point3d(((L/2)+(d/2)+dExtraH),((d/2)+dExtraH),0) + else + pEnd = Point3d(L/2,((d/2)+dExtraH),0) + end + else + pIni = Point3d(0,0,0) + pEnd = Point3d(L/2,0,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if est then + if OS > 0 then -- se cava aperta a destra + pEnd = Point3d(((L/2)+(d/2)+dExtraH),-(H+(d/2)+dExtraH),0) + else + pEnd = Point3d(L/2,-(H+(d/2)+dExtraH),0) + end + else + pEnd = Point3d(L/2,-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if est then + if OS < 0 then -- se cava aperta a sinistra + pEnd = Point3d(-((L/2)+(d/2)+dExtraH),-(H+(d/2)+dExtraH),0) + else + pEnd = Point3d(-(L/2),-(H+(d/2)+dExtraH),0) + end + else + pEnd = Point3d(-(L/2),-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if est then + if OS < 0 then -- se cava aperta a sinistra + pEnd = Point3d(-((L/2)+(d/2)+dExtraH),((d/2)+dExtraH),0) + else + pEnd = Point3d(-L/2,((d/2)+dExtraH),0) + end + else + pEnd = Point3d(-L/2,0,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if est then + pEnd = Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0) + else + pEnd = Point3d(0,0,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else -- altrimenti contorno aperto + + if est then -- se altro materiale faccio percorso chiuso + pIni = Point3d(-((L/2)-(d/2)-dExtraH),((d/2)+dExtraH),0) + if OS > 0 then -- se cava aperta a destra + pEnd = Point3d(((L/2)+(d/2)+dExtraH),((d/2)+dExtraH),0) + else + pEnd = Point3d(L/2,((d/2)+dExtraH),0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(L/2,0,0) + end + + if R > 0 and OS <= 0 then -- se raggio esiste e cava non aperta a destra + pEnd = Point3d(L/2,(-H+R),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, 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, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else -- nessun raccordo o cava aperta a destra + if OS > 0 and smr ~= 0 then -- se cava aperta a destra e chisel abilitato + pEnd = Point3d(L/2,-H+0.5,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pCen = Point3d((L/2)-0.5,-H+0.5,0) + pEnd = Point3d((L/2)-0.5,-H,0) + DrawAddCircleDrawCircle( pCen, 0.5, 0,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + elseif OS > 0 then -- se cava aperta a destra + if est then -- se altro materiale faccio percorso chiuso + pEnd = Point3d(((L/2)+(d/2)+dExtraH),-H,0) + else + pEnd = Point3d(L/2,-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + else + pEnd = Point3d(L/2,-H,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if R > 0 and OS >= 0 then -- se raggio esiste e cava non aperta a sinistra + pEnd = Point3d((-(L/2)+R),-H,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, 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, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else -- nessun raccordo o cava aperta a sinistra + if OS < 0 and smr ~= 0 then -- se cava aperta a sinistra e chisel abilitato + pEnd = Point3d(-(L/2)+0.5,-H,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pCen = Point3d(-(L/2)+0.5,-H+0.5,0) + pEnd = Point3d(-(L/2),-H+0.5,0) + DrawAddCircleDrawCircle( pCen, 0.5, -90,-90, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + elseif OS < 0 then -- se cava aperta a sinistra + if est then -- se altro materiale faccio percorso chiuso + pEnd = Point3d(-((L/2)+(d/2)+dExtraH),-H,0) + else + pEnd = Point3d(-(L/2),-H,0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + else + pEnd = Point3d(-(L/2),-H,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if est then -- se altro materiale faccio percorso chiuso + if OS < 0 then -- se cava aperta a sinistra + pEnd = Point3d(-((L/2)+(d/2)+dExtraH),((d/2)+dExtraH),0) + else + pEnd = Point3d(-L/2,((d/2)+dExtraH),0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tHint, 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, tHint, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + hint = EgtCurveCompo( Lg, tHint, true) + if hint then + EgtModifyCurveThickness( hint, -T) + EgtSetName( hint, LG) + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( hint, Point3d(-((L/2)+DS),0,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))) + if est then + EgtSetInfo( hint, 'StartFromExt', 1) + end + -- se mantiene lato anche su face + 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 + end + + -- Costruzione della geometria di lavorazione + if nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + local dZedStart + local dZedWork + local nStep + local dStep + local nPass + + -- geometria antischeggia + if d2 then -- se parametro valido + + local tPocketAs = {} + local tPocketAs2 = {} + + if s >= T then -- se passo unico + + local dPosY, dEndPosY, dEndPosX, dIniPosY, dDeltaPosX + local dPosY2, dEndPosY2, dEndPosX2, dIniPosY2 + + if bStartAng then -- se lead-in con angolo + + if OS >= 0 then -- se aperto a destra + + 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()) + + -- Se spessore passante e non aperta a destra + if bEqualTh and OS == 0 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 -- se aperto a sinistra + + if L >= (d2*3/4) then + dEndPosX = -((L/2)-(d2/4)) + else + dEndPosX = -((L/2)-dExtra) + end + + dEndPosY = -H+(d2/2) + dIniPosY = (d2*3/4) + dPosY = dIniPosY - (d2*7/8) + dDeltaPosX = ( (d2*7/8) / tan(30)) + + -- linea entrante inclinata + pIni = Point3d(dEndPosX + dDeltaPosX, dIniPosY,0) + pEnd = Point3d(dEndPosX, dPosY,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in Y fino a tangenza percorso + pIni = pEnd + pEnd = Point3d( dEndPosX, dEndPosY,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d( -((L/2)+(d2*3/4)), dEndPosY,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- Se spessore passante + 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 + end + else -- lead-in diritto + + if OS >= 0 then + + 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()) + + -- Se spessore passante e non aperta a destra + if bEqualTh and OS == 0 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 + else -- se aperto a sinistra + + pIni = Point3d(-((L/2)+dExtraL),(d2*3/4),0) -- parto in X un po' fuori dalla geometria + pEnd = Point3d(-((L/2)+dExtraL),-H+(d2/2),0) -- scendo fino a fine cava perchè è aperto questo lato + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni = pEnd + if L >= (d2*3/4) then + dEndPosX = -((L/2)-(d2/4)) + else + dEndPosX = -((L/2)-dExtra) + end + + if H >= (d2*3/4) then + if (H-R) > (d2/4) then + dEndPosY2 = -H+(d2/4) + else + dEndPosY2 = -R + end + else + if (H-R) > 0 then + dEndPosY2 = -R + else + dEndPosY2 = -(d2/2) + end + end + + dIniPosY2 = -H-(d2*3/4) + + pEnd = Point3d( dEndPosX, -H+(d2/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- Se spessore passante + 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 + end + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs then + EgtModifyCurveThickness( hintAs, -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, dEndPosX, dIniPosY, dDeltaPosX + local dPosY2, dEndPosY2, dEndPosX2, dIniPosY2 + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if bStartAng then -- se lead-in con angolo + + if OS >= 0 then -- se aperto a destra + + 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) + + -- se spessore passante e non aperto a destra + if bEqualTh and OS == 0 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 -- se aperto a sinistra + + if L >= (d2*3/4) then + dEndPosX = -((L/2)-(d2/4)) + else + dEndPosX = -((L/2)-dExtra) + end + + if H >= (d2*3/4) then + if (H-R) > (d2/4) then + dEndPosY2 = -H+(d2/4) + else + dEndPosY2 = -R + end + else + if (H-R) > 0 then + dEndPosY2 = -R + else + dEndPosY2 = -(d2/2) + end + end + + dEndPosY = -H+(d2/2) + dIniPosY = (d2*3/4) + dPosY = dIniPosY - (d2*7/8) + dPosY2 = dEndPosY2 - (d2/8) + dIniPosY2 = dPosY2 - (d2*7/8) + dDeltaPosX = ( (d2*7/8) / tan(30)) + + -- linea entrante inclinata + pIni = Point3d( dEndPosX + dDeltaPosX, dIniPosY,dZedWork) + pEnd = Point3d( dEndPosX, dPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in Y fino a tangenza percorso + pIni = pEnd + pEnd = Point3d( dEndPosX, dEndPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d( -((L/2)+(d2*3/4)),dEndPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di risalita in Y + pIni = pEnd + pEnd = Point3d( pIni:getX(), (d2*3/4), dZedWork) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar, {nConEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(dEndPosX + dDeltaPosX,pIni:getY(), dZedWork) + + -- se spessore passante + 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 + end + else -- lead-in diritto + + if OS >= 0 then + + 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) + + -- se spessore passante e non aperto a destra + if bEqualTh and OS == 0 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 + else -- se aperto a sinistra + + pIni = Point3d(-((L/2)+dExtraL),(d2*3/4),dZedWork) -- parto in X un po' fuori dalla geometria + pEnd = Point3d(-((L/2)+dExtraL),-H+(d2/2)+0.2,dZedWork) -- scendo fino a fine cava perchè è aperto questo lato + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni = pEnd + if L >= (d2*3/4) then + dEndPosX = -((L/2)-(d2/4)) + else + dEndPosX = -((L/2)-dExtra) + end + + if H >= (d2*3/4) then + if (H-R) > (d2/4) then + dEndPosY2 = -H+(d2/4) + else + dEndPosY2 = -R + end + else + if (H-R) > 0 then + dEndPosY2 = -R + else + dEndPosY2 = -(d2/2) + end + end + + dIniPosY2 = -H-(d2*3/4) + + pEnd = Point3d( dEndPosX, -H+(d2/2)+0.2,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( dEndPosX, -H+(d2/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(-((L/2)+dExtraL), pIni:getY(), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d( pIni:getX(),(d2*3/4), dZedWork) + + -- se spessore passante + 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 + 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 #tPocketAs2 > 0 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 + hintAs = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs then + EgtModifyCurveThickness( hintAs, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar[i][1], 0) .. ', ' .. 'code=' .. tMVar[i][2] .. '}' + if i < #tMVar then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs, 'MVar', sListEnt) end + end + end + + if ( #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 hintAs then + EgtSetName( hintAs, LA) + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( hintAs, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintAs,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintAs,'DeltaPos' ,( L+(2*DS))) + -- se mantiene lato anche su face + 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( hintAs, 'KeepBackSet', sKeepMode) + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintAs, 'ProbeSide', '1') + end + end + if hintAs2 then + EgtSetName(hintAs2,LA) + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( hintAs2, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintAs2,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintAs2,'DeltaPos' ,( L+(2*DS))) + -- 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 + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + + if not est then -- se non c'è lavorazione steel + + local tPocket = {} + local dDeltaL + local dPosIniMach + local dPosEndMach + local tMVar = {} + local nConEnt + local sKindVar + local pStart + nPass = 1 + dZedStart = 0 + nStep = ceil(T/s) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if bStartOppo then -- inizio a sinistra + + if OS == 1 then -- se fianco destro aperto + pIni = Point3d(-((L-d)/2)+0.2,(d*3/4),dZedWork) + pStart = pIni -- memorizzo punto per ritorno e reiniziare 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/2)+dExtraL),dExtraH,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + if bEqualTh then + pEnd = Point3d(((L/2)+dExtraL),-H-dExtraH,dZedWork) + else + pEnd = Point3d(((L/2)+dExtraL),-H+(d/2),dZedWork) + end + dDeltaL = (d/2) + else -- fianco sinistro aperto + pIni = Point3d(-((L-d)/2)+0.2,(d*3/4),dZedWork) + pStart = pIni -- memorizzo punto per ritorno e reiniziare 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 + if R > (d/2) then + pEnd = Point3d(((L-d)/2),(-H+R),dZedWork) + else + if bEqualTh then + pEnd = Point3d(((L-d)/2),-H-dExtraH,dZedWork) + else + pEnd = Point3d(((L-d)/2),-H+(d/2),dZedWork) + end + end + dDeltaL = 0 + end + else -- inizio a destra + + if OS == 1 then -- se fianco destro aperto inizio al valore di dExtraL + pIni = Point3d(((L/2)+dExtraL),(d*3/4),dZedWork) + if bEqualTh then + pEnd = Point3d(((L/2)+dExtraL),-H-dExtraH,dZedWork) + else + pEnd = Point3d(((L/2)+dExtraL),-H+(d/2),dZedWork) + end + dDeltaL = (d/2) + else + pIni = Point3d(((L-d)/2),(d*3/4),dZedWork) + if R > (d/2) then + pEnd = Point3d(((L-d)/2),(-H+R),dZedWork) + else + if bEqualTh then + pEnd = Point3d(((L-d)/2),-H-dExtraH,dZedWork) + else + pEnd = Point3d(((L-d)/2),-H+(d/2),dZedWork) + end + end + dDeltaL = 0 + end + pStart = pIni -- memorizzo punto per ritorno e reiniziare nuovo step + end + + local bDrawCircle = EgtIf( bStartOppo, false, true) + + -- linea entrante in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), bDrawCircle, true, RED(), RED()) -- linea discesa in Y + pIni = pEnd + + if OS <= 0 then -- se fianco destro chiuso + if R > (d/2) then + -- raccordo 1, a destra + 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()) + pIni = pEnd + end + end + + if OS == -1 then -- se aperto a sinistra + if bEqualTh then + pEnd = Point3d(-((L/2)+dExtraL),-H-dExtraH,dZedWork) + else + pEnd = Point3d(-((L/2)+dExtraL),-H+(d/2),dZedWork) + end + else + if R > (d/2) then + pEnd = Point3d(-((L/2)-R),-H+(d/2),dZedWork) + else + if bEqualTh then + pEnd = Point3d(-((L-d)/2),-H-dExtraH,dZedWork) + else + pEnd = Point3d(-((L-d)/2),-H+(d/2),dZedWork) + end + end + end + + -- linea traversa in X + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- linea orizzontale in X + pIni = pEnd + + if ( H <= (d/2) or (( L + dDeltaL) <= (d*2))) then -- se cava troppo bassa o stretta line di uscita in alto e stop + if OS == -1 then -- se aperto a sinistra + pEnd = Point3d(-((L/2)+dExtraL),(d*3/4),dZedWork) + else + pEnd = Point3d(-((L-d)/2),(d*3/4),dZedWork) + end + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- linea di ritorno in Y + else + + if OS == -1 then -- se aperto a sinistra + pEnd = Point3d(-((L/2)+dExtraL),dExtraH,dZedWork) + else + if R > (d/2) then + -- raccordo 2, a sinistra + 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 + end + + pEnd = Point3d(-((L-d)/2),dExtraH,dZedWork) + end + + -- linea di risalita in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) -- linea di ritorno in Y + pIni = pEnd + + if bStartOppo then -- se partenza a sinistra + -- calcolo i valori di X in base al fianco sinistro se aperto o chiuso + if OS == -1 then -- se fianco sinistro aperto + dPosIniMach = -((L-d)/2) -- se fianco aperto mi avvicino a filo del bordo già lavorato + else + dPosIniMach = -(((L*2)-(d*3))/4) -- se fianco chiuso calcolo il solito punto a 3/4 del diametro + end + + -- calcolo i valori di X in base al fianco destro se aperto o chiuso + if OS == 1 then -- se fianco destro aperto + dPosEndMach = -((L-d)/2) -- se fianco aperto mi avvicino a filo del bordo già lavorato + else + dPosEndMach = -(((L*2)-(d*3))/4) + end + else + -- calcolo i valori di X in base al fianco destro se aperto o chiuso + if OS == 1 then -- se fianco destro aperto + dPosIniMach = ((L-d)/2) -- se fianco aperto mi avvicino a filo del bordo già lavorato + else + dPosIniMach = (((L*2)-(d*3))/4) -- se fianco chiuso calcolo il solito punto a 3/4 del diametro + end + + -- calcolo i valori di X in base al fianco sinistro se aperto o chiuso + if OS == -1 then -- se fianco sinistro aperto + dPosEndMach = ((L-d)/2) -- se fianco aperto mi avvicino a filo del bordo già lavorato + else + dPosEndMach = (((L*2)-(d*3))/4) + end + end + + pEnd = Point3d( dPosIniMach,dExtraH,dZedWork) + -- linea di riposizionamento in X + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) -- linea di ritorno in X + pIni = pEnd + + local nDirVers = EgtIf( bStartOppo, 1, -1) + local nDistYcentr = (d*p) + local nPosYcentr = nDistYcentr - dExtraH + local dXvalue + local nDeltaXPk = 0 + local KindSide + local bContinue + + if bEqualTh then + bContinue = nPosYcentr < H + else + bContinue = nPosYcentr < ( H -(d/2)) + end + + dXvalue = dPosIniMach + + -- 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 + + if bStartOppo and bContinue then + if OS == -1 then -- se fianco sinistro aperto + pEnd = Point3d((nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((nDirVers * (dXvalue+nDeltaXPk)),-nPosYcentr,dZedWork) + end + elseif bContinue then + if OS == 1 then -- se fianco destro aperto + pEnd = Point3d((-nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((-nDirVers * (dXvalue-nDeltaXPk)),-nPosYcentr,dZedWork) + end + end + + -- 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 + + -- scambio quota tra fianco destro e sinsistro + if dXvalue == dPosIniMach then -- se quota sul fianco destro + dXvalue = dPosEndMach -- prendo valore del fianco sinistro + KindSide = EgtIf( bStartOppo, 1, -1) -- setto come fianco in base al lato di provenienza + else + dXvalue = dPosIniMach -- prendo valore del fianco destro + KindSide = EgtIf( bStartOppo, -1, 1) -- setto come fianco in base al lato di provenienza + end + + -- scambio quota tra fianco destro e sinsistro +-- if dXvalue == dPosIniMach then -- se quota sul fianco destro +-- dXvalue = dPosEndMach -- prendo valore del fianco sinistro +-- KindSide = -1 -- setto come fianco sinistro +-- else +-- dXvalue = dPosIniMach -- prendo valore del fianco destro +-- KindSide = 1 -- setto come fianco destro +-- end + + if bStartOppo then + if OS == KindSide then -- se fianco aperto + pEnd = Point3d((-nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((-nDirVers * (dXvalue+nDeltaXPk)),-nPosYcentr,dZedWork) + end + else + if OS == KindSide then -- se fianco aperto + pEnd = Point3d((nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((nDirVers * (dXvalue-nDeltaXPk)),-nPosYcentr,dZedWork) + end + end + + -- linea passata in X + 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 + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + nDirVers = -nDirVers + -- ricalcolo punti per linea successiva + pIni = pEnd + if bStartOppo then + if OS == KindSide then -- se fianco aperto + pEnd = Point3d((nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((nDirVers * (dXvalue+nDeltaXPk)),-nPosYcentr,dZedWork) + end + else + if OS == KindSide then -- se fianco aperto + pEnd = Point3d((-nDirVers * dXvalue),-nPosYcentr,dZedWork) + else + pEnd = Point3d((-nDirVers * (dXvalue-nDeltaXPk)),-nPosYcentr,dZedWork) + end + end + 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, RED(), RED()) -- linea di ritorno in Y + end + + nPass = nPass + 1 + dZedStart = dZedWork + + -- se ho altri passi scendo in z + 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, + RED(), RED(), 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) + if s < T then -- se passi multipli + -- 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 + end + EgtSetName( hintPk, LM) + -- muovo la geometria vesro sinistra del valore di L/2 + DS + EgtMove( hintPk, Point3d(-((L/2)+DS),0,0) - ORIG()) + -- muovo la geometria vesro sinistra del valore di L/2 + DS + EgtMove( Dm, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintPk,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( Dm,'InserPoint' ,'Edge') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintPk,'DeltaPos' ,( L+(2*DS))) + EgtSetInfo( Dm,'DeltaPos' ,( L+(2*DS))) + -- se mantiene lato anche su face + 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 + end + end + end + + if not dws then -- se viene disposto sul lato narrow o è sulla porta(disposto sul lato stretto) + + -- se la sezione strike supera 1/6 dello spessore porta (se è un frame drf vale 0.1 e crea sempre regione) + -- disegno sezione ribasso su faccia superiore/inferiore porta + if fhb and drf and 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, -dThickDoor) + else + EgtModifyCurveThickness(nIdSideBoxUp, -H) + end + -- muovo la geometria verso sinistra del valore di L/2 + DS + EgtMove( nIdSideBoxUp, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + EgtSetInfo( nIdSideBoxUp, 'DeltaPos', ( L+(2*DS))) + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + else -- altrimenti viene lavorato disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint then + EgtSetColor(hint,AQUA()) + end + if hintAs then + EgtSetColor(hintAs,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 hintAs then + EgtSetColor(hintAs,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 Dor then + EgtErase(Dor) + end + -- assegno nota su percorsi antisplint e svuotatura + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + if hintAs then + EgtSetInfo( hintAs, 'NotCheckDir', '1') + end + if hintAs2 then + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + end + end + + return hint, hintPk, hintAs, hintAs2, nIdSideBoxUp +end + +return _OverHeadArm diff --git a/LuaLibs/_OverHeadPocket.lua b/LuaLibs/_OverHeadPocket.lua new file mode 100644 index 0000000..abef1b5 --- /dev/null +++ b/LuaLibs/_OverHeadPocket.lua @@ -0,0 +1,484 @@ +-- +-- EEEEEEEEEE GGGGGG wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwww wwww +-- EEEE GGGG GGGG wwww wwww wwww +-- EEEE GGGG wwww wwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww +-- EEEE GGGG GGGG wwww wwwwwwww wwww +-- EEEE GGGG GGGG wwww wwww wwww wwww +-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww +-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww +-- +-- _OverHeadPocket.lua by EgalWare s.r.l. 2016.06.30 +-- Autore: Filippo Monchi +-- Over Head Arm dati i valori 'L' e 'H' e 'T' e 'd' e 'p' e 'DS' e con nomi attributi + +-- 2016.09.21 V1.001 FM Add warning messages +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2020.05.25 V2.001 FM Manage geometries for calculate region when frame(jamb) is disposed on wide side +-- 2021.11.24 V2.002 FM Manage side probe option if variable DGC.Pms > 2 +-- 2021.11.24 V2.003 FM Manage side probe option if variable DGC.Pms > 2 +-- 2022.07.27 V2.004 FM Modification to use compiled code +-- 2024.07.19 V2.005 FM Set note 'NotCheckDir' to pocketing path + +-- Tavola per definizione modulo (serve ma non usata) +local _OverHeadPocket = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- per messaggi +-- EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua') +-- EgtAddToPackagePath( DGD.BASEDIR .. '?.lua') + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, + nGroupCirc, nRad, bDrawFirst, bDrawLast, cColor1, cColor2) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + + if idTable then + table.insert( idTable, nLine) + end + + if bPrev then + if bDrawFirst then + local nCircle1 = EgtCircle( nGroupCirc, pInitial, nRad , GDB_RT.LOC) + EgtSetColor( nCircle1, cColor1) + end + + if bDrawLast then + local nCircle2 = EgtCircle( nGroupCirc, pFinal, nRad , GDB_RT.LOC) + EgtSetColor( nCircle2, cColor2) + end + end + + return nLine +end + +-- Funzione di disegno +function _OverHeadPocket.Draw( EC, EM, tOHPkt, bPreview, bRunByCompo, nDrawMach, Pz, Lg) + + -- Assegno le dimensioni + local L = tOHPkt.L2 + local H = tOHPkt.H2 + local T = tOHPkt.T2 + local d = tOHPkt.d3 + local p = tOHPkt.p3 + local s = tOHPkt.s + local DS = tOHPkt.DS2 + local kbs = tOHPkt.kbs -- keep backset/thickness (0: none, 1: only face, 2: all) + local pbs = tOHPkt.pbs + local dws = tOHPkt.Dws + -- Assegno i nomi geometrie + local LG = tOHPkt.LGM + local LM = tOHPkt.LMM + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tOHPkt.Nome + -- RunByComponetInterface + local RC = true + -- Variabili per risalita distaccata + local nDeltaMovX = 2 + local nDeltaMovY = 2 + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not s or abs(s) <= GEO.EPS_SMALL then + s = T + end + + -- Layer + local Dm, Dor + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) -- layer della figura principale + EgtSetName( Lg, sCompoName) + end + + if nDrawMach > 0 then -- se abilitata geometria lavorazione + Dm = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName( Dm, DM) + Dor = EgtGroup( Pz, GDB_RT.LOC) -- layer disegni cerchi rappresentatte l'origine + EgtSetName( Dor, DM) + end + + local hint1, hint2, hint3, hint4, hint5, hint6, hint, hintPk + + -- disegno cerchio origine + if Dor then + local nCircleOri = EgtCircle( Dor, Point3d(0,0,0), d/4 , GDB_RT.LOC) + EgtSetColor( nCircleOri, NAVY()) + end + + if nDrawMach ~= 1 then -- se abilitata geometria esterna + + hint1 = DrawAddLineDrawCircle( Point3d(0,H/2,0), Point3d(L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint2 = DrawAddLineDrawCircle( Point3d(L/2,H/2,0), Point3d(L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint3 = DrawAddLineDrawCircle( Point3d(L/2,-(H/2),0), Point3d(-L/2,-(H/2),0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint4 = DrawAddLineDrawCircle( Point3d(-L/2,-(H/2),0), Point3d(-L/2,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint5 = DrawAddLineDrawCircle( Point3d(-L/2,H/2,0), Point3d(0,H/2,0), Lg, nil, bPreview, Dm, 0, false, false, RED(), RED()) + hint = EgtCurveCompo( Lg, {hint1,hint2,hint3,hint4,hint5}, true) + if hint then + EgtModifyCurveThickness(hint, -T) + EgtSetName(hint,LG) + -- muovo la geometria vesro sinistra del valore di L/2 + DS + EgtMove( hint, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hint,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hint,'DeltaPos' ,( L+(2*DS))) + -- se mantiene centro spessore anche su face + if kbs and kbs > 0 then + EgtSetInfo( hint, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hint, 'ProbeSide', '1') + end + end + end + + --------------------------------------- + --------------------------------------- + -- Costruzione delle geometrie di lavorazione + --------------------------------------- + --------------------------------------- + if nDrawMach > 0 then -- se abilitata geometria lavorazione + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + --------------------------------------- + -- geometria svuotatura giro interno + --------------------------------------- + local tPocket = {} + local pIni + local pEnd + local pEnd2 + local nStep + local dStep + local dPerim + local nDirVers + local nPass + local dZedStart = 0 + local dZedWork = -T + + -- individuo in che caso sono + local nCase + if abs(H-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (H-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((H-d) > ( d*0.98)) and ( (H-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (H-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi zig zag + nCase = 4 + end + + dPerim = 2*( H + L -(2*d)) + nStep = ceil(T/s) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + if nCase == 1 then -- solo 1 passaggio in centro + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + + local nDoubleStep = nStep * 2 + + while nPass <= nDoubleStep do + + -- primo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = dZedStart - ((dStep * nPass)/2) + if nPass == nDoubleStep then + dZedWork = -T + end + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + nPass = nPass + 1 + end + + -- ultimo mezzo passo + nDirVers = - nDirVers + pIni = pEnd + dZedWork = -T + pEnd = Point3d((-nDirVers*((L-d)/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- Uscita in Z0 + pIni = pEnd + dZedWork = 0 + + if ( nDeltaMovX > (L-d)) then + nDeltaMovX = (L-d) + end + pEnd = Point3d((-nDirVers*((L-d)/2)-nDeltaMovX),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + nPass = 1 + nDirVers = 1 + dZedStart = 0 + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedStart) -- nuovo punto finale + hint3 = EgtCircle( Dm, pEnd, (d/2) , GDB_RT.LOC) + EgtSetColor(hint3,PURPLE()) + + while nPass <= nStep do + + if nCase > 2 then -- se ho la svuotatura centrale scendo direttamente al passo + + -- prima linea discendente + pIni = pEnd + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + -- prima linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H-d)/dPerim)) + end + pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- seconda linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*((H+L-(2*d))/dPerim)) + end + pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- terza linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - ( dStep*(((2*H)+L-(3*d))/dPerim)) + end + pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- quarta linea contorno + pIni = pEnd + if nCase == 2 then + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + end + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- Se passaggio di contornatura e sono all'ultimo passo, faccio ancora un giro di contorno + if nCase == 2 and nPass == nStep then -- passaggio di contornatura + + -- prima linea contorno + pIni = pEnd + pEnd = Point3d(((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- seconda linea contorno + pIni = pEnd + pEnd = Point3d(-((L-d)/2),-((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- terza linea contorno + pIni = pEnd + pEnd = Point3d(-((L-d)/2),((H-d)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + -- quarta linea contorno + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- quinta linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((((L*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + + -- sesta linea passata centrale + pIni = pEnd + pEnd = Point3d(-(((L*2)-(d*3))/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, LIME(), LIME()) + + -- settima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + nDirVers = -1 + local nDistYcentr = (d*p) + local nPosYcentr = ((H-d)/2) - nDistYcentr + local bContinue = nPosYcentr > -((H-d)/2) + + -- linea posizionamento passaggi svuotatura + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + + -- ciclo passate svuotatura + while bContinue do + + -- linea affondamento in Y + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + + -- linea passata in X + pIni = pEnd + pEnd = Point3d((nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + + -- calcolo nuovo passo in Y e indice direzione + nPosYcentr = nPosYcentr - nDistYcentr + bContinue = nPosYcentr > -((H-d)/2) + + -- calcolo prossimo punto solo se sono ancora dentro l'area + if bContinue then + nDirVers = -nDirVers + -- ricalcolo punti per linea successiva + pIni = pEnd + pEnd = Point3d((-nDirVers * (((L*2)-(d*3))/4)),nPosYcentr,dZedWork) + end + end + + -- ultima linea ritorno a posizione iniziale + pIni = pEnd + pEnd = Point3d(((L-d)/2),((H-d)/2),dZedWork) + + if ( nDeltaMovX > ((L-d)/2)) then -- se delta più grande di metà cava in X + nDeltaMovX = (L-d)/2 + end + if ( nDeltaMovY > ((H-d)/2)) then -- se delta più grande di metà cava in Y + nDeltaMovY = (H-d)/2 + end + + pEnd2 = Point3d((((L-d)/2)-nDeltaMovX),(((H-d)/2)-nDeltaMovY),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + end + + -- Uscita in Z0 + pIni = pEnd + DrawAddLineDrawCircle( pIni, pEnd2, Lg, tPocket, bPreview, Dm, (d/2), false, true, GREEN(), GREEN()) + end + + -- trasformo in geometria composita il percorso di svuotatura + if ( #tPocket > 0) then + hintPk = EgtCurveCompo( Lg, tPocket, true) + if hintPk then + EgtModifyCurveThickness(hintPk, 0) + EgtSetName(hintPk,LM) + -- muovo la geometria vesro sinistra del valore di L/2 + DS + EgtMove( hintPk, Point3d(-((L/2)+DS),0,0) - ORIG()) + -- muovo la geometria vesro sinistra del valore di L/2 + DS + EgtMove( Dm, Point3d(-((L/2)+DS),0,0) - ORIG()) + EgtSetInfo( hintPk,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( Dm,'InserPoint' ,'Center') -- setto una nota per indicare su che lato della porta deve essere spostato + EgtSetInfo( hintPk,'DeltaPos' ,( L+(2*DS))) + EgtSetInfo( Dm,'DeltaPos' ,( L+(2*DS))) + -- se mantiene centro spessore anche su mortise + if kbs and kbs > 0 then + EgtSetInfo( hintPk, 'KeepBackSet', 'c') -- setto 'c' perchè viene mantenuto il centro spessore + end + if pbs and pbs > 0 and DGC.Pms and DGC.Pms > 2 then + EgtSetInfo( hintPk, 'ProbeSide', '1') + end + end + end + + if dws then -- se frame viene disposto sul lato wide + + local nIdSideBoxUp + + if hint then + nIdSideBoxUp = EgtCopyGlob( hint, Lg) + EgtSetName( nIdSideBoxUp, 'upper') + EgtSetInfo( nIdSideBoxUp, 'SideDoor', 'upper') + end + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint then + EgtSetColor(hint,AQUA()) + end + if hintPk then + EgtSetColor(hintPk,AQUA()) + end + else + if hint then + EgtSetColor(hint,ORANGE()) + end + if hintPk then + EgtSetColor(hintPk,ORANGE()) + end + end + else -- altrimenti non Preview + + -- (NOTA : se ci sono errori il componente non viene eseguito dal programma di gestione dei componenti) + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + if Dor then + EgtErase(Dor) + end + -- assegno nota su percorso svuotatura + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + end + + return hint, hintPk +end + +return _OverHeadPocket diff --git a/LuaLibs/_PivotL.lua b/LuaLibs/_PivotL.lua new file mode 100644 index 0000000..eb72c32 --- /dev/null +++ b/LuaLibs/_PivotL.lua @@ -0,0 +1,1902 @@ +-- +-- 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 +-- +-- _PivotL.lua by EgalWare s.r.l. 2016.07.11 +-- Autore: Filippo Monchi +-- PivotL, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.01.08 V1.0a3 FM Manage new R1 parameter to add a fillet on single corner +-- 2018.01.12 V1.0a4 FM Manage new anti splint position path when side pivot correspond to side door ( on offset and offsetintermediate type) +-- 2018.05.15 V1.0a5 FM Add manage new mode to count entity also on curvecompo path to allow assign note on connection entity +-- 2019.07.29 V1.0a6 FM Manage new differents pivot models and submodels: Centerhung pivot with submodel (1), Offset pivot with submodel (1), +-- OffsetInpermediate pivot with submodel (1) 4 +-- the defalult and old one is submodel (1) for all model +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.10.21 V2.001 FM Modify the closed path start point for steel material +-- 2020.10.20 V2.002 FM Fix error on insert fillet when L = L3 +-- 2024.07.19 V2.003 FM Set note 'NotCheckDir' to pocketing and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local PivotL = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- Valori limite +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' +-- contatori +local nTotContEnt = 0 +local nTotContEnt_r = 0 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, nCounter_r) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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, nCounter_r) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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 PivotL.Draw( EC, EM, tPivotParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tPivotParam.L + local H = tPivotParam.H + local T = tPivotParam.T + local L3 = tPivotParam.L3 + local H3 = tPivotParam.H3 + local radius = tPivotParam.rad + local R1 = tPivotParam.R1 + local R1i = tPivotParam.R1i + local D_SK = tPivotParam.D_SK + local D_SK2 = tPivotParam.D_SK2 + local B_SK = tPivotParam.B_SK + local d = tPivotParam.d + local p = tPivotParam.p + local sf = tPivotParam.sf + local d2 = tPivotParam.d2 + local jn = tPivotParam.jn + local L2 = tPivotParam.L2 + local H2 = tPivotParam.H2 + local D = tPivotParam.D + local D_X = tPivotParam.D_X + local invG = tPivotParam.invG + local est = tPivotParam.est + local mkrev = tPivotParam.mkrev + local stn = tPivotParam.stn + local subtype = tPivotParam.stype + local nextSub = tPivotParam.nextSub + local T2 = tPivotParam.T2 -- for subtype 4 + local s = tPivotParam.s -- for subtype 4 + local d3 = tPivotParam.d3 -- for subtype 4 + local p3 = tPivotParam.p3 -- for subtype 4 + -- Assegno i nomi geometrie + local LG = tPivotParam.LG + local LM = tPivotParam.LM + local LA = tPivotParam.LA + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tPivotParam.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = true + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + local dPrevTh = T + + -- se sottotipo 4 modifico le variabili necessarie + if subtype == 4 then + radius = 0 + R1 = 0 + R1i = 0 + T = T2 + L = 0 + mkrev = false + D_SK = 0 + if not jn then + d = d3 + p = p3 + sf = s + end + 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 radius or abs(radius) <= GEO.EPS_SMALL then + radius = 0 + end + + -- single radius on face: per compatibilità con tutti i componenti, se non è definito lo setto a 0 + if not R1 or abs(R1) <= GEO.EPS_SMALL then + R1 = 0 + end + + if not R1i or abs(R1i) <= GEO.EPS_SMALL then + R1i = 0 + end + + local nR1 = R1 + if B_SK == 0 then -- se forma L opposta resetto i raccordi + R1i = 0 + R1 = 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local hint1, hint2 + local hint, hintPk, hintAs1, hintAs2, hintPk_r + local pIni, pEnd, pCentr + + -- creo lo stesso la geometria esterna perchè viene utilizzata anche per creare il percorso di lavorazione + -- se non è previsto viene eliminato dopo + + local tPocket = {} + + -- Costruzione della geometria ( in senso orario) + -- se abilitato material steel faccio percorso chiuso + if est then + pIni = Point3d(-((L3/2)-(d/2)-dExtraH),(H3-(H/2)+(d/2)+dExtraH),0) + if B_SK then + pEnd = Point3d(L3/2,(H3-(H/2)+(d/2)+dExtraH),0) + else + pEnd = EgtIf( stn, Point3d(((L3/2)+(d/2)+dExtraH),(H3-(H/2)+(d/2)+dExtraH),0), Point3d(L3/2,(H3-(H/2)+(d/2)+dExtraH),0)) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if B_SK then + pIni = Point3d(L3/2,(H3-(H/2)),0) + else + pIni = EgtIf( stn, Point3d(((L3/2)+(d/2)+dExtraH),(H3-(H/2)),0), Point3d(L3/2,(H3-(H/2)),0)) + end + end + + if D_SK > 0 then -- se ho il knuckle centrato + if R1 > 0 and D_SK2 and D_SK2 > 0 then + -- linea discendente + pEnd = Point3d(L3/2,(H/2)+R1,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + -- arco antiorario verso destra + pEnd = Point3d((L3/2)+R1,(H/2),0) + pCentr = Point3d((L3/2)+R1,(H/2)+R1,0) + DrawAddCircleDrawCircle( pCentr, R1, 180,90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if D_SK > (R1+radius) then + -- linea verso destra + pEnd = Point3d((L3/2)+D_SK-radius,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + if radius > 0 then + -- arco orario verso destra + pEnd = Point3d((L3/2)+D_SK,(H/2)-radius,0) + pCentr = Point3d((L3/2)+D_SK-radius,(H/2)-radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs((2*radius) - H) < 0.0001 then + pEnd = Point3d(((L3/2)+D_SK-radius),-(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-radius),-(H/2)+radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(((L3/2)+D_SK),-(H/2)+radius,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3/2)+D_SK-radius),-(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-radius),-(H/2)+radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + else + --linea discendente fino a parte inferiore + pEnd = Point3d((L3/2)+D_SK,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + else -- se non ho il raccordo + if stn and not B_SK then + -- linea discendente fino a parte inferiore + pEnd = Point3d(((L3/2)+(d/2)+dExtraH),-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if subtype == 4 then + -- linea discendente fino a parte inferiore + pEnd = Point3d(L3/2,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + -- linea discendente + pEnd = Point3d(L3/2,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + if D_SK > (R1+radius) then + -- linea verso destra + pEnd = Point3d((L3/2)+D_SK-radius,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + if radius > 0 then + -- arco orario verso destra + pEnd = Point3d((L3/2)+D_SK,(H/2)-radius,0) + pCentr = Point3d((L3/2)+D_SK-radius,(H/2)-radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + if abs((2*radius) - H) < 0.0001 then + pEnd = Point3d(((L3/2)+D_SK-radius),-(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-radius),-(H/2)+radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(((L3/2)+D_SK),-(H/2)+radius,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3/2)+D_SK-radius),-(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-radius),-(H/2)+radius,0) + DrawAddCircleDrawCircle( pCentr, radius, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + else + --linea discendente + pEnd = Point3d((L3/2)+D_SK,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + end + end + else + if R1 > 0 then + -- linea discendente + pEnd = Point3d(L3/2,-(H/2)+R1,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3/2)+D_SK-R1),-(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-R1),-(H/2)+R1,0) + DrawAddCircleDrawCircle( pCentr, R1, 0,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else -- se non ho il raccordo + if B_SK then + pEnd = Point3d(L3/2,-(H/2),0) + else + pEnd = EgtIf( stn, Point3d(((L3/2)+(d/2)+dExtraH),-(H/2),0), Point3d(L3/2,-(H/2),0)) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + + local dRadTemp = radius + if D_SK2 and D_SK2 == 0 then -- se forma L opposta setto il raccordo con il valore di R1 + dRadTemp = nR1 + end + + if dRadTemp > 0 then + pEnd = Point3d(((L3/2)+D_SK-L+dRadTemp),-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3/2)+D_SK-L),-(H/2)+dRadTemp,0) + pCentr = Point3d(((L3/2)+D_SK-L+dRadTemp),-(H/2)+dRadTemp,0) + DrawAddCircleDrawCircle( pCentr, dRadTemp, -90,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if subtype == 4 then + if stn and B_SK then + pEnd = Point3d((-(L3/2)-(d/2)-dExtraH),-(H/2),0) + else + pEnd = Point3d((-(L3/2)+D_SK),-(H/2),0) + end + else + if stn and B_SK then + pEnd = Point3d(((L3/2)+D_SK-L-(d/2)-dExtraH),-(H/2),0) + else + pEnd = Point3d(((L3/2)+D_SK-L),-(H/2),0) + end + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + dRadTemp = radius + if D_SK2 and D_SK2 == 0 then -- se forma L opposta resetto i raccordi + dRadTemp = 0 + R1i = 0 + end + + if dRadTemp > 0 then + if (L3+D_SK-L) < -dRadTemp then + if abs((2*dRadTemp) - H) < 0.0001 then + pEnd = Point3d(((L3/2)+D_SK-L+dRadTemp),(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-L+dRadTemp),-(H/2)+dRadTemp,0) + DrawAddCircleDrawCircle( pCentr, dRadTemp, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + pEnd = Point3d(((L3/2)+D_SK-L),(H/2)-dRadTemp,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3/2)+D_SK-L+dRadTemp),(H/2),0) + pCentr = Point3d(((L3/2)+D_SK-L+dRadTemp),(H/2)-dRadTemp,0) + DrawAddCircleDrawCircle( pCentr, dRadTemp, 180,-90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + else -- se non ho spazio per il secondo salgo diritto + pEnd = Point3d(((L3/2)+D_SK-L),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + else + if subtype < 4 then + if not D_SK2 or (D_SK2 and D_SK2 > 0) then + pEnd = Point3d(((L3/2)+D_SK-L),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + end + + if dRadTemp > 0 then + if D_SK > 0 then + if R1i > 0 then + if abs( L-D_SK-L3-dRadTemp-R1i) > 0.001 then + -- linea fino al raccordo R1i + pEnd = Point3d(-(L3/2)-R1i,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + -- arco antiorario verso l'alto + pEnd = Point3d(-(L3/2),(H/2)+R1i,0) + pCentr = Point3d(-(L3/2)-R1i,(H/2)+R1i,0) + DrawAddCircleDrawCircle( pCentr, R1i, 270,90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if abs( L-D_SK-L3-dRadTemp) > 0.001 then + pEnd = Point3d(-(L3/2),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + else + if abs( L-L3-dRadTemp) > 0.001 then + pEnd = Point3d(-(L3/2),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + else + if D_SK > 0 then + if R1i > 0 then + if abs( L-D_SK-L3-dRadTemp-R1i) > 0.001 then + -- linea fino al raccordo R1i + pEnd = Point3d(-(L3/2)-R1i,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + -- arco antiorario verso l'alto + pEnd = Point3d(-(L3/2),(H/2)+R1i,0) + pCentr = Point3d(-(L3/2)-R1i,(H/2)+R1i,0) + DrawAddCircleDrawCircle( pCentr, R1i, 270,90, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + else + if abs( L-D_SK-L3-dRadTemp) > 0.001 then + pEnd = Point3d(-(L3/2),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + else + if subtype < 4 then + pEnd = Point3d(-(L3/2),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + end + end + + if stn and B_SK then + if subtype == 4 then + pEnd = Point3d(-((L3/2)+(d/2)+dExtraH),H3-(H/2),0) + else + pEnd = Point3d(((L3/2)+D_SK-L-(d/2)-dExtraH),(H3-(H/2)+EgtIf( est, (d/2)+dExtraH, 0)),0) + end + else + pEnd = Point3d(-(L3/2),(H3-(H/2)+EgtIf( est, (d/2)+dExtraH, 0)),0) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + -- se abilitato material steel chiudo il percorso + if est then + pEnd = Point3d(-((L3/2)-(d/2)-dExtraH),(H3-(H/2)+(d/2)+dExtraH),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + hint = EgtCurveCompo( Lg, tPocket, true) + if hint then + EgtModifyCurveThickness( hint, -T) + EgtSetName( hint, LG or '') + if est then + EgtSetInfo( hint, 'StartFromExt', 1) + end + end + + --------------------------------------- + --------------------------------------- + -- Costruzione delle geometrie di lavorazione + --------------------------------------- + --------------------------------------- + if nDrawMach > 0 and not est then -- se abilitata geometria lavorazione + + local tPocket = {} + local tPocket_r = {} + local tPocketAs = {} + local tPocketAs_r = {} + local pIni , pEnd + local nCase, nCaseNext, nCaseH + local dZedStart, dZedWork + local nRadius, hint_ofs, hint_ofs_r, hint_ofs2, hint_ofs2_r + local pIni_r, pEnd_r + local nStep + local dStep + local nPass + local pStartStep + local pStartStep_r + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + -- geometria antischeggia + if d2 then -- se parametro valido + + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + local tMVar = {} + local tMVar_r = {} + local nConEnt + local sKindVar + local dPosY, dEndPosY, dIniPosY, dDeltaPosX + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + if nStep == 1 then + dZedWork = 0 + else + dZedWork = -T + end + end + + if bStartAng then -- se lead-in con angolo + + dEndPosY = -(d2/4) + dPosY = dEndPosY + (d2/8) + dIniPosY = dPosY + (d2*7/8) + dDeltaPosX = ( (d2*7/8) / tan(30)) + + if ( not B_SK and ( not stn or ( stn and invG > 0))) or + ( B_SK and not( stn and invG > 0)) then -- se il pivot non sborda + + -- linea entrante inclinata + pIni = Point3d((-((L3-d2)/2) + 0.2 + dDeltaPosX)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd = Point3d((-((L3-d2)/2) + 0.2)*invG, (H3-(H/2)+dPosY),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in Y + pIni = pEnd + pEnd = Point3d((-((L3-d2)/2) + 0.2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni = pEnd + pEnd = Point3d(-((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-((L3-d2)/2)*invG,(H3-(H/2)+(d2*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d((-((L3-d2)/2) + 0.2 + dDeltaPosX)*invG, pIni:getY(), dZedWork) + else -- se il pivot sborda faccio geomtria ruotata + + -- linea entrante inclinata + pIni = Point3d(-((L3/2)+dIniPosY)*invG, (-((H-d2)/2) + 0.2 + dDeltaPosX),dZedWork) + pEnd = Point3d(-((L3/2)+dPosY)*invG, (-((H-d2)/2) + 0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in X + pIni = pEnd + pEnd = Point3d(-((L3/2)+dEndPosY)*invG, (-((H-d2)/2) + 0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni = pEnd + pEnd = Point3d(-((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni = pEnd + pEnd = Point3d(-((L3/2)+(d2*3/4))*invG,-((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(pIni:getX(), (-((H-d2)/2) + 0.2 + dDeltaPosX), dZedWork) + end + + if mkrev then -- se abilitato anche il percorso inverso + + if not stn or ( stn and invG < 0) then -- se il pivot non sborda + + -- linea entrante inclinata + pIni_r = Point3d((((L3-d2)/2) - 0.2 - dDeltaPosX)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd_r = Point3d((((L3-d2)/2) - 0.2)*invG, (H3-(H/2)+dPosY),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in Y + pIni_r = pEnd_r + pEnd_r = Point3d((((L3-d2)/2) - 0.2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni_r = pEnd_r + pEnd_r = Point3d(((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni_r = pEnd_r + pEnd_r = Point3d(((L3-d2)/2)*invG,(H3-(H/2)+(d2*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d((((L3-d2)/2) - 0.2 - dDeltaPosX)*invG, pIni_r:getY(), dZedWork) + else -- se il pivot sborda faccio geometria ruotata + + -- linea entrante inclinata + pIni_r = Point3d(((L3/2)+dIniPosY)*invG, (-((H-d2)/2) + 0.2 + dDeltaPosX),dZedWork) + pEnd_r = Point3d(((L3/2)+dPosY)*invG, (-((H-d2)/2) + 0.2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea entrante in X + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dEndPosY)*invG, (-((H-d2)/2) + 0.2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linee tangente al percorso + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea di uscita + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+(d2*3/4))*invG,-((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d(pIni_r:getX(), (-((H-d2)/2) + 0.2 + dDeltaPosX), dZedWork) + end + end + else -- lead-in diritto + + dEndPosY = -(d2/4) + dIniPosY = (d2*3/4) + + if ( not B_SK and ( not stn or ( stn and invG > 0))) or + ( B_SK and not( stn and invG > 0)) then -- se il pivot non sborda + + if nStep == 1 then + pIni = Point3d(-((L3-d2)/2)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd = Point3d(-((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + pIni = Point3d((-((L3-d2)/2) + 0.2)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd = Point3d((-((L3-d2)/2) + 0.2)*invG, (H3-(H/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(-((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d( pIni:getX(), (H3-(H/2)+dIniPosY), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d((-((L3-d2)/2) + 0.2)*invG, pIni:getY(), dZedWork) + end + else -- se il pivot sborda faccio geometria ruotata + + if nStep == 1 then + pIni = Point3d(-((L3/2)+dIniPosY)*invG, -((H-d2)/2),dZedWork) + pEnd = Point3d(-((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + pIni = Point3d(-((L3/2)+dIniPosY)*invG, -((H-d2)/2)+0.2,dZedWork) + pEnd = Point3d(-((L3/2)+dEndPosY)*invG, -((H-d2)/2)+0.2,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(-((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(-((L3/2)+dIniPosY)*invG, pIni:getY(), dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(pIni:getX(), -((H-d2)/2)+0.2, dZedWork) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + if not stn or ( stn and invG < 0) then -- se il pivot non sborda + + if nStep == 1 then + pIni_r = Point3d(((L3-d2)/2)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd_r = Point3d(((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + pIni_r = Point3d((((L3-d2)/2) - 0.2)*invG, (H3-(H/2)+dIniPosY),dZedWork) + pEnd_r = Point3d((((L3-d2)/2) - 0.2)*invG, (H3-(H/2)+dEndPosY),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + pIni_r = pEnd + pEnd_r = Point3d(((L3-d2)/2)*invG, (H3-(H/2)+dEndPosY), dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d( pIni_r:getX(), (H3-(H/2)+dIniPosY), dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d((((L3-d2)/2) - 0.2)*invG, pIni_r:getY(), dZedWork) + end + else -- se il pivot sborda faccio geomtria ruotata + + if nStep == 1 then + pIni_r = Point3d(((L3/2)+dIniPosY)*invG, -((H-d2)/2),dZedWork) + pEnd_r = Point3d(((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + pIni_r = Point3d(((L3/2)+dIniPosY)*invG, -((H-d2)/2)+0.2,dZedWork) + pEnd_r = Point3d(((L3/2)+dEndPosY)*invG, -((H-d2)/2)+0.2,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- faccio il ritorno alla posizione di partenza + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dEndPosY)*invG, -((H-d2)/2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dIniPosY)*invG, pIni_r:getY(), dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d(pIni_r:getX(), -((H-d2)/2)+0.2, dZedWork) + end + end + 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 mkrev then -- se abilitato anche il percorso inverso + pIniLoc = pEnd_r + pEnd_r = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar_r, {nConEnt,sKindVar}) + end + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs1 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs1, -T) + else + 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 + EgtSetName(hintAs1,LA) + end + end + + if ( #tPocketAs_r > 0) then + hintAs2 = EgtCurveCompo( Lg, tPocketAs_r, true) + if hintAs2 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs2, -T) + else + EgtModifyCurveThickness( hintAs2, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end + end + EgtSetName(hintAs2,(LA..'_R')) + end + end + end + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + + -- individuo in che caso sono + local dDimMax = max( H, EgtIf( stn, L3+(d/2)+dExtraH,L3)) + local dDimMin = H + -- controllo con la distanza massima + if abs(dDimMax-d) < 0.03 then -- solo 1 passaggio in centro + nCase = 1 + elseif (dDimMax-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCase = 2 + elseif ((dDimMax-d) > ( d*0.98)) and ( (dDimMax-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase = 3 + elseif (dDimMax-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi offset + nCase = 4 + end + -- controllo con la distanza minima + if abs(dDimMin-d) < 0.03 then -- solo 1 passaggio in centro + nCaseH = 1 + elseif (dDimMin-d) <= ( d*0.98) then -- solo passaggio di contornatura + nCaseH = 2 + elseif ((dDimMin-d) > ( d*0.98)) and ( (dDimMin-d) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCaseH = 3 + elseif (dDimMin-d) > (d*(1+p)) then -- passaggio di contornatura + passaggi offset + nCaseH = 4 + end + + local nDirVers = 1 + local tMVar = {} + local tMVar_r = {} + local nConEnt + local sKindVar + + -- resetto contatori entità + nTotContEnt = 0 + nTotContEnt_r = 0 + nRadius = dDimMax/2 + nPass = 1 + if jn and subtype == 4 then -- svuotature unite calcolo il numero di passi in Z + dZedStart = -dPrevTh + nStep = ceil((T2-dPrevTh)/sf) -- numero di passate + dStep = ((T2-dPrevTh)/nStep) -- passo ricalcolato + jn = false + else + dZedStart = 0 + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + end + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + if nCase == 1 then -- solo 1 passaggio in centro + + if nDirVers == 1 then -- se passata di andata + + -- se primo passo con seconda cava faccio linea di discesa + if nPass == 1 and not jn and subtype == 4 then + pIni = Point3d(0,(H3-(H/2)+(d*3/4)),dZedStart) + pStartStep = pIni + pEnd = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + end + + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + + if not stn and D_SK > 0 then + pEnd = Point3d(((L3/2)+D_SK-(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + end + + if subtype < 4 then + pEnd = Point3d(((L3/2)+D_SK-L+(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + pIni = pEnd + end + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd = Point3d(pIni:getX(),0,(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + end + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + + if not stn and D_SK > 0 then + pEnd_r = Point3d(((L3/2)+D_SK-(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + end + + pEnd_r = Point3d(((L3/2)+D_SK-L+(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pEnd_r = Point3d(((L3/2)+D_SK-L+(d/2)),0,(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, 1) + end + end + else -- altrimenti passata di ritorno + + if subtype == 4 then + if not stn and D_SK > 0 then + pIni = Point3d(((L3/2)+D_SK-(d/2)),0,dZedWork) + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(0,0,dZedWork) + end + pEnd = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + else + pIni = Point3d(((L3/2)+D_SK-L+(d/2)),0,dZedWork) + + if not stn and D_SK > 0 then + pEnd = Point3d(((L3/2)+D_SK-(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + end + + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + end + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+(d*3/4)),(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, RED(), RED()) + end + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = Point3d(((L3/2)+D_SK-L+(d/2)),0,dZedWork) + + if not stn and D_SK > 0 then + pEnd_r = Point3d(((L3/2)+D_SK-(d/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + end + + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, 1) + + -- se non sono all'ultima passata scendo in Z + if nPass < nStep then + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+(d*3/4)),(dZedWork-dStep)) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, RED(), RED(), nil, 1) + end + end + end + + if nPass == nStep then + + 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 + + -- se ho fatto passata ritorno scendo alla Y del punto join + if nDirVers == 1 then -- se fatta passata di andata + + if nextSub == 4 then -- se il percorso successivo è ancora una forma pivot torno al punto di inizio + pEnd = Point3d(pStartStep:getX(),pIni:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + else + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + else + pEnd = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + else -- altrimenti già tornato + + if nextSub == 4 then -- se il percorso successivo è ancora una forma pivot torno al punto di inizio + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + else + -- linea discendente + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d(pIni:getX(),D,dZedWork) + else + pEnd = Point3d(pIni:getX(),(((H2-d)/2)+D),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + else + pEnd = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + end + end + + if mkrev then -- se abilitato anche il percorso inverso + + pIni_r = pEnd_r + + -- se ho fatto passata ritorno scendo alla Y del punto join + if nDirVers == 1 then -- se passata di andata + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + else + pEnd_r = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + end + + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + else + + -- linea discendente + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(pIni_r:getX(),D,dZedWork) + else + pEnd_r = Point3d(pIni_r:getX(),(((H2-d)/2)+D),dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + + pIni_r = pEnd_r + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + pEnd_r = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + else + pEnd_r = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + end + + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + end + end + end + end + -- solo contornatura or contornatura + un passaggio centrale or contornatura + passaggi svuotatura + elseif ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + -- calcolo l'ampiezza dell'offset + nRadius = nRadius - (d/2) + + -- offset + hint_ofs = EgtOffsetCurveAdv( hint, (d/2), GDB_OT.FILLET) + + if hint_ofs and hint_ofs > 0 then + + if mkrev then -- se abilitato anche il percorso inverso + -- copia del percorso offsettato + hint_ofs_r = EgtCopyGlob( hint_ofs, Lg) + end + + -- 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 bStartOppo then + + if ( not B_SK and ( not stn or ( stn and invG > 0))) or + ( B_SK and not( stn and invG > 0)) then -- se il pivot non sborda + + -- se primo passo con seconda cava faccio linea di discesa + if nPass == 1 and not jn and subtype == 4 then + pIni = Point3d((-((L3-d)/2) + 0.2)*invG,(H3-(H/2)+(d*3/4)),dZedStart) + pStartStep = pIni + pEnd = Point3d((-((L3-d)/2) + 0.2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d((-((L3-d)/2) + 0.2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + end + + -- linea in Y con centro utensile fuori + pEnd = Point3d((-((L3-d)/2) + 0.2)*invG,(H3-(H/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(((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + else -- se il pivot sborda faccio geometria ruotata + + -- se primo passo con seconda cava faccio linea di discesa + if nPass == 1 and not jn and subtype == 4 then + pIni = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedStart) + pStartStep = pIni + pEnd = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + pStartStep = pIni + end + + -- linea in X con centro utensile fuori + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni = pEnd + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + else + if ( not B_SK and ( not stn or ( stn and invG > 0))) or + ( B_SK and not( stn and invG > 0)) then -- se il pivot non sborda + + -- se primo passo con seconda cava faccio linea di discesa + if nPass == 1 and not jn and subtype == 4 then + pIni = Point3d(((L3-d)/2)*invG,(H3-(H/2)+(d*3/4)),dZedStart) + pStartStep = pIni + pEnd = Point3d(((L3-d)/2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(((L3-d)/2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + end + + -- prima linea entrante + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + else -- se il pivot sborda faccio geomtria ruotata + + -- se primo passo con seconda cava faccio linea di discesa + if nPass == 1 and not jn and subtype == 4 then + pIni = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedStart) + pStartStep = pIni + pEnd = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + else + pIni = Point3d(-((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + pStartStep = pIni + end + + -- prima linea entrante + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni = pEnd + pEnd = Point3d(-((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + pEnd = Point3d(((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = pEnd + pEnd = EgtSP( hint_ofs) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- muovo la geometria in Z + EgtMove( hint_ofs_r, Point3d(0,0,dZedWork) - ORIG()) + + -- se flag non inverso, inverto la geometria, solo qui non nelle altre copie + if invG > 0 then + EgtInvertCurve(hint_ofs_r) + end + + if bStartOppo then + if not stn or ( stn and invG < 0) then -- se il pivot non sborda + pIni_r = Point3d((((L3-d)/2) - 0.2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + -- linea in Y con centro utensile fuori + pEnd_r = Point3d((((L3-d)/2) - 0.2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + pIni_r = pEnd_r + pEnd_r = Point3d(-((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea entrante a prendere il percorso di offset + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs_r) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + else -- se il pivot sborda faccio geomtria ruotata + pIni_r = Point3d(((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + pStartStep_r = pIni_r + -- linea in X con centro utensile fuori + pEnd_r = Point3d(((L3/2)+dExtraH)*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(-((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea entrante a prendere il percorso di offset + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs_r) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + else + if not stn or ( stn and invG < 0) then -- se il pivot non sborda + -- prima linea entrante + pIni_r = Point3d(-((L3-d)/2)*invG,(H3-(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + pEnd_r = EgtSP( hint_ofs_r) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + else -- se il pivot sborda faccio geomtria ruotata + -- prima linea entrante + pIni_r = Point3d(((L3/2)+(d*3/4))*invG,(-((H-d)/2)+0.2),dZedWork) + pStartStep_r = pIni_r + pEnd_r = Point3d(((L3/2)+dExtraH)*invG,(-((H-d)/2)+0.2),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linee traverse in Y e poi X per andare sul vecchio punto iniziale (in X) + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+dExtraH)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(-((L3-d)/2)*invG,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs_r) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + end + end + end + + if nCase == 2 and R1 > 0 and p >= 0.8 then -- passaggio di contornatura con il raccordo sullo spigolo + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + if subtype < 4 then + if nCaseH >= 2 then + pEnd = Point3d(((L3/2)-(d/2)-dExtraH),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + end + + if subtype < 4 then + if nCaseH >= 2 then -- se forma a L e la parte lunga è abbastanza larga + pEnd = Point3d(-((L3/2)-(d/2)-dExtraH)*EgtIf(B_SK,-1,1),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + end + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + if subtype < 4 then + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + elseif nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + if not stn and D_SK > 0 and not B_SK then + if nCaseH > 2 then + pEnd = Point3d(((L3/2)+D_SK-(d*3/4)),0,dZedWork) + else + pEnd = Point3d(((L3/2)-(d/2)-dExtraH),0,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + if subtype < 4 then + if nCaseH > 2 then -- se forma a L e la parte lunga è abbastanza larga + if B_SK then + pEnd = Point3d(((L3/2)+D_SK-(d*3/4)),0,dZedWork) + else + if D_SK == 0 or ( D_SK2 and D_SK2 > 0) then + pEnd = Point3d(((L3/2)+D_SK-L+(d*3/4)),0,dZedWork) + end + end + else + pEnd = Point3d(-((L3/2)-(d/2)-dExtraH)*EgtIf(B_SK,-1,1),0,dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + if subtype < 4 then + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- linea posizionamento passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + + -- linee passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + if not stn and D_SK > 0 then + if nCaseH > 2 then + pEnd_r = Point3d(((L3/2)+D_SK-(d*3/4)),0,dZedWork) + else + pEnd_r = Point3d(((L3/2)-(d/2)-dExtraH),0,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + + if nCaseH > 2 then + pEnd_r = Point3d(((L3/2)+D_SK-L+(d*3/4)),0,dZedWork) + else + pEnd_r = Point3d(-((L3/2)-(d/2)-dExtraH),0,dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + local nDistYcentr = (d*p) + local bContinue + + -- se percorso offset esiste + if hint_ofs and hint_ofs > 0 then + + -- faccio l'offset del raggio fresa + nRadius = nRadius - nDistYcentr + bContinue = nRadius > 0 + nCountOfs = 0 + + -- se percorso offset esiste + while bContinue do + + hint_ofs2 = EgtOffsetCurveAdv( hint_ofs, nDistYcentr*invG, GDB_OT.FILLET) + + if hint_ofs2 and hint_ofs2 > 0 then + + nCountOfs = nCountOfs + 1 + + -- linea congiunzione tra osset + pIni = pEnd + pEnd = EgtSP( hint_ofs2) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pEnd = EgtEP( hint_ofs2) + hint_ofs = hint_ofs2 + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + + if mkrev then -- se abilitato anche il percorso inverso + + -- copia del percorso offsettato + hint_ofs2_r = EgtCopyGlob( hint_ofs2, Lg) + EgtInvertCurve(hint_ofs2_r) + -- linea congiunzione tra osset + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs2_r) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + pEnd_r = EgtEP( hint_ofs2_r) + hint_ofs_r = hint_ofs2_r + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + end + + -- calcolo nuovo passo in Y e indice direzione + nRadius = nRadius - nDistYcentr + bContinue = nRadius > 0 + else + bContinue = false + end + end -- end while + + if not stn then -- se non sborda + + -- se ho knuckle aggiungo passaggio centrale + if D_SK > 0 then + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + pEnd = Point3d(((L3/2)+D_SK-(nDistYcentr*nCountOfs)-d),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + if subtype < 4 then + pEnd = Point3d(((L3/2)+D_SK-L+(nDistYcentr*nCountOfs)+d),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- linea posizionamento passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + + -- linee passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + + pIni_r = pEnd_r + pEnd_r = Point3d(((L3/2)+D_SK-(nDistYcentr*nCountOfs)-d),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + pEnd_r = Point3d(((L3/2)+D_SK-L+(nDistYcentr*nCountOfs)+d),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + end + end + elseif p > 0.6 then -- se sborda ma la percentuale di sovrapposizione è alta + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- linea posizionamento passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + + -- linee passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + pEnd_r = Point3d(0,(H3-(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + end + end + end + end + + if nPass == nStep then + + if jn then -- se uso un solo utensile mi porto in posizione di partenza per la prossima geometria + + -- carcolo 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 mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + end + + if nextSub == 4 then -- se il percorso successivo è ancora una forma pivot torno al punto di inizio + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale, torno indietro + pEnd = Point3d(0,0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + pEnd = Point3d(pIni:getX(),pStartStep:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + else + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni:getX() + pEnd = Point3d(nx,D,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + end + pEnd = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + + if mkrev then -- se abilitato anche il percorso inverso + + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni_r:getX() + pEnd_r = Point3d(nx,D,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + pIni_r = pEnd_r + end + pEnd_r = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),D,dZedWork) + end + else + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni:getX() + pEnd = Point3d(nx,(((H2-d)/2)+D),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + end + pEnd = Point3d(((((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + + if mkrev then -- se abilitato anche il percorso inverso + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni_r:getX() + pEnd_r = Point3d(nx,(((H2-d)/2)+D),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + pIni_r = pEnd_r + end + pEnd_r = Point3d(((-((L2-d)/2)*invG)-((L-L3)/2)+D_X),(((H2-d)/2)+D),dZedWork) + end + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + end + end + end + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + nRadius = dDimMax/2 + nDirVers = -nDirVers + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep and nCase > 1 then + + pIni = pEnd + if ( not B_SK and ( not stn or ( stn and invG > 0))) or + ( B_SK and not( stn and invG > 0)) then -- se il pivot non sborda + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),dZedStart) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,sKindVar}) + else -- se il pivot sborda faccio geometria ruotata + pEnd = Point3d(pStartStep:getX(),pIni:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,sKindVar}) + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,sKindVar}) + end + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + if not stn or ( stn and invG < 0) then -- se il pivot non sborda + pEnd_r = Point3d(pStartStep_r:getX(),pStartStep_r:getY(),dZedStart) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(pStartStep_r:getX(),pStartStep_r:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, 1) + table.insert( tMVar_r, {nTotContEnt_r,sKindVar}) + else -- se il pivot sborda faccio geomtria ruotata + pEnd_r = Point3d(pStartStep_r:getX(),pIni_r:getY(),dZedStart) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, 1) + table.insert( tMVar_r, {nTotContEnt_r,sKindVar}) + pIni_r = pEnd_r + pEnd_r = Point3d(pStartStep_r:getX(),pStartStep_r:getY(),(dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, 1) + table.insert( tMVar_r, {nTotContEnt_r,sKindVar}) + end + end + 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) + end + end + + if ( #tPocket_r > 0) then + hintPk_r = EgtCurveCompo( Lg, tPocket_r, true) + if hintPk_r then + EgtModifyCurveThickness(hintPk_r, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPk_r, 'MVar', sListEnt) end + EgtSetName(hintPk_r,(LM..'_R')) + end + end + + -- se variabile inversione negativa inverto la direzione del percorso geomerico principale + if invG < 0 then + EgtInvertCurve(hint) + 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 + 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 hintPk_r then + EgtSetColor(hintPk_r,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 hintPk_r then + EgtSetColor(hintPk_r,ORANGE()) + end + end + else -- altrimenti non Preview + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + -- assegno nota su percorsi antisplint e svuotatura + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + if hintAs1 then + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + end + if hintAs2 then + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + end + if hintPk_r then + EgtSetInfo( hintPk_r, 'NotCheckDir', '1') + end + end + + return hint, hintPk, hintAs1, hintAs2, hintPk_r +end + +return PivotL diff --git a/LuaLibs/_Strike.lua b/LuaLibs/_Strike.lua new file mode 100644 index 0000000..06a4bf5 --- /dev/null +++ b/LuaLibs/_Strike.lua @@ -0,0 +1,1549 @@ +-- +-- 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 +-- +-- _Strike.lua by EgalWare s.r.l. 2016.07.11 +-- Autore: Filippo Monchi +-- StrikeC, componente di secondo livello, non può essere chiamato direttamente da un lua dei +-- componenti di interfaccia + +-- 2017.09.05 V1.0a2 FM Manage lead-in on opposite side and anti-splint path V lead-in +-- 2018.01.08 V1.0a3 FM Manage new R1 parameter to add a fillet on single corner +-- 2018.01.12 V1.0a4 FM Manage new anti splint position path when side pivot correspond to side door ( on offset and offsetintermediate type) +-- 2018.05.15 V1.0a5 FM Add manage new mode to count entity also on curvecompo path to allow assign note on connection entity +-- 2019.10.10 V1.0a6 FM Manage steel option (disable to generate pocket paths and antisplint path, make closed and extend face path) +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2024.04.12 V2.001 FM Also Consider the latch strike wide to check if it's possible do the offset +-- 2024.07.19 V2.002 FM Set note 'NotCheckDir' to pocketing and antisplint paths + +-- Tavola per definizione modulo (serve ma non usata) +local StrikeC = {} + +-- Intestazioni +require( 'EgtBase') +EgtEnableDebug( false) + +-- Valori limite +local dExtraH = 0.5 +local sMaxFeed = 'MaxFeed' +local sRapid = 'Rapid' +-- contatori +local nTotContEnt = 0 +local nTotContEnt_r = 0 + +local function DrawAddLineDrawCircle( pInitial, pFinal, nGroup, idTable, bPrev, nGroupCirc, + nRad, bDrawFirst, bDrawLast, cColor1, cColor2, sMVar, nCounter_r) + + local nLine = EgtLine(nGroup, pInitial, pFinal, GDB_RT.LOC) + local nNumLine + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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, nCounter_r) + + local nCircle = EgtArc( nGroup, pCenter, dRadius, dAngIni, dAngCen, 0, GDB_RT.LOC) + local nNumCircle + -- serve per il conteggio delle entità in caso di concatenamento con curvecompo + if nCounter_r then + nTotContEnt_r = nTotContEnt_r + 1 + else + nTotContEnt = nTotContEnt + 1 + end + + 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 DrawExternalPath( Lg, D_SS, L, LS, H, H3, IS, AS, R1, rf, nMode, H5, Dm) + + local tPath = {} + local tPath2 = {} + local nPath1, nPath2 + local pIni, pEnd, pCentr, pIni_c, pEnd_c + local dLS = H3 * tan(AS) + local H5r = EgtIf( H5, H5, H3) + local dLS5 = H5r * tan(AS) + local dR1 = R1 * tan((90-AS)/2) + local dR1s = dR1*sin(AS) + local dR1c = dR1*cos(AS) + + -- Costruzione della geometria ( in senso orario) prima parte percorso + + if nMode == 2 then + pIni = Point3d((-D_SS-dLS),(H3+(H/2)),0) + else + pIni_c = Point3d((-D_SS-dLS),(H3+(H/2)),0) + pIni = Point3d((-D_SS-dLS5),(H5r+(H/2)),0) + end + + if R1 > 0 then + pEnd = Point3d((-D_SS-dR1s),((H/2)+dR1c),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni_c, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-D_SS+dR1,(H/2),0) + pCentr =Point3d(-D_SS+dR1,((H/2)+R1),0) + DrawAddCircleDrawCircle( pCentr, R1,(180+AS),(90-AS), Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, R1,(180+AS),(90-AS), Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(-D_SS,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni_c, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if rf > 0 then + pEnd = Point3d(-rf,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(0,(H/2)-rf,0) + pCentr = Point3d(-rf,(H/2)-rf,0) + DrawAddCircleDrawCircle( pCentr, rf, 90,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, 90,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(0,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if rf > 0 then + if abs((2*rf)-H) < 0.0001 then + pEnd = Point3d(-rf,-(H/2),0) + pCentr = Point3d(-rf,-(H/2)+rf,0) + DrawAddCircleDrawCircle( pCentr, rf, 0,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, 0,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(0,-(H/2)+rf,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-rf,-(H/2),0) + pCentr = Point3d(-rf,-(H/2)+rf,0) + DrawAddCircleDrawCircle( pCentr, rf, 0,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, 0,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + else + pEnd = Point3d(0,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if rf > 0 then + if abs( L-rf-rf) > 0.001 then + pEnd = Point3d(-L+rf,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-L,-(H/2)+rf,0) + pCentr = Point3d(-L+rf,-(H/2)+rf,0) + DrawAddCircleDrawCircle( pCentr, rf, -90,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, -90,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(-L,-(H/2)+rf,0) + pCentr = Point3d(-L+rf,-(H/2)+rf,0) + DrawAddCircleDrawCircle( pCentr, rf, -90,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, -90,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + else + pEnd = Point3d(-L,-(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if rf > 0 then + if abs((2*rf)-H) < 0.0001 then + pEnd = Point3d(-L+rf,(H/2),0) + pCentr = Point3d(-L+rf,(H/2)-rf,0) + DrawAddCircleDrawCircle( pCentr, rf, 180,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, 180,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(-L,(H/2)-rf,0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-L+rf,(H/2),0) + pCentr = Point3d(-L+rf,(H/2)-rf,0) + DrawAddCircleDrawCircle( pCentr, rf, 180,-90, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, rf, 180,-90, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + else + pEnd = Point3d(-L,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if R1 > 0 then + pEnd = Point3d((-D_SS-LS-IS-dR1),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d((-D_SS-LS-IS+dR1s),((H/2)+dR1c),0) + pCentr = Point3d((-D_SS-LS-IS-dR1),((H/2)+R1),0) + DrawAddCircleDrawCircle( pCentr, R1, -90,(90-AS), Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, R1, -90,(90-AS), Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d((-D_SS-LS-IS),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + -- risalita dente + pEnd = Point3d((-D_SS-LS-IS+dLS),(H3+(H/2)),0) -- punto idoneo per modo 2 o per modo 1 con doppio dente + if nMode == 1 then + pEnd_c = Point3d((-D_SS-LS-IS+dLS),(H3+(H/2)),0) + if abs(IS) < GEO.EPS_SMALL then -- se un solo dente + pEnd = Point3d((-D_SS-LS-IS+dLS5),(H5r+(H/2)),0) + end + DrawAddLineDrawCircle( pIni, pEnd_c, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + pIni_c = pEnd_c + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + + if nMode == 2 then -- se modalità percorsi aperti + -- creo primo percorso + nPath1 = EgtCurveCompo( Lg, tPath, true) + pIni = Point3d((-D_SS-IS-dLS),(H3+(H/2)),0) + + if IS > 0 then -- se passo per due denti + tPath = {} + end + else -- percorso chiuso + + if abs(IS) > GEO.EPS_SMALL then -- se un solo dente + pEnd = Point3d((-D_SS-IS-dLS),(H3+(H/2)),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + pEnd_c = Point3d((-D_SS-IS-dLS),(H3+(H/2)),0) + DrawAddLineDrawCircle( pIni_c, pEnd_c, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + pIni_c = pEnd_c + end + + if IS > 0 then -- se passo per due denti + + if R1 > 0 then + pEnd = Point3d((-D_SS-IS-dR1s),((H/2)+dR1c),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni_c, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-D_SS-IS+dR1,(H/2),0) + pCentr = Point3d(-D_SS-IS+dR1,((H/2)+R1),0) + DrawAddCircleDrawCircle( pCentr, R1, (180+AS),(90-AS), Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, R1, (180+AS),(90-AS), Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d(-D_SS-IS,(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + if R1 > 0 then + pEnd = Point3d((-D_SS-LS-dR1),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + pEnd = Point3d(-D_SS-LS+dR1s,((H/2)+dR1c),0) + pCentr = Point3d(-D_SS-LS-dR1,((H/2)+R1),0) + DrawAddCircleDrawCircle( pCentr, R1, -90,(90-AS), Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddCircleDrawCircle( pCentr, R1, -90,(90-AS), Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + else + pEnd = Point3d((-D_SS-LS),(H/2),0) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + if nMode == 1 then + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + end + pIni = pEnd + end + + -- risalita dente + pEnd = Point3d((-D_SS-LS+dLS),(H3+(H/2)),0) + if nMode == 1 then + pEnd_c = Point3d((-D_SS-LS+dLS),(H3+(H/2)),0) + pEnd = Point3d((-D_SS-LS+dLS5),(H5r+(H/2)),0) + DrawAddLineDrawCircle( pIni, pEnd_c, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + pIni_c = pEnd_c + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPath, bPreview, Dm, 0, false, false, RED(), RED()) + pIni = pEnd + end + + if nMode == 2 then -- se modalità percorsi aperti + -- creo primo percorso + nPath2 = EgtCurveCompo( Lg, tPath, true) + else -- percorso chiuso + + pEnd_c = Point3d((-D_SS-dLS),(H3+(H/2)),0) + DrawAddLineDrawCircle( pIni_c, pEnd_c, Lg, tPath2, bPreview, Dm, 0, false, false, RED(), RED()) + + -- creo primo percorso + nPath1 = EgtCurveCompo( Lg, tPath, true) + -- creo secondo percorso + nPath2 = EgtCurveCompo( Lg, tPath2, true) + end + + return nPath1, nPath2 +end + +-- Funzione di disegno +function StrikeC.Draw( EC, EM, tStrikeParam, bPreview, bRunByCompo, nDrawMach, Pz, Lg, dThickDoor) + + -- Assegno le dimensioni + local L = tStrikeParam.L + local H = tStrikeParam.H + local T = tStrikeParam.T + local rf = tStrikeParam.rf + local cl = tStrikeParam.cl + local d = tStrikeParam.d + local p = tStrikeParam.p + local sf = tStrikeParam.sf + local jn = tStrikeParam.jn + local L2 = tStrikeParam.L2 + local H2 = tStrikeParam.H2 + local invG = tStrikeParam.invG + local est = tStrikeParam.est + local D_X = tStrikeParam.D_X + local D_Y = tStrikeParam.D_Y + local LS = tStrikeParam.LS + local HS = tStrikeParam.HS + local AS = tStrikeParam.AS + local IS = tStrikeParam.IS + local D_SS = tStrikeParam.D_SS + local R1 = tStrikeParam.rs + local d2 = tStrikeParam.da + local mkrev = tStrikeParam.mkrev + -- Assegno i nomi geometrie + local LG = tStrikeParam.LG + local LM = tStrikeParam.LM + local LA = tStrikeParam.LA + local DM = 'DUMMY' + -- variabili per messaggi e settaggi vari + local sCompoName = tStrikeParam.Nome + + -- settaggio opzione per partenza ad angolo o meno + local bStartAng = true + local bStartOppo = true + + -- RunByComponetInterface + local RC = true + + if not bRunByCompo then -- controllo se lanciato da componente + RC = false + end + + -- 0 solo geom esterna, 1 solo geom mach, 2 entrambe + if not nDrawMach then -- se non definita la setto per non creare geometria di lavorazione + nDrawMach = 0 + end + + -- set variabili per compatibilità con vecchi componenti + -- step face: per compatibilità con tutti i componenti, se non è definito lo setto = alla profondità cava + if not sf or abs(sf) <= GEO.EPS_SMALL then + sf = T + end + + -- rf 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 cl == 0 then + rf = 0 + end + + if not D_Y then + D_Y = 0 + end + + -- single radius on face: per compatibilità con tutti i componenti, se non è definito lo setto a 0 + if not R1 or abs(R1) <= GEO.EPS_SMALL then + R1 = 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) -- layer disegni cerchi rappresentatte il diametro utensile + EgtSetName(Dm,DM) + end + + local hint1, hint2, hint3, hint4, hint5 + local hintPk, hintAs1, hintAs2, hintAs3, hintAs4, hintPk_r + local pIni, pEnd, pCentr + + -- creo lo stesso la geometria esterna perchè viene utilizzata anche per creare il percorso di lavorazione + -- se non è previsto viene eliminato dopo + + local H3 = HS + local nMode = 2 -- make open/s path + local dLS = HS * tan(AS) + + if est then + nMode = 1 -- make closed path + H3 = HS+(d/2)+ dExtraH + end + -- creo percorsi geometrici per eventuale chisel + hint1, hint2 = DrawExternalPath( Lg, D_SS, L, LS, H, H3, IS, AS, R1, rf, nMode, HS, Dm) + + if hint1 then + if est then + EgtErase(hint1) + hint1 = nil + else + EgtModifyCurveThickness( hint1, -T) + EgtSetName( hint1, LG) + end + end + + if hint2 then + EgtModifyCurveThickness( hint2, -T) + EgtSetName( hint2, LG) + end + + --------------------------------------- + --------------------------------------- + -- Costruzione delle geometrie di lavorazione + --------------------------------------- + --------------------------------------- + if nDrawMach > 0 then -- se abilitata geometria lavorazione + + local tPocket = {} + local tPocket_r = {} + local tPocketAs = {} + local tPocketAs_r = {} + local pIni , pEnd + local nCase1, nCase2 + local nCase, nCaseNext + local dZedStart, dZedWork + local dRadius, hint_ofs, hint_ofs_c, hint_ofs_r, hint_ofs2, hint_ofs2_r, num_hint_o2, num_hint_o2_r + local pIni_r, pEnd_r + local nStep + local dStep + local nPass + local pStartStep + local pStartStep_r + + if not Lg then + Lg = EgtGroup(Pz,GDB_RT.LOC) + EgtSetName(Lg,sCompoName) + end + + -- geometria antischeggia + if d2 then -- se parametro valido + + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + nPass = 1 + dZedStart = 0 + local tMVar = {} + local tMVar_r = {} + local nConEnt + local sKindVar + local dPosY, dEndPosY, dIniPosY, dDeltaPosX, dCompoRadTool + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + if nStep == 1 then + dZedWork = 0 + else + dZedWork = -T + end + end + + if bStartAng then -- se lead-in con angolo + + dEndPosY = -(d2/4) + dPosY = dEndPosY + (d2/8) + dIniPosY = dPosY + (d2*7/8) + dDeltaPosX = ( (d2*7/8) / tan(30)) + dCompoRadTool = (d2/2)/cos(AS) + + -- linea inclinata entrante fino all'incrocio con linea discendente dislocata di 0.2 + pIni = Point3d((((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))+dDeltaPosX)*invG, dIniPosY, dZedWork) + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))*invG, dPosY,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- discesa con linea inclinata disassata di 0.2 + pIni = pEnd + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS)))*invG, (dEndPosY-(((d2/2)+0.2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- accostamento di 0.2mm sul profilo + pIni = pEnd + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- linea uscente + pIni = pEnd + pEnd = Point3d(((d2*3/4)*tan(AS))*invG, (d2*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d((((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))+dDeltaPosX)*invG, pIni:getY(), dZedWork) + + if mkrev then -- se abilitato anche il percorso inverso + + -- linea inclinata entrante fino all'incrocio con linea discendente dislocata di 0.2 + pIni_r = Point3d(-(((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))+dDeltaPosX)*invG, dIniPosY,dZedWork) + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))*invG, dPosY,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- discesa con linea inclinata disassata di 0.2 + pIni_r = pEnd_r + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS)))*invG, ((dEndPosY-(((d2/2)+0.2)*sin(AS)))),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- accostamento di 0.2mm sul profilo + pIni_r = pEnd_r + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, ORANGE(), ORANGE()) + + -- linea uscente + pIni_r = pEnd_r + pEnd_r = Point3d(-((d2*3/4)*tan(AS))*invG, (d2*3/4),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d(-(((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS))-((dEndPosY-(((d2/2)+0.2)*sin(AS))-dPosY)*tan(AS)))+dDeltaPosX)*invG, pIni_r:getY(),dZedWork) + end + else -- lead-in diritto + + dEndPosY = -(d2/4) + dIniPosY = (d2*3/4) + dCompoRadTool = (d2/2)/cos(AS) + + if nStep == 1 then + -- linea entrante in Y + pIni = Point3d((dIniPosY*tan(AS))*invG, dIniPosY,dZedWork) + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + -- linea entrante in Y distaccata di 0.2mm + pIni = Point3d(((dIniPosY*tan(AS))+(0.2/cos(AS)))*invG, dIniPosY,dZedWork) + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS)))*invG, (dEndPosY-(((d2/2)+0.2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- accostamento sul lato profilo + pIni = pEnd + pEnd = Point3d(((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- risalita in Y + pIni = pEnd + pEnd = Point3d(((d2*3/4)*tan(AS))*invG, (d2*3/4),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocketAs, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni = pEnd + pEnd = Point3d(((dIniPosY*tan(AS))+(0.2/cos(AS)))*invG, pIni:getY(),dZedWork) + end + + if mkrev then -- se abilitato anche il percorso inverso + + if nStep == 1 then + -- linea entrante in Y + pIni_r = Point3d(-(dIniPosY*tan(AS))*invG, dIniPosY,dZedWork) + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + else + -- linea entrante in Y distaccata di 0.2mm + pIni_r = Point3d(-((dIniPosY*tan(AS))+(0.2/cos(AS)))*invG, dIniPosY,dZedWork) + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+(((d2/2)+0.2)*cos(AS)))*invG, (dEndPosY-(((d2/2)+0.2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- accostamento al profilo + pIni_r = pEnd_r + pEnd_r = Point3d(-((dEndPosY*tan(AS))-dCompoRadTool+((d2/2)*cos(AS)))*invG, (dEndPosY-((d2/2)*sin(AS))),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + -- risalita in Y + pIni_r = pEnd_r + pEnd_r = Point3d(-((d2*3/4)*tan(AS))*invG, (d2*3/4),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), true, true, ORANGE(), ORANGE()) + + pIni_r = pEnd_r + pEnd_r = Point3d(-((dIniPosY*tan(AS))+(0.2/cos(AS)))*invG, pIni_r:getY(),dZedWork) + end + 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 mkrev then -- se abilitato anche il percorso inverso + pIniLoc = pEnd_r + pEnd_r = Point3d(pIniLoc:getX(), pIniLoc:getY(), (dZedStart - dStep)) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocketAs_r, bPreview, Dm, (d2/2), false, true, + ORANGE(), ORANGE(), sMaxFeed) + table.insert( tMVar_r, {nConEnt,sKindVar}) + end + end + end -- end while + + -- trasformo in geometria composita + if ( #tPocketAs > 0) then + hintAs1 = EgtCurveCompo( Lg, tPocketAs, true) + if hintAs1 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs1, -T) + else + 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 + EgtSetName(hintAs1,LA) + -- muovo il percorso nella posizione corretta + if invG > 0 then + EgtMove( hintAs1, Point3d((-D_SS-LS+dLS+((d2/2)/cos(AS))),((H/2)+HS),0) - ORIG()) + else + EgtMove( hintAs1, Point3d((-D_SS-dLS-((d2/2)/cos(AS))),((H/2)+HS),0) - ORIG()) + end + -- faccio la copia se ha doppio dente + if IS > 0 then + hintAs3 = EgtCopyGlob( hintAs1, Lg) + EgtMove( hintAs3, Point3d(-IS,0,0) - ORIG()) + end + end + end + + if ( #tPocketAs_r > 0) then + hintAs2 = EgtCurveCompo( Lg, tPocketAs_r, true) + if hintAs2 then + if nStep == 1 then + EgtModifyCurveThickness(hintAs2, -T) + else + EgtModifyCurveThickness( hintAs2, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintAs2, 'MVar', sListEnt) end + end + EgtSetName(hintAs2,(LA..'_R')) + -- muovo il percorso nella posizione corretta + if invG > 0 then + EgtMove( hintAs2, Point3d((-D_SS-dLS-((d2/2)/cos(AS))),((H/2)+HS),0) - ORIG()) + else + EgtMove( hintAs2, Point3d((-D_SS-LS+dLS+((d2/2)/cos(AS))),((H/2)+HS),0) - ORIG()) + end + -- faccio la copia se ha doppio dente + if IS > 0 then + hintAs4 = EgtCopyGlob( hintAs2, Lg) + EgtMove( hintAs4, Point3d(-IS,0,0) - ORIG()) + end + end + end + end + + --------------------------------------- + -- geometria svuotatura giro esterno + --------------------------------------- + + if not est then -- se non c'è lavorazione steel + + -- creo percorso per offset + H3 = HS+(d/2)+ dExtraH + local dLS = HS * tan(AS) + local H5 = HS + nMode = 1 -- make close path + hint3, hint4 = DrawExternalPath( Lg, D_SS, L, LS, H, H3, IS, AS, R1, rf, nMode, H5, Dm) + + -- individuo in che caso sono considerando l'altezza dello strike + local dDimMin = H+HS + local dDimMinLs = LS + if (dDimMin-(d/2)+dExtraH) <= ( d*0.98) then -- solo passaggio di contornatura + nCase1 = 2 + elseif ((dDimMin-(d/2)+dExtraH) > ( d*0.98)) and ((dDimMin-(d/2)+dExtraH) <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase1 = 3 + elseif (dDimMin-(d/2)+dExtraH) > (d*(1+p)) then -- passaggio di contornatura + passaggi offset + nCase1 = 4 + end + -- individuo in che caso sono considerando la larghezza del dente dello strike + if dDimMinLs <= ( d*0.98) then -- solo passaggio di contornatura + nCase2 = 2 + elseif (dDimMinLs > ( d*0.98)) and (dDimMinLs <= (d*(1+p))) then -- passaggio di contornatura + un passaggio centrale + nCase2 = 3 + elseif dDimMinLs > (d*(1+p)) then -- passaggio di contornatura + passaggi offset + nCase2 = 4 + end + + nCase = max( nCase1, nCase2) + + local nDirVers = 1 + local tMVar = {} + local tMVar_r = {} + local nConEnt + local sKindVar + -- resetto contatori entità + nTotContEnt = 0 + nTotContEnt_r = 0 + -- calcolo il massimo tra altezza strike e larghezza dente + dRadius = max( dDimMin/2, LS/2) + nPass = 1 + dZedStart = 0 + nStep = ceil(T/sf) -- numero di passate + dStep = (T/nStep) -- passo ricalcolato + + while nPass <= nStep do + + dZedWork = dZedStart - dStep + if nPass == nStep then + dZedWork = -T + end + + -- solo contornatura o contornatura + un passaggio centrale o contornatura + passaggi svuotatura + if ( nCase == 2) or ( nCase == 3) or ( nCase == 4) then + + -- calcolo l'ampiezza dell'offset + dRadius = dRadius - (d/2) + + -- offset sul percorso aperto per il primo giro e chiuso per gli offset successivi + hint_ofs = EgtOffsetCurveAdv( hint3, (d/2), GDB_OT.FILLET) + hint_ofs_c = EgtOffsetCurveAdv( hint4, (d/2), GDB_OT.FILLET) + + if hint_ofs and hint_ofs > 0 then + + if mkrev then -- se abilitato anche il percorso inverso + -- copia del percorso offsettato + hint_ofs_r = EgtCopyGlob( hint_ofs, Lg) + end + + -- 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 bStartOppo then + if invG > 0 then + pIni = Point3d((-D_SS-LS+dLS+(d/2)+0.2)*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d((-D_SS-LS+dLS+(d/2)+0.2)*invG,(HS+(H/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((-D_SS-dLS-(d/2))*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni, Point3d( pIni:getX(), pEnd:getY(), dZedWork), Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = Point3d( pIni:getX(), pEnd:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + else + pIni = Point3d((D_SS+dLS+(d/2)+0.2)*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + -- linea in Y con centro utensile fuori + pEnd = Point3d((D_SS+dLS+(d/2)+0.2)*invG,(HS+(H/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((D_SS+LS-dLS-(d/2))*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + -- linea entrante a prendere il percorso di offset + pIni = pEnd + pEnd = EgtSP( hint_ofs) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni, Point3d( pIni:getX(), pEnd:getY(), dZedWork), Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = Point3d( pIni:getX(), pEnd:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + else + if invG > 0 then + -- prima linea entrante + pIni = Point3d((-D_SS-dLS-(d/2))*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni, Point3d( pIni:getX(), pEnd:getY(), dZedWork), Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = Point3d( pIni:getX(), pEnd:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + else + -- prima linea entrante + pIni = Point3d((D_SS+LS-dLS-(d/2))*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep = pIni + pEnd = EgtSP( hint_ofs) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni, Point3d( pIni:getX(), pEnd:getY(), dZedWork), Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pIni = Point3d( pIni:getX(), pEnd:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, RED(), RED()) + pEnd = EgtEP( hint_ofs) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, hint_ofs) + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- muovo la geometria in Z + EgtMove( hint_ofs_r, Point3d(0,0,dZedWork) - ORIG()) + + -- se flag non inverso, inverto la geometria, solo qui non nelle altre copie + if invG > 0 then + EgtInvertCurve(hint_ofs_r) + end + + if bStartOppo then + if invG > 0 then + pIni_r = Point3d((-D_SS-dLS-(d/2)-0.2)*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + -- linea in Y con centro utensile fuori + pEnd_r = Point3d((-D_SS-dLS-(d/2)-0.2)*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-LS+dLS+(d/2))*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea entrante a prendere il percorso di offset + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs_r) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni_r, Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork), Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + else + pIni_r = Point3d((D_SS+LS-dLS-(d/2)-0.2)*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + -- linea in Y con centro utensile fuori + pEnd_r = Point3d((D_SS+LS-dLS-(d/2)-0.2)*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea traversa in X per andare sul vecchio punto iniziale (in X) + pIni_r = pEnd_r + pEnd_r = Point3d((D_SS+dLS+(d/2))*invG,(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + -- linea entrante a prendere il percorso di offset + pIni_r = pEnd_r + pEnd_r = EgtSP( hint_ofs_r) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni_r, Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork), Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + else + if invG > 0 then + -- prima linea entrante + pIni_r = Point3d((-D_SS-LS+dLS+(d/2))*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + pEnd_r = EgtSP( hint_ofs_r) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni_r, Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork), Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + else + -- prima linea entrante + pIni_r = Point3d((D_SS+dLS+(d/2))*invG,(HS+(H/2)+(d*3/4)),dZedWork) + pStartStep_r = pIni_r + pEnd_r = EgtSP( hint_ofs_r) + -- in base all'angolo del dente, mi collego direttamente o prima scendo in Y + if AS > 0 then + -- scenso solo in Y + DrawAddLineDrawCircle( pIni_r, Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork), Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pIni_r = Point3d( pIni_r:getX(), pEnd_r:getY(), dZedWork) + end + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, RED(), RED(), nil, 1) + pEnd_r = EgtEP( hint_ofs_r) + end + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + end + end + end + + if nCase == 3 then -- passaggio di contornatura + un passaggio centrale + + -- linea posizionamento passata centrale + pIni = pEnd + pEnd = Point3d((-D_SS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + + -- linee passata centrale + pIni = pEnd + pEnd = Point3d((-D_SS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d(-(d*3/4),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + if IS > 0 then + pEnd = Point3d((-D_SS-IS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d((-D_SS-IS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d((-D_SS-IS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + pEnd = Point3d((-L+(d*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd = Point3d((-D_SS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + pEnd = Point3d((-D_SS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW()) + pIni = pEnd + end + + if mkrev then -- se abilitato anche il percorso inverso + + -- linea posizionamento passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + + -- linee passata centrale + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d(-(d*3/4),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + if IS > 0 then + pEnd_r = Point3d((-D_SS-IS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-IS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-IS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + + pEnd_r = Point3d((-L+(d*3/4)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + + -- se non sono all'ultima passata ritorno al punto di inizio della passata centrale, + -- si perde un po' di tempo ma è l'unica per poter rifare il passo + if nPass < nStep then + + pEnd_r = Point3d((-D_SS-(LS/2)),0,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + pEnd_r = Point3d((-D_SS-(LS/2)),(HS+(H/2)+dExtraH),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), true, true, YELLOW(), YELLOW(), nil, 1) + pIni_r = pEnd_r + end + end + elseif nCase == 4 then -- passaggio di contornatura + passaggi svuotatura + + local dDistYcentr = (d*p) + local dDistYApply = dDistYcentr + local bContinue + + -- se percorso offset esiste + if hint_ofs_c and hint_ofs_c > 0 then + + -- muovo la geometria in Z + EgtMove( hint_ofs_c, Point3d(0,0,dZedWork) - ORIG()) + + -- se flag inverso, inverto la geometria, solo qui non nelle altre copie + if invG < 0 then + EgtInvertCurve(hint_ofs_c) + end + + hint5 = hint_ofs_c + + -- faccio l'offset del raggio fresa + dRadius = dRadius - dDistYcentr + bContinue = dRadius > 0 + local bCalcDir = true + + -- se percorso offset esiste + while bContinue do + + hint_ofs2, num_hint_o2 = EgtOffsetCurveAdv( hint_ofs_c, dDistYApply*invG, GDB_OT.FILLET) + + if hint_ofs2 and hint_ofs2 > 0 then + + pIni = pEnd + + local nStartPath = hint_ofs2 + local nIncIndex = 1 + + -- se ottengo più di una curva determino quale è più distante tra la prima e l'ultima + if bCalcDir and num_hint_o2 > 1 then + + bCalcDir = false + local nFirstP = hint_ofs2 + local nLastP = hint_ofs2 + ( num_hint_o2 - 1) + local nDistIni = dist( pIni, EgtSP( nFirstP)) + local nDistLast = dist( pIni, EgtSP( nLastP)) + -- se la prima curva è più lontana dall'inizio, inverto il valore di DX tramite il semi interasse passato + if nDistIni >= nDistLast then + nStartPath = nLastP + nIncIndex = -1 + end + end + + -- linea congiunzione tra offset + pEnd = EgtSP( nStartPath) + -- vado a X nuovo punto + DrawAddLineDrawCircle( pIni, Point3d( pEnd:getX(), pIni:getY(), pIni:getZ()), Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + -- congiungo a offset + DrawAddLineDrawCircle( Point3d( pEnd:getX(), pIni:getY(), pIni:getZ()), pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pEnd = EgtEP( nStartPath) + local ntypeDom, nNumCurve = EgtCurveDomain(nStartPath) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, nStartPath) + + -- per tutte le curve create + for i = 1, ( num_hint_o2 - 1) do + -- linea discesa a Y0 + pIni = pEnd + pEnd = Point3d( pEnd:getX(), 0, pEnd:getZ()) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + -- linea X prossima curva + pIni = pEnd + pEnd = EgtSP( nStartPath+(i*nIncIndex)) + DrawAddLineDrawCircle( pIni, Point3d( pEnd:getX(), 0, pEnd:getZ()), Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + -- linea congiunzione curva + pIni = Point3d( pEnd:getX(), 0, pEnd:getZ()) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW()) + pEnd = EgtEP( nStartPath+(i*nIncIndex)) + local ntypeDom, nNumCurve = EgtCurveDomain((nStartPath+(i*nIncIndex))) + nTotContEnt = nTotContEnt + ( nNumCurve - ntypeDom) + table.insert( tPocket, (nStartPath+(i*nIncIndex))) + end + + if mkrev then -- se abilitato anche il percorso inverso + + num_hint_o2_r = num_hint_o2 + + if nIncIndex > 0 then + nStartPath = hint_ofs2 + else + nStartPath = hint_ofs2 + (num_hint_o2_r-1) + end + + -- copia del percorso offsettato + hint_ofs2_r = EgtCopyGlob( nStartPath, Lg) + EgtInvertCurve(hint_ofs2_r) + + -- linea congiunzione tra offset + pIni_r = pEnd_r + + pEnd_r = EgtSP( hint_ofs2_r) + -- vado a X nuovo punto + DrawAddLineDrawCircle( pIni_r, Point3d( pEnd_r:getX(), pIni_r:getY(), pIni_r:getZ()), Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + -- congiungo a offset + DrawAddLineDrawCircle( Point3d( pEnd_r:getX(), pIni_r:getY(), pIni_r:getZ()), pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + pEnd_r = EgtEP( hint_ofs2_r) + hint_ofs_r = hint_ofs2_r + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + + for i = 1, ( num_hint_o2_r - 1) do + local nIdOf = EgtCopyGlob( (nStartPath+(i*nIncIndex)), Lg) + EgtInvertCurve(nIdOf) + -- linea discesa a Y0 + pIni_r = pEnd_r + pEnd_r = Point3d( pEnd_r:getX(), 0, pEnd_r:getZ()) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + -- linea X prossima curva + pIni_r = pEnd_r + pEnd_r = EgtSP( nIdOf) + DrawAddLineDrawCircle( pIni_r, Point3d( pEnd:getX(), 0, pEnd:getZ()), Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + -- linea congiunzione curva + pIni_r = Point3d( pEnd_r:getX(), 0, pEnd_r:getZ()) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), nil, 1) + pEnd_r = EgtEP( nIdOf) + hint_ofs_r = nIdOf + local ntypeDom, nNumCurve = EgtCurveDomain(hint_ofs_r) + nTotContEnt_r = nTotContEnt_r + ( nNumCurve - ntypeDom) + table.insert( tPocket_r, hint_ofs_r) + end + end + + -- calcolo nuovo passo in Y e indice direzione + dRadius = dRadius - dDistYcentr + dDistYApply = dDistYApply + dDistYcentr + bContinue = dRadius > 0 + else + bContinue = false + end + end -- end while + if hint5 then + EgtErase(hint5) + hint5 = nil + end + end + end + + if nPass == nStep then + + 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 mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + end + + if ( nCaseNext == 1) then -- se solo passaggio in centro parto dalla parte opposta + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni:getX() + pEnd = Point3d(nx,D_Y,dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + end + pEnd = Point3d(((-((L2-d)/2)*invG)-(L/2)+D_X),D_Y,dZedWork) + + if mkrev then -- se abilitato anche il percorso inverso + + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni_r:getX() + pEnd_r = Point3d(nx,D_Y,dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + pIni_r = pEnd_r + end + pEnd_r = Point3d(((((L2-d)/2)*invG)-(L/2)+D_X),D_Y,dZedWork) + end + else + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni:getX() + pEnd = Point3d(nx,(((H2-d)/2)+D_Y),dZedWork) + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + pIni = pEnd + end + pEnd = Point3d(((((L2-d)/2)*invG)-(L/2)+D_X),(((H2-d)/2)+D_Y),dZedWork) + + if mkrev then -- se abilitato anche il percorso inverso + if nCase ~= 3 then -- posso trovarmi in una Y alta e per raggiungere la mortasa taglio il percorso + local nx = pIni_r:getX() + pEnd_r = Point3d(nx,(((H2-d)/2)+D_Y),dZedWork) + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + pIni_r = pEnd_r + end + pEnd_r = Point3d(((-((L2-d)/2)*invG)-(L/2)+D_X),(((H2-d)/2)+D_Y),dZedWork) + end + end + + DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE()) + if mkrev then -- se abilitato anche il percorso inverso + DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, PURPLE(), PURPLE(), nil, 1) + end + end + end + end + + nPass = nPass + 1 + dZedStart = dZedStart - dStep + dRadius = dDimMin/2 + nDirVers = -nDirVers + + -- se ho altri passi torno al punto di inizio + if nPass <= nStep and nCase > 1 then + + pIni = pEnd + pEnd = Point3d(pStartStep:getX(),pStartStep:getY(),(dZedStart - dStep)) + -- salgo in Y + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, Point3d( pIni:getX(), pEnd:getY(), pIni:getZ()), Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,sKindVar}) + -- congiungo al punto di inizio + pIni = Point3d( pIni:getX(), pEnd:getY(), pIni:getZ()) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni, pEnd, Lg, tPocket, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed) + table.insert( tMVar, {nTotContEnt,sKindVar}) + + if mkrev then -- se abilitato anche il percorso inverso + pIni_r = pEnd_r + pEnd_r = Point3d(pStartStep_r:getX(),pStartStep_r:getY(),(dZedStart - dStep)) + -- salgo in Y + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, Point3d( pIni_r:getX(), pEnd_r:getY(), pIni_r:getZ()), Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, 1) + table.insert( tMVar_r, {nTotContEnt_r,sKindVar}) + -- congiungo al punto di inizio + pIni_r = Point3d( pIni_r:getX(), pEnd_r:getY(), pIni_r:getZ()) + _, nConEnt, sKindVar = DrawAddLineDrawCircle( pIni_r, pEnd_r, Lg, tPocket_r, bPreview, Dm, (d/2), false, true, YELLOW(), YELLOW(), sMaxFeed, 1) + table.insert( tMVar_r, {nTotContEnt_r,sKindVar}) + end + 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) + end + end + + if ( #tPocket_r > 0) then + hintPk_r = EgtCurveCompo( Lg, tPocket_r, true) + if hintPk_r then + EgtModifyCurveThickness(hintPk_r, 0) + -- assegno nota con la lista delle entità di variazione + local sListEnt = '' + for i = 1, #tMVar_r do + sListEnt = sListEnt .. '{ ent=' .. EgtNumToString( tMVar_r[i][1], 0) .. ', ' .. 'code=' .. tMVar_r[i][2] .. '}' + if i < #tMVar_r then + sListEnt = sListEnt .. ',' + end + end -- end for + if string.len( sListEnt) > 0 then EgtSetInfo( hintPk_r, 'MVar', sListEnt) end + EgtSetName(hintPk_r,(LM..'_R')) + end + end + + end + -- se variabile inversione negativa inverto la direzione del percorso geometrico principale + if invG < 0 then + if hint1 then + EgtInvertCurve(hint1) + end + if hint2 then + EgtInvertCurve(hint2) + end + end + end + + -- se abilitata solo geometria di lavorazione elimino il percorso di sola geometria + if nDrawMach == 1 then + if hint1 then + -- cancello il percorso + EgtErase( hint1) + hint1 = nil + end + if hint2 then + -- cancello il percorso + EgtErase( hint2) + hint2 = nil + end + end + + -- cambio colore alla geometria + if bPreview then + if EC == 0 then + if hint1 then + EgtSetColor(hint1,AQUA()) + end + if hint2 then + EgtSetColor(hint2,AQUA()) + end + if hintAs1 then + EgtSetColor(hintAs1,AQUA()) + end + if hintAs2 then + EgtSetColor(hintAs2,AQUA()) + end + if hintAs3 then + EgtSetColor(hintAs3,AQUA()) + end + if hintAs4 then + EgtSetColor(hintAs4,AQUA()) + end + if hintPk then + EgtSetColor(hintPk,AQUA()) + end + if hintPk_r then + EgtSetColor(hintPk_r,AQUA()) + end + else + if hint1 then + EgtSetColor(hint1,ORANGE()) + end + if hint2 then + EgtSetColor(hint2,ORANGE()) + end + if hintAs1 then + EgtSetColor(hintAs1,ORANGE()) + end + if hintAs2 then + EgtSetColor(hintAs2,ORANGE()) + end + if hintAs3 then + EgtSetColor(hintAs3,ORANGE()) + end + if hintAs4 then + EgtSetColor(hintAs4,ORANGE()) + end + if hintPk then + EgtSetColor(hintPk,ORANGE()) + end + if hintPk_r then + EgtSetColor(hintPk_r,ORANGE()) + end + end + else -- altrimenti non Preview + -- muovo tutti i percorsi di metà lunghezza + if EC == 0 then + if hint1 then + EgtMove( hint1, Point3d((L/2),0,0) - ORIG()) + end + if hint2 then + EgtMove( hint2, Point3d((L/2),0,0) - ORIG()) + end + if hintAs1 then + EgtMove( hintAs1, Point3d((L/2),0,0) - ORIG()) + end + if hintAs2 then + EgtMove( hintAs2, Point3d((L/2),0,0) - ORIG()) + end + if hintAs3 then + EgtMove( hintAs3, Point3d((L/2),0,0) - ORIG()) + end + if hintAs4 then + EgtMove( hintAs4, Point3d((L/2),0,0) - ORIG()) + end + if hintPk then + EgtMove( hintPk, Point3d((L/2),0,0) - ORIG()) + end + if hintPk_r then + EgtMove( hintPk_r, Point3d((L/2),0,0) - ORIG()) + end + end + + -- elimino i percorsi non necessari + if hint3 then EgtErase(hint3) end + if hint4 then EgtErase(hint4) end + if hint5 then EgtErase(hint5) end + + -- cancello le parti ausiliarie se disegnate + if Dm then + EgtErase(Dm) + end + -- assegno nota su percorsi antisplint e svuotatura + if hintPk then + EgtSetInfo( hintPk, 'NotCheckDir', '1') + end + if hintAs1 then + EgtSetInfo( hintAs1, 'NotCheckDir', '1') + end + if hintAs2 then + EgtSetInfo( hintAs2, 'NotCheckDir', '1') + end + if hintAs3 then + EgtSetInfo( hintAs3, 'NotCheckDir', '1') + end + if hintAs4 then + EgtSetInfo( hintAs4, 'NotCheckDir', '1') + end + if hintPk_r then + EgtSetInfo( hintPk_r, 'NotCheckDir', '1') + end + end + + return hint1, hintPk, hint2, hintAs1, hintAs2, hintAs3, hintAs4, hintPk_r +end + + +return StrikeC diff --git a/Machining.lua b/Machining.lua new file mode 100644 index 0000000..f706cda --- /dev/null +++ b/Machining.lua @@ -0,0 +1,560 @@ +-- +-- 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 +-- +-- Machining.lua by EgalWare s.r.l. 2016.23.05 +-- Machining generation for Doors program + +-- 2018.11.06 V1.001 FM Check bevel profiles on top and bottom door side +-- 2019.01.16 V1.002 FM fix error into FindGroupNameWithInfo +-- 2019.02.08 V2.001 FM Change release to 2 by new EgtCam5 Release +-- 2019.02.08 V2.002 FM Manage error in case Post processor (Machining_xx) file not defined +-- 2019.07.02 V2.003 FM Add at the end, library reset commands for DoorsLib and EgtDoorsBase +-- 2020.05.29 V2.004 FM Force single jambs dispsotion when material is aluminum +-- 2021.07.06 V2.005 FM Manage show error messages in case the mtable info not match with corrent EgtDoor configuration +-- 2021.07.06 V2.005 FM Manage show error messages in case run Dmach with empty piece or not saved piece +-- 2022.07.27 V2.006 FM Modification to use compiled code +-- 2024.07.24 V2.007 FM By CurrcamInfo parameter (MakeSentinelFileWhenNoMach) add to write sentinel file if there are not machining +-- 2024.10.15 V2.008 FM Manage better when there is no machining on a machine to crerate a right .tok file +-- 2024.11.20 V2.009 DS If Machining runs by DMACH set as current the 1st machining group +-- 2025.01.17 V2.00a FM Manage .ini parameter 'OptimizeMachForLine' to enable machining adjustment for line machines + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +if not _G.DGD then + _G.DGD = {} +end + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') + +local OptimizeMach = false + +----------------------------------------------------------------- +-- *** Sentinel write file *** +----------------------------------------------------------------- +local function WriteSntFile( sFileErr, sDispMsg) + if sDispMsg and #sDispMsg > 0 then + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + nIdFile:write('\n' .. sDispMsg) + nIdFile:close() + end + end +end + +local function FindGroupNameWithInfo( sGroupName, sNameInfo) + + -- cerco il primo pezzo con il nome passato + local Pz = EgtGetFirstNameInGroup( GDB_ID.ROOT, sGroupName) + local Pzi = Pz + local sAssemblyName + local sDoorName + local bNotProduce + + while Pz do + + -- verifico se la nota di produzione è per non produrre il pezzo + bNotProduce = EgtGetInfo( Pz, 'Produce', 'i') == 0 + + -- cerco se il pezzo ha l'info desiderata + sAssemblyName = EgtGetInfo( Pz, 'Assembly') + if sAssemblyName and sAssemblyName == sNameInfo then + if bNotProduce then + return nil, nil + else + return Pz, sAssemblyName + end + elseif not sAssemblyName then -- se non ho un nome di assemblato + if bNotProduce then + return nil, nil + end + sDoorName = EgtGetInfo( Pz, 'N') + end + Pz = EgtGetNextName( Pz, sGroupName) + end + + return Pz, sAssemblyName, Pzi, sDoorName +end + +-- Librerie di lavorazione +EgtAddToPackagePath( sBaseDir .. '?.lua') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +-- variabile presentazione dialogo +local bEnAssemblyDispos = false + +----------------------------------------------------------------------------------- +-- se machining lanciato DMACH chiedo se si vuole la generazione o la disposizione +if not DGD.NCGEN then + + -- se dialogo abilitato + if bEnAssemblyDispos then + + local tsMode = EgtDialogBox( ' 0 = pieces disposition, 1 = machines pieces', {'Choice:', '1'}) + local sMode = '1' + + if tsMode then + sMode = tsMode[1] + end + + -- se scelta di disposizione pezzi + if sMode == '0' then + local sPathAssemb = sBaseDir .. 'LuaLibs\\' .. 'Main_Assemb_I.lua' + local bOkDisp = dofile( sPathAssemb) + return bOkDisp + end + end +end + +-- Librerie di lavorazione +EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') +require( 'CurrDoorsCustomData') + +local MB = require( 'MachiningBase') + +-- Reset dati custom +ResetDoorsCustomData() + +-- nome componente machining di default +local sCompoMachining = 'Machining_1' + +-- nome file dati cam +local sPathCurrMachtabOri = sBaseDir..'CurrCamInfo'..'.lua' +local mCamData + +-- Project path, name, extension +local sFilePath = EgtGetCurrFilePath() +if not sFilePath then + EgtOutText( EgtDoorsMsg[694]) + -- se machining lanciato DMACH visualizzo errore + if not DGD.NCGEN then + EgtOutBox( EgtDoorsMsg[694], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false +end +local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) +local sLogFile = sFileDir .. sFileName .. '.log' + +-- se machining lanciato DMACH +if not DGD.NCGEN then + -- open log file in append + OpenLogFile(sLogFile, 'a') +end + +-- --------------------------------------------------------------------------------------------- +-- verifico parametro ini per gestione ottimizzazione lavorazioni macchine in linea +-- --------------------------------------------------------------------------------------------- + +-- ottengo il file ini dell'egtcam5 +local sConfigFolder = EgtGetIniFile() + +-- ottengo parametro +local nTemp = EgtGetNumberFromIni( 'DOORS', 'OptimizeMachForLine', 0, sConfigFolder) +OptimizeMach = EgtIf( nTemp > 0, true, false) + +-- --------------------------------------------------------------------------------------------- +-- --------------------------------------------------------------------------------------------- + + +-- verifico se esiste il file +if EgtExistsFile( sPathCurrMachtabOri) then + -- utilizzo la tabella + sPathCurrMachtabOri = 'CurrCamInfo' + mCamData = require( sPathCurrMachtabOri) +else + DoorOutLog( string.format(EgtDoorsMsg[487], '', sPathCurrMachtabOri), 0) -- File non trovato + EgtOutText( string.format(EgtDoorsMsg[487], '', sPathCurrMachtabOri)) + -- se machining lanciato DMACH chiudo file log + if not DGD.NCGEN then CloseLogFile() end + return false +end + +-- Resetto i gruppi lavorazioni se esistono +local nMchId = EgtGetFirstMachGroup() +while nMchId do + EgtRemoveMachGroup( nMchId) + nMchId = EgtGetFirstMachGroup() +end + +local bOk = false +-- nomi pezzi da cercare e nomi delle note per le porte +local sPieceName = 'DOO*' +local sFindNote = 'first' +local MachJambTogh = 0 +local nLocNumGroup +-- variabile per lancio disposizione pezzi assemblato +local bFirstCheckDisp = true +local nIdProcessedPiece = 0 + +repeat -- ripeti per tutti i pezzi trovati + + -- determino il pezzo dell'assemblato o pezzo unico + local Pz = {} + local Pz2 = {} + local tFoundAssembly = {} + local tFoundAssembly2 = {} + local sFoundAssembly + local sFoundDoor + local Pzi, Pii + + -- ricavo id pezzo e se è assemblato + Pii, sFoundAssembly, Pzi, sFoundDoor = FindGroupNameWithInfo( sPieceName, sFindNote) + + if sFoundAssembly then + table.insert( Pz, Pii) + else + if nIdProcessedPiece ~= Pzi then + nIdProcessedPiece = Pzi + table.insert( Pz, Pzi) + end + end + table.insert( tFoundAssembly, sFoundAssembly) + + if #Pz > 0 then -- se il pezzo è valido + + if bFirstCheckDisp and bEnAssemblyDispos then + local sPathAssemb = sBaseDir .. 'LuaLibs\\' .. 'Main_Assembly.lua' + local MHgen = require('Main_Assembly') + -- lancio funzione main del componente + bOk = MHgen.main(0) -- passo il parametro per disporre l'assemblato sul piano + bFirstCheckDisp = false + end + + local MachiningsTable = EgtGetInfo( Pz[1], 'MTable') + local MachiningsPath = EgtGetInfo( Pz[1], 'MTablePath') + local sDoorMaterial = EgtGetInfo( Pz[1], 'Material') + local bAlumDoor = FindMaterial( sDoorMaterial, 'aluminum') -- per aluminum doors + + -- se nome tabella non esiste esco subito + if not MachiningsTable then + + DoorOutLog( EgtDoorsMsg[499], 0) -- Errore nel file cam + EgtOutText( EgtDoorsMsg[499]) + -- se machining lanciato DMACH chiudo file log + if not DGD.NCGEN then CloseLogFile() end + return bOk + -- altrimenti controllo se esiste il file della mtable + else + local sMtableFile = sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl' + if not EgtExistsFile( sMtableFile) then + DoorOutLog( string.format(EgtDoorsMsg[692], sMtableFile, sBaseDir), 0) -- Mtable non trovata + EgtOutText( string.format(EgtDoorsMsg[692], sMtableFile, sBaseDir)) + -- se machining lanciato DMACH chiudo file log + if not DGD.NCGEN then + EgtOutBox( string.format(EgtDoorsMsg[692], sMtableFile, sBaseDir), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + CloseLogFile() + end + return bOk + end + -- verifico anche il percorso della Mtable se corrisponde + sMtableFile = sBaseDir .. 'MTables\\' + if string.lower(sMtableFile) ~= string.lower(MachiningsPath) then + DoorOutLog( string.format(EgtDoorsMsg[693], sMtableFile, sBaseDir), 0) -- percorso Mtable non corrispondente + EgtOutText( string.format(EgtDoorsMsg[693], sMtableFile, sBaseDir)) + -- se machining lanciato DMACH chiudo file log + if not DGD.NCGEN then + EgtOutBox( string.format(EgtDoorsMsg[693], MachiningsPath, sMtableFile), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + CloseLogFile() + end + return bOk + end + end + + local M = require( MachiningsTable) + local MachinesName = M.MMachineData + local MTablePrev = M.MTable + local nNumMach + local nNumGroup = 0 + local tListCompo = {} + local nNoMach + + -- per ogni macchina presente in MTable + for j = 1, #MachinesName do + + -- inizializzo la variabile dei messaggi di errore + if not DGD.NCGEN then + DGD.ERR = nil + DGD.EMC = '' + DGD.ERM = '' + end + + nNumMach = 0 + MachJambTogh = 0 + -- verifico se il nome macchina è presente nel file CurrCamInfo + -- e se c'è il parametro per lavorare i jamb assieme + for i = 1, #mCamData do + + if string.lower( MachinesName[j].MachName) == string.lower(mCamData[i].MachName) then + nNumMach = i + if mCamData[i].MachineJambsTogether then + MachJambTogh = mCamData[i].MachineJambsTogether + end + end + end + + -- se porta di alluminio per ora forzo la disposizione singola + if bAlumDoor then MachJambTogh = 0 end + + -- abilitata lavorazione pezzi jamb assieme + if MachJambTogh == 1 then + + -- se pezzo passato non è una porta cerco gli altri pezzi + if sPieceName ~= 'DOO*' then + + -- carico tutti i pezzi frame nella tabella + while sFindNote ~= '' and sFindNote ~= 'framebot' do + + -- se pezzo valido e non è una porta cerco il frame successivo al sinistro + if sFindNote == 'framesx' then + sFindNote = 'framedx' + sPieceName = 'FRAME*' + elseif sFindNote == 'framedx' then + sFindNote = 'frametop' + sPieceName = 'FRAME*' + elseif sFindNote == 'frametop' then + sFindNote = 'framebot' + sPieceName = 'FRAME*' + else + sFindNote = '' + end + + if sFindNote ~= '' and sFindNote ~= 'framebot' then + + Pii, sFoundAssembly, Pzi = FindGroupNameWithInfo( sPieceName, sFindNote) + if Pii then + table.insert( Pz, Pii) + table.insert( tFoundAssembly, sFoundAssembly) + end + elseif sFindNote == 'framebot' then -- il frame bottom lo faccio da solo + + Pii, sFoundAssembly, Pzi = FindGroupNameWithInfo( sPieceName, sFindNote) + if Pii then + table.insert( Pz2, Pii) + table.insert( tFoundAssembly2, sFoundAssembly) + end + end + end + end + end + + if nNumMach > 0 then + + -- imposto i dati macchina secondo le informazioni del file cam + sCompoMachining = mCamData[nNumMach].CompoMachining + local MachName = mCamData[nNumMach].MachName + + if sCompoMachining then + + DoorOutLog( ' Postprocessor used: ' .. sCompoMachining, 0) + + -- se ci sono lavorazioni nella Mtable per la macchina selezionata entro + -- MTable scanning + local sLocMachId + local bFoundmach = false + local bFoundmach2 = false + + for k = 1, #MTablePrev do + if MTablePrev[k].On ~= 0 then -- se non è disabilitata + + -- acquisisco numero macchine (se indicato), se non trovato setto macchina 1 ( per default nella Mtable) + sLocMachId = MTablePrev[k].MachId or 1 + + if sLocMachId == j then -- se numero macchina corrispondente + + -- Recupero le entità + local EntList = {} + local EntList2 = {} + local sNameMach = MTablePrev[k].Name + local sNameMach2 = MTablePrev[k].Name + -- se metodo assegnato è bevel verifico che siano coerenti con la dsposizione finale + if MTablePrev[k].Oper and MTablePrev[k].Oper == 'AdjustBevel' then + + EntList = MB.FindEntitiesWithName( Pz , sNameMach) + EntList2 = MB.FindEntitiesWithName( Pz2, sNameMach2) + if #EntList == 0 then -- se non trovata nessuna entità provo con l'opposta + local sTmpName = sNameMach + sNameMach = EgtIf( sNameMach == 'BU', 'BD','BU') + EntList = MB.FindEntitiesWithName( Pz, sNameMach) + if #EntList == 0 then -- se non trovata nessuna entità provo con quella di testa opposta + sNameMach = sTmpName + sNameMach = EgtIf( sNameMach == 'BU_H', 'BD_H','BU_H') + EntList = MB.FindEntitiesWithName( Pz, sNameMach) + end + end + if #EntList2 == 0 then -- se non trovata nessuna entità provo con l'opposta + local sTmpName2 = sNameMach2 + sNameMach2 = EgtIf( sNameMach2 == 'BU', 'BD','BU') + EntList2 = MB.FindEntitiesWithName( Pz2, sNameMach2) + if #EntList2 == 0 then -- se non trovata nessuna entità provo con quella di testa opposta + sNameMach2 = sTmpName2 + sNameMach2 = EgtIf( sNameMach2 == 'BU_H', 'BD_H','BU_H') + EntList2 = MB.FindEntitiesWithName( Pz2, sNameMach2) + end + end + -- se non ho metodi oppure se metodo non AdjustProbeMill o non AdjustProbeHole verifico se ho lavorazioni + elseif not MTablePrev[k].Oper or not ( MTablePrev[k].Oper == 'AdjustProbeMill' or MTablePrev[k].Oper == 'AdjustProbeHole') then + EntList = MB.FindEntitiesWithName( Pz , sNameMach) + EntList2 = MB.FindEntitiesWithName( Pz2, sNameMach2) + end + + -- se trovate entità associate a nome lavorazione + if #EntList > 0 then + bFoundmach = true + end + if #EntList2 > 0 then + bFoundmach2 = true + end + + -- siccome sono mutuamente esclusivi perchè il frame bottom (Pz2) è lavorato da solo + -- se una delle due è vera, ci sono delle lavorazioni per quel pezzo/i + if bFoundmach or bFoundmach2 then + break -- esco dal for appena ho trovato almeno una lavorazione + end + end + end + end + + if bFoundmach or bFoundmach2 then -- se ho delle lavorazioni sul pezzo/i + + -- metto in tabella il nome del componente lanciato per il forget + table.insert( tListCompo,sCompoMachining) + + if nLocNumGroup and nLocNumGroup > 0 then nNumGroup = nLocNumGroup end + + -- lancio il primo componente base + MHgen = require( sCompoMachining) + if bFoundmach then + bOk, nLocNumGroup, nNoMach = MHgen.Calc( Pz, tFoundAssembly, j, nNumMach, nNumGroup, OptimizeMach) + end + if bFoundmach2 then + bOk, nLocNumGroup, nNoMach = MHgen.Calc( Pz2, tFoundAssembly2, j, nNumMach, nNumGroup, OptimizeMach) + end + if nNoMach == 1 then + nLocNumGroup = nLocNumGroup - 1 + end + else + nNoMach = 1 + end + + -- se non ho lavorazioni + if nNoMach == 1 then + + local nPieceNum = EgtIf( #Pz == 1, Pz[1], 0) + if nPieceNum == 0 then + nPieceNum = EgtIf( #Pz2 == 1, Pz2[1], 0) + end + local sPieceName = EgtIf( #tFoundAssembly == 1, tFoundAssembly[1], '') + if #sPieceName < 1 then + sPieceName = EgtIf( #tFoundAssembly2 == 1, tFoundAssembly2[1], '') + end + if #sPieceName < 1 then + sPieceName = EgtIf( #sFoundDoor > 0, sFoundDoor, '') + end + DoorOutLog( string.format( EgtDoorsMsg[493], MachName, nPieceNum, sPieceName), 0) -- No machining for machine + if not DGD.NCGEN then + EgtOutBox( string.format(EgtDoorsMsg[493], MachName, nPieceNum, sPieceName), EgtDoorsMsg[501], EgtDoorsMsg[502]) + end + + -- CurrCamInfo option to generate sentinel file + local nGenSentinel = mCamData[nNumMach].MakeSentinelFileWhenNoMach or 0 + if nGenSentinel == 1 then + if nLocNumGroup and nLocNumGroup > 0 then nNumGroup = nLocNumGroup end + -- incremento il numero del gruppo + nNumGroup = nNumGroup + 1 + -- compongo il file sentinella (.tok) + local sNumGroup = EgtIf( nNumGroup > 1, '_' .. EgtNumToString( nNumGroup,0), '') + local sSentinelFileName = sFileDir..sFileName..sNumGroup..'.tok' + -- cancello il file tok + EgtEraseFile( sSentinelFileName) + WriteSntFile( sSentinelFileName, 'Err=0\n LIGHT=PURPLE\n \n No machining for this machine\n') + end + end + else + DoorOutLog( EgtDoorsMsg[640], 0) + if not DGD.NCGEN then + EgtOutBox( EgtDoorsMsg[640], EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + end + else + DoorOutLog( EgtDoorsMsg[641], 0) -- Machine name mismatch + if not DGD.NCGEN then + EgtOutBox( EgtDoorsMsg[641], EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + end + end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + for i = 1, #tListCompo do + package.loaded[tListCompo[i]] = nil + end + end + + -- effettuo la prossima ricerca + if sFindNote == 'first' then + sFindNote = 'second' + sPieceName = 'DOO*' + elseif sFindNote == 'second' then + sFindNote = 'framesx' + sPieceName = 'FRAME*' + elseif sFindNote == 'framesx' and MachJambTogh == 0 then + sFindNote = 'framedx' + sPieceName = 'FRAME*' + elseif sFindNote == 'framedx' and MachJambTogh == 0 then + sFindNote = 'frametop' + sPieceName = 'FRAME*' + elseif sFindNote == 'frametop' and MachJambTogh == 0 then + sFindNote = 'framebot' + sPieceName = 'FRAME*' + else + sFindNote = '' + end + +until sFindNote == '' + +-- ------------------------------------------------------------------------------------------------------------- +-- ------------------------------------------------------------------------------------------------------------- +-- Gestione riordino lavorazioni per macchine in linea +-- ------------------------------------------------------------------------------------------------------------- +-- ------------------------------------------------------------------------------------------------------------- +if OptimizeMach then + + -- codice valutazione lavorazioni + +end + +-- ------------------------------------------------------------------------------------------------------------- +-- ------------------------------------------------------------------------------------------------------------- + + +-- reset librerie locali +package.loaded.CurrCamInfo = nil +package.loaded.CurrDoorsCustomData = nil + +-- se machining lanciato DMACH do messaggio di chiusura e rendo corrente la prima macchinata +if not DGD.NCGEN then + DoorOutLog( ' ' .. EgtDoorsMsg[498]..'\n', 0) + EgtOutText( EgtDoorsMsg[498]) + CloseLogFile() + EgtSetCurrMachGroup() +end + +-- reset librerie globali +ResetDoorsLibs() +package.loaded.EgtDoorsBase = nil + +return bOk diff --git a/Machining_1.lua b/Machining_1.lua new file mode 100644 index 0000000..b36b522 --- /dev/null +++ b/Machining_1.lua @@ -0,0 +1,2901 @@ +-- +-- 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 +-- +-- Machining_1.lua by EgalWare s.r.l. 2016/23/05 20:00:00 +-- Autore: Dario Sassi +-- Machining generation for Doors program machine CMS +-- 2016.11.16 V1.011 FM Manage door limit for shifted disposition +-- 2017.05 V1.012 FM Mmanage machining optimization +-- 2017.06.13 V1.013 FM Manage top door disposition by Currcaminfo +-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece +-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2018.02.26 V1.0b1 FM Manage door dimension checking +-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces +-- 2018.10.16 V1.0b3 FM Extend setup to 50 items +-- 2018.10.18 V1.0b4 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles +-- 2018.10.23 V1.0b5 FM Manage rough machining +-- 2018.10.25 V1.0b6 FM Fix problem on AdjustBevel: missing parameter into call function +-- 2019.01.14 V1.0b7 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set +-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name) +-- 2019.01.23 V1.0b8 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. +-- 2019.02.12 V1.0b9 FM Remove empty phase (after the first one) +-- 2019.03.11 V1.0c1 FM Fix error on delete paths with HIDE and ROUGH suffix +-- 2019.03.27 V1.0c2 FM Manage check door/jamb dimension by function CheckPieceDimension +-- 2019.03.27 V1.0c3 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values +-- 2019.03.27 V1.0c3 FM Modify error messages format into CheckPieceDimension +-- 2019.03.27 V1.0c3 FM Manage estimate time +-- 2019.03.29 V1.0c4 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.08 V1.0c5 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines +-- Now it uses 1 line for antisplint blade and 1 line for normal blade +-- 2019.04.08 V1.0c5 FM Manage Blade groove function AdjustBladeVertCurve +-- 2019.05.28 v1.0c6 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings +-- 2021.06.01 v1.0c7 FM Fix error on calculate piece box +-- 2021.10.28 V1.0c8 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter +-- 2022.06.10 V1.0c9 FM Manage large width door disposition +-- 2022.06.20 V1.0d1 FM Manage Part parameter from ddf +-- 2022.07.27 V1.0d2 FM Modification to use compiled code +-- 2023.03.29 V1.0d3 FM Fix error on calculate rough paths on Convex profile +-- 2023.07.06 V1.0d4 FM Fix error on not check new variables dDimPendularDoor and AskCustomTable +-- 2023.12.01 V1.0d5 FM Manage small planes on Convex profile + + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local MachiningLoc = {} + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- variabili genarazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true + +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. DGD.EMC) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** calculate door disposition by parameters *** +----------------------------------------------------------------- +local function CalcTopPosition( nTopSideDriveDisp, bAtRight) + local bTopOnRight + + if nTopSideDriveDisp and nTopSideDriveDisp == 1 then + bTopOnRight = true + elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then + bTopOnRight = false + else + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + + return bTopOnRight +end + +----------------------------------------------------------------- +-- *** Add Machining in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, + sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, + bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed, bCalMach) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + + if nMach == 1 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMach) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, + bNotGenMachining, nil, nil, nil, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMachUp) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, + bNotGenMachining, nil, nil, nil, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMachDw) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + end + end + end + + return bOk, nNumMach, tMachining +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if tLocTable[i].Oper == 'AdjustHead' and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j]) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, + nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +----------------------------------------------------------------- +local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + local bFailDim = false + local sErrMess = '' + local dLimitToCheck + + dLimitToCheck = dMinDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMinDoorThick + if dThickDoor < dLimitToCheck then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorThick + if dThickDoor > dLimitToCheck then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + return bFailDim +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) + + -- macchina e tabella di default + local MachName = 'Cms-PF122R8RR' + + -- Machinings Table + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- References on table (respect Zero machine) + -- Y Table + local Ori1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + -- V Table + local Ori3 = Point3d( -120.420, -57.130, -11.511) * GEO.ONE_INCH + -- Y Table for wide door + local Ori9 = Point3d( -21.991, -11.1703, -11.511) * GEO.ONE_INCH + -- V Table for wide door + local Ori10 = Point3d( -120.420, -11.1703, -11.511) * GEO.ONE_INCH + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftAct = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + -- tabella raccordi + local tsRadiusProf = {} + local tsPlaneProf = {} + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- variabili pezzo singolo + local nPz + local sAssemb + + -- variabile check dimensioni porta + local bFailDim = false + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- elimino percorsi eventualmente creati dal Mach + -- cancello i percorsi ghost e tutti i percorsi di sgrossatura + local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + + -- se la variabile è una tabella, estrapolo solo la porta + local PzIsTab = type(tPz) == 'table' + if PzIsTab then + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + + -- se non ha nota o nota della prima porta esco + if not sAssemb or ( sAssemb and sAssemb == 'first') then + break + end + end + else + Pz = tPz + sAssemb = tsAssemb + end + +-------------------------------------------------------------------------------- + -- Dati della porta + local sCode = EgtGetInfo( Pz, 'Code') + local dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + local dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + local dThickDoor = EgtGetInfo( Pz, 'T', 'd') + local sSwing = EgtGetInfo( Pz, 'Swing') + MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente + local sSecure = EgtGetInfo( Pz, 'Secure') +-- local nPart = EgtGetInfo( Pz, 'Part', 'i') + local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + local sTopTrim = EgtGetInfo( Pz, 'top_trimming') + local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra + local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) + local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' ) + tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') + tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') + tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') + tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') + tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') + tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') + tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') + local dRadiusPrf = tsRadiusProf[1] + local dPlanePrf = tsPlaneProf[1] + local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + + -- Box pezzo + local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local b3fx = BBox3d() -- inizializzo il box nullo + b3fx = MakeBoxFromSolidLayer( Ls, 0, Aux) + local b3Solid = b3fx +-- local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + +-------------------------------------------------------------------------------- + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + local TAB + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato + return false + end + local MachinesName = TAB.MMachineData + if not MachinesName then + DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable + return false + end + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + local TABORD + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + + local dUseOneTab + local AskCustomTable + local dDimPendularDoor + local dMaxDoorLength + local dMinDoorLength + local dMaxDoorWidth + local dMinDoorWidth + local dMaxDoorThick + local dMinDoorThick + local dWideDoorWidth + local sLocSecure + local dMaxOverMat + local dStepOverMat + local nTopSideDriveDisp + local dMaxDistToChain + local dExtraThruDepth + local nGenCncAsDdfName + local dBladePerpLeadIn + local dPercRedFeed + + -- imposto i dati macchina secondo le informazioni del file cam + MachName = mCamData[nNumMachFromCam].MachName + Ori1 = mCamData[nNumMachFromCam].Ori1 + Ori3 = mCamData[nNumMachFromCam].Ori3 + Ori9 = mCamData[nNumMachFromCam].Ori9 + Ori10 = mCamData[nNumMachFromCam].Ori10 + vShiftAct = mCamData[nNumMachFromCam].Shift1 + dUseOneTab = mCamData[nNumMachFromCam].LimitTable + AskCustomTable = mCamData[nNumMachFromCam].AskCustomTable + dDimPendularDoor = mCamData[nNumMachFromCam].DimPendularDoor + dMaxDoorLength = mCamData[nNumMachFromCam].MaxDoorLength + dMinDoorLength = mCamData[nNumMachFromCam].MinDoorLength + dMaxDoorWidth = mCamData[nNumMachFromCam].MaxDoorWidth + dMinDoorWidth = mCamData[nNumMachFromCam].MinDoorWidth + dMaxDoorThick = mCamData[nNumMachFromCam].MaxDoorThick + dMinDoorThick = mCamData[nNumMachFromCam].MinDoorThick + dWideDoorWidth = mCamData[nNumMachFromCam].WideDoorWidth + sLocSecure = mCamData[nNumMachFromCam].sLocSecure + dMaxOverMat = mCamData[nNumMachFromCam].MaxOverMat + dStepOverMat = mCamData[nNumMachFromCam].StepOverMat or 10 + nTopSideDriveDisp = mCamData[nNumMachFromCam].TopSideDriveDisp + dMaxDistToChain = mCamData[nNumMachFromCam].MaxDistToChain + dExtraThruDepth = mCamData[nNumMachFromCam].ExtraThruDepthMachining + nGenCncAsDdfName = mCamData[nNumMachFromCam].nGenCncAsDdfName or 0 + dBladePerpLeadIn = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) + dPercRedFeed = mCamData[nNumMachFromCam].PercRedFeed or 0.3 + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], MachName), 0) -- warning. Cnc generation disable + return true + end + + -- setto come generare il nome del file cnc (di default è uguale al nome del parametro sCode interno ad ddf) + if nGenCncAsDdfName == 0 then + -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi + sFileName = sCode + end + + local MTable = TAB.MTable + local MTableOrd = TABORD.MTable + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftMchng = false + local bSmallShiftedDoor = false + local bWiderDoor = false + local sDispMode + local sNotePhase + local sTotDispMode = '' + local sNumGroup = '' + local bGenFirstStep = false + local nIndexStartMach = 1 + local bWork = true + -- variabili utilizzate dentro al ciclo + local nMchId + local sTab + local tabOri + local Ori + local OriDw + local ColA + local nRaw + local bMoveRaw + local bPush + local bFlip +-- local bSpin = false + local bTopOnRight + -- variabili per disposizione sottopezzi + local OffsRef + local OffsVac + local X1r + local X2r + local X3r + local X1 + local X2 + local Y1r + local Y2r + local Y3r + local Y1 + local Y2 + local nRef1 + local nRef2 + local nRef3 + local nFix1 + local nFix2 + local nFix3 + local nFix4 + local nFix5 + local nFix6 + local nFix7 + local nFix8 + local OffsXSovr = 0 + local OffsYSovr = 0 + -- variabile per tool setup + local bSetUp + local MSetup + local sSetup + local tListError + local sListTool + -- variabili calcolo box + local b3SolidPiece + local b3SolidPiece2 + local b3SolidOnTab + local pMin + local pMax + local dOffsX = 0 + local dOffsY = 0 + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local sMachProf + local bWorkUnder = false + -- variabile per conteggio lavorazioni + local nNumMach + local nNumSkip + local tSecMachTab = {} + local tSecMachTabOrd = {} + -- variabili per fase + local nNumPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( MachName) + + -- faccio tutte le fasi + while bWork do + + sDispMode = '' + + if bFirstStep and not bShiftMchng then + nNumGroup = nNumGroup + 1 + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName) + else + nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName) + end + nNumPhase = EgtGetCurrPhase() + else + + -- se nessuna lavorazione riutilizzo la vecchia fase + if nNumMach == 0 then + + EgtRemoveRawPart( nRaw) -- elimino il grezzo + + -- elimino la disposizione dei sottopezzi + local nNumFix = EgtGetFirstFixture() + while nNumFix do + EgtRemoveFixture( nNumFix) + nNumFix = EgtGetFirstFixture() + end + else + nNumPhase = EgtAddPhase() -- creo nuova fase + end + + -- rendo corrente la fase + if nNumPhase then + EgtSetCurrPhase(nNumPhase) + end + + -- se porta large wide cambio la nota a tutte le entità con la nota SkipByLowerPos + if bWiderDoor then + local tSkipByPosList = {} + tSkipByPosList = MB.FindGeomWithNote( Pz, 'SkipByLowerPos', 'i', 1, tSkipByPosList) + for i = 1, #tSkipByPosList do + local nMach = EgtGetInfo( tSkipByPosList[i], 'Mach', 'i') or 1 + if nMach > 10 and nMach < 20 then + nMach = nMach - 10 + EgtSetInfo( tSkipByPosList[i], 'Mach', nMach) + EgtRemoveInfo( tSkipByPosList[i], 'SkipByLowerPos') + EgtSetInfo( tSkipByPosList[i], 'AlreadyReduceMach', 1) + end + end + end + end + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + if bFirstStep and not bShiftMchng then + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + dLeftOffs = 0 + dRightOffs = 0 + dTopOffs = 0 + dBottomOffs = 0 + end + else -- fase successiva ribaltata o spostata + + -- i profili con lavorazione disabilitata li posso mettere subito a zero + if ( not bLockMach and bAtRight) or ( not bHingeMach and not bAtRight) then -- lavorazione lato serratura disabilitata + dRightOffs = 0 + end + + if ( not bLockMach and not bAtRight) or ( not bHingeMach and bAtRight) then -- lavorazione lato serratura disabilitata + dLeftOffs = 0 + end + + if not bTopMach then -- lavorazione lato top disabilitata + dTopOffs = 0 + end + + if not bBottomMach then -- lavorazione lato top disabilitata + dBottomOffs = 0 + end + + -- azzero i sovramateriali dei profili che sono stati lavorati + if sMachProf and #sMachProf > 0 then + + local sListProf = EgtSplitString( sMachProf, ',') + for m = 1, #sListProf do + if string.lower( sListProf[m]) == 'left' then + dLeftOffs = 0 + elseif string.lower( sListProf[m]) == 'right' then + dRightOffs = 0 + elseif string.lower( sListProf[m]) == 'top' then + dTopOffs = 0 + elseif string.lower( sListProf[m]) == 'bottom' then + dBottomOffs = 0 + end + end + end + end + + if bFirstStep then + b3SolidPiece = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + else + b3SolidPiece2 = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + end + + if b3SolidPiece and b3SolidPiece2 then + dOffsX = b3SolidPiece2:getMin():getX() - b3SolidPiece:getMin():getX() + dOffsY = b3SolidPiece2:getMin():getY() - b3SolidPiece:getMin():getY() + end + + ColA = Color3d( 255, 165, 0, 15) + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, + b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs + dOffsX, dBottomOffs + dOffsY, 0), nRaw) + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitae inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + local tLocMach = {} + local tLocMachOrd = {} + + if bFirstStep then + tLocMach = MTable + tLocMachOrd = MTableOrd + if not bShiftMchng then + sMachProf = '' + nIndexStartMach = 1 + end + else + tLocMach = tSecMachTab + tLocMachOrd = MTableOrd + if not bShiftMchng then + nIndexStartMach = 1 + end + end + + -- solo il primo giro, prendo nota dei profili tipo bevel + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + if bFirstStep and not bShiftMchng then + + local nUnderGeom + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + local sUpperProfName = string.upper(tLocMach[i].Name) + -- prendo i profili bevel direttamente dalla tabella + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName) then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata o la porta è al di sotto del limite.. + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + ( ( tLocMach[i].Shift and tLocMach[i].Shift > 0) or dWidthDoor <= DGC.Wl) then + bSmallShiftedDoor = true + end + -- Test delle lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + end + end + end + end + end + elseif not bFirstStep and not bShiftMchng then -- se porta ribaltata + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata e la porta è al di sotto del limite + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + ( ( tLocMach[i].Shift and tLocMach[i].Shift > 0) or dWidthDoor <= DGC.Wl) then + bSmallShiftedDoor = true + end + end + end + end + end + + -- se porta da disporre subito traslata setto i flag + if bSmallShiftedDoor then + bShiftMchng = true -- porta traslata + bGenFirstStep = true -- flag per saltare il primo giro + end + -- se porta è più larga della dimensione limite + if bFirstStep and dWideDoorWidth and dWidthDoor > dWideDoorWidth then + bWiderDoor = true + if AskCustomTable and AskCustomTable == 1 then + local nNumTab = 9 + repeat + local sNumTab = '9' + local tPos = EgtDialogBox( 'Origin on table for wide door', {'Origin 1/3 - 9/10', sNumTab}) + + if tPos and #tPos == 1 then + nNumTab = tonumber( tPos[1]) + if nNumTab == 1 then + bWiderDoor = false + elseif nNumTab == 9 then + bWiderDoor = true + end + else + nNumTab = 0 + end + until ( nNumTab == 1 or nNumTab == 9) + end + + if bWiderDoor then + bSmallShiftedDoor = false + bShiftMchng = false + end + end + + ----------------------- + -- *** Disposizione *** + ----------------------- + + -- Scelta della tavola + if bFirstStep then + sTab = 'YTab' + if b3Solid:getDimY() > dUseOneTab then + sTab = 'YVTab' + -- altrimenti se lunghezza è idonea attivare il pendolare ed è selezionabile + elseif dDimPendularDoor and AskCustomTable and b3Solid:getDimY() <= dDimPendularDoor and AskCustomTable == 1 then + local nNumTab = 1 + repeat + local sNumTab = '1' + local tPos = EgtDialogBox( 'Choose pendular table(1 for Y table, 2 For V table)', {'Table 2 - 1', sNumTab}) + if tPos and #tPos == 1 then + nNumTab = tonumber( tPos[1]) + if nNumTab == 1 then + sTab = 'YTab' + elseif nNumTab == 2 then + sTab = 'VTab' + end + else + nNumTab = 0 + end + until ( nNumTab == 1 or nNumTab == 2) + end + end + EgtSetTable( sTab) + + -- Origine tavola corrente rispetto a Zero macchina + tabOri = EgtGetTableRef( 1) + if bWiderDoor then + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sTab == 'VTab' then + Ori = Ori10 - tabOri + OriDw = Ori1 - tabOri + -- per Y tab o YV tab + else + Ori = Ori9 - tabOri + OriDw = Ori1 - tabOri + end + else + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sTab == 'VTab' then + Ori = Ori3 - tabOri + else + Ori = Ori1 - tabOri + end + end + + -- se porta da traslare setto lo shift da applicare + if bShiftMchng then + vShift = vShiftAct + else + vShift = vNullShift + end + + Ori = Ori + Vector3d( 0, 0, 80) + Ori = Ori + vShift + if OriDw then + OriDw = OriDw + Vector3d( 0, 0, 80) + OriDw = OriDw + vShift + end + + -- Rotazione porta in base alla macchina + bMoveRaw = false + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- se non c'è il parametro considero la porta come se avesse bevel down + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or + sSwing == 'LH' or sSwing == 'LHI' or sSwing == 'LHA' then + bPush = true + else + bPush = false + end + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. tostring( nNumPhase) + elseif nNumPhase then + sNumPhase = tostring( nNumPhase) + else + sNumPhase = '0' + end + + if bFirstStep then + + local bOkDisp = false + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure +-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel ed è da lavorare + if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB'and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or + ( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) +-- if ( sLockTrim == 'BD' or sLockTrim == 'BU') and bLockMach and not bOkDisp then + if ( sLockTrim == 'BD' or sLockTrim == 'BU' or sLockTrim == 'BDEB' or sLockTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sLockTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sLockTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sLockTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sLockTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + if ( ( sLockTrim == 'BD' or sLockTrim == 'BDEB') and bPush) or + ( ( sLockTrim == 'BU' or sLockTrim == 'BUEB') and not bPush and not bOppoBevelProf) or + ( ( sLockTrim == 'BU' or sLockTrim == 'BUEB') and bPush and bOppoBevelProf) then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or + ( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or + ( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore + if sSecure and string.upper(sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not sLocSecure or ( string.upper(sLocSecure) ~= 'UP' and string.upper(sLocSecure) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + sSecure = sLocSecure + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if sSecure and string.upper(sSecure) == 'UP' then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + elseif sSecure and string.upper(sSecure) == 'DN' then + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) qualla di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + -- se porta a tirare non la ribalto perchè si presta già ad essere bevel down + else + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + end + -- in attesa delle considerazioni del cliente, in base alle geometrie trovate ribalto o meno la porta + else + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight) + else -- altrimenti vecchio metodo + bFlip = true + bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight) + end + end + end + end + + if bWiderDoor then + sDispMode = sDispMode .. EgtDoorsMsg[697] + end + + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + -- se porta è più larga dela parametro limite + if bWiderDoor then + -- Muovo porta con l'angolo in alto a destra nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.TR) + else + -- Muovo porta con l'angolo in basso a destra nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.BR) + end + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + else -- se sono in ribaltamento porta + + -- posizioni opposte + bFlip = not bFlipFirst + if nTopSideDriveDisp and nTopSideDriveDisp == 1 then + bTopOnRight = true + elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then + bTopOnRight = false + else + bTopOnRight = not bTopOnRightFirst + end + + -- faccio le rotazioni della porta e setto per non ribaltarla + if bWiderDoor then + EgtRotateRawPart( nRaw, Z_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[696] + bFlip = bFlipFirst + bTopOnRight = bTopOnRightFirst + end + + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[EgtIf( bWiderDoor, 482, 481)] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[EgtIf( bWiderDoor, 481, 482)] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + -- se porta larga + if bWiderDoor then + -- Muovo porta con l'angolo in alto a destra nella posizione di origine + local dXShift + if bTopOnRight then + dXShift = dBottomOffs + else + dXShift = dTopOffs + end + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori+Vector3d( dXShift,0,0), MCH_CR.TR) + else + -- Muovo porta con l'angolo in basso a destra nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.BR) + end + end + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[528]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + if bFirstStep then + if bShiftMchng then + sNotePhase = 'SHIFT' + else + sNotePhase = 'NORMAL' + end + else + if bShiftMchng then + sNotePhase = 'FLIPSHIFT' + else + if bWiderDoor then + sNotePhase = 'NORMAL' + else + sNotePhase = 'FLIP' + end + end + end + + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sNotePhase) + EgtSetInfo( Pz, 'WideDoor', bWiderDoor) + + if bFlip then -- se porta capovolta + if bWiderDoor then + if bFirstStep then + if bTopOnRight then -- se top a destra (effettivo) + -- il lato destro riferito in alto è quello delle lock (effettivo) + OffsYSovr = dRightOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + else -- se top a sinistra (effettivo) + -- il lato sinistro riferito in alto è quello delle lock (effettivo) + OffsYSovr = dLeftOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + end + else + if bTopOnRight then -- se top a destra (nominale) + -- il lato sinistro in alto è quello delle hinges (effettivo) + OffsYSovr = dLeftOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + else -- se top a sinistra (nominale) + -- il lato destro riferito in alto è quello delle hinges (effettivo) + OffsYSovr = dRightOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + end + end + else + if bTopOnRight then -- se top a destra (effettivo) + -- il lato sinistro riferito in basso è quello delle hinges (effettivo) + OffsYSovr = dLeftOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + else -- se top a sinistra (effettivo) + -- il lato destro riferito in basso è quello delle hinges (effettivo) + OffsYSovr = dRightOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + end + end + else -- altrimenti non è capovolta + -- se porta larga + if bWiderDoor then + if bFirstStep then + if bTopOnRight then -- se top a destra (effettivo) + -- il lato sinistro riferito in alto è quello delle lock (effettivo) + OffsYSovr = dLeftOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + else -- se top a sinistra (effettivo) + -- il lato destro riferito in alto è quello delle lock (effettivo) + OffsYSovr = dRightOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + end + else + if bTopOnRight then -- se top a destra (nominale) + -- il lato destro riferito in alto è quello delle hinges (effettivo) + OffsYSovr = dRightOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + else -- se top a sinistra (nominale) + -- il lato sinistro in alto è quello delle hinges (effettivo) + OffsYSovr = dLeftOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + end + end + else + if bTopOnRight then -- se top a destra (effettivo) + -- il lato destro riferito in basso è quello delle hinges (effettivo) + OffsYSovr = dRightOffs + -- il lato top si trova a destra (effettivo) + OffsXSovr = dTopOffs + else -- se top a sinistra + -- il lato sinistro riferito in basso è quello delle hinges (effettivo) + OffsYSovr = dLeftOffs + -- il lato bottom si trova a destra (effettivo) + OffsXSovr = dBottomOffs + end + end + end + + -- Controllo dimensioni pezzo + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + vShift:getX(), vShift:getY(), dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + if bFailDim then + + DGD.ERR = 19 + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( DGD.EMC, 0) + EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + + -- Inserimento riferimenti e ventose + local dPosxRef = b3Solid:getDimY() + if dPosxRef <= dUseOneTab and dPosxRef > 2305.05 then + dPosxRef = 2305.05 + end + OffsRef = 70 + OffsVac = 40 + X1r = Ori:getX() + OffsRef + X2r = Ori:getX() - 150 + X3r = Ori:getX() - dPosxRef + 150 + X1 = Ori:getX() - dPosxRef + 25 + OffsVac - OffsXSovr + X2 = Ori:getX() - 25 - OffsVac - OffsXSovr + local dAngRef + if bWiderDoor then + Y1r = Ori:getY() - ( Ori9:getY() - Ori1:getY()) + 100 + Y2r = Ori:getY() + OffsRef + abs( vShift:getY()) + Y3r = Ori:getY() + OffsRef + abs( vShift:getY()) + Y1 = Ori:getY() - b3Solid:getDimX() + 25 + OffsVac - OffsYSovr + if Y1 < (OriDw:getY() + 25 + OffsVac) then + Y1 = OriDw:getY() + 25 + OffsVac + end + Y2 = Ori:getY() - 25 - OffsVac - OffsYSovr + dAngRef = 180 + else + Y1r = Ori:getY() + 100 + Y2r = Ori:getY() - OffsRef - abs( vShift:getY()) + Y3r = Ori:getY() - OffsRef - abs( vShift:getY()) + Y1 = Ori:getY() + 25 + OffsVac + OffsYSovr + Y2 = Ori:getY() + b3Solid:getDimX() - 25 - OffsVac + OffsYSovr + dAngRef = 0 + end + nRef1 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X1r), Y1r, 0), 90) + nRef2 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X2r), Y2r, 0), dAngRef) + nRef3 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X3r), Y3r, 0), dAngRef) + nFix1 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X1), Y1, 0)) + nFix2 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X1), Y2, 0), 180) + nFix3 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.66*X1+0.34*X2), Y1, 0)) + nFix4 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.66*X1+0.34*X2), Y2, 0), 180) + nFix5 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.34*X1+0.66*X2), Y1, 0)) + nFix6 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.34*X1+0.66*X2), Y2, 0), 180) + nFix7 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X2), Y1, 0)) + nFix8 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X2), Y2, 0), 180) + + -- *** Lavorazioni *** + local bMakeGhost = EgtIf( bFirstStep, true, false) + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + -- print Machining table + for i = nIndexStartMach, #tLocMach do + DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + end + + -- solo il primo giro aggiusto i profili bevel per essere coerente con la sequenza di tabella + if bFirstStep and ( not bShiftMchng or bSmallShiftedDoor) then + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + local sNewName + _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep) + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sottp + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + end + local bEnBreak = false + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = nIndexStartMach, #tLocMach do + + -- se devo uscire dal ciclo + if bEnBreak then break end + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local sHide = EgtIf( bFirstStep, '','_HIDE') + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide) + -- Applico le lavorazioni + for j = 1, #EntList do + + local nNewIdEnt + local nNewIdEnt2 + local nLocMach + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' then + + local sNewName + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + bLocMach, sNewName, nNewIdEnt, nNewIdEnt2 = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, nil, bMakeGhost, bWiderDoor, sEdge, true) + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + if sEdge then + -- se porta large wide e prima fase inserisco l'eventuale profilo di lavorazione del solo lato lock + if bWiderDoor and bFirstStep then + if ( string.lower( sEdge) == 'left' and not bAtRight) or ( string.lower( sEdge) == 'right' and bAtRight) then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + else + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + +-- if bFirstStep then + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + if nNewIdEnt2 then + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc) + end + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + if nNewIdEnt2 then + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc) + end + end +-- end + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' then + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + bLocMach, nNewIdEnt, nNewIdEnt2 = MB.AdjustThrouCurve( EntList[j], bMakeGhost, nil, bWiderDoor, sEdge, true, bFirstStep) + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + if sEdge then + -- se porta large wide e prima fase inserisco l'eventuale profilo di lavorazione del solo lato lock + if bWiderDoor and bFirstStep then + if ( string.lower( sEdge) == 'left' and not bAtRight) or ( string.lower( sEdge) == 'right' and bAtRight) then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + else + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + +-- if bFirstStep then + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + if nNewIdEnt2 then + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc) + end + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + if nNewIdEnt2 then + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc) + end + end +-- end + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione non è applicabile e non scatena lo shift +-- if not bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione non è applicabile + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].Mach}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachUp}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' then + bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], 0, NO_WORK_UNDERSQUARE, bMakeGhost ) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione non è applicabile e non scatena lo shift +-- if not bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione non è applicabile + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].Mach}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachUp}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + end + elseif tLocMach[i].Oper == 'AdjustHole' then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then + bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) + end + else -- se nessuna operazione + if bMakeGhost then + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + else + nNewIdEnt = EntList[j] + end + end + + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + -- se porta large width e la geoemtria è lavorabile, verifico se è in posizione lavorabile + if bWiderDoor and nMach >= 1 and nMach <= 3 then + -- considero solo entità con il nome che contiene '_HIDE' + local sNameEnt = EgtGetName( nNewIdEnt) + if sNameEnt and string.find( sNameEnt, '_HIDE') then + local b3f1 = EgtGetBBoxGlob( nNewIdEnt, GDB_BB.EXACT) + local dYmin = b3f1:getMin():getY() + -- se il punto minimo è più in basso esco dalla funzione + if dYmin < ( pMax:getY() - dWideDoorWidth) then + nNumMachSkip = nNumMachSkip + 1 + nMach = nMach + 10 + EgtSetInfo( nNewIdEnt, 'Mach', nMach) + EgtSetInfo( nNewIdEnt, 'SkipByLowerPos', 1) + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + end + if nNewIdEnt2 then + sNameEnt = EgtGetName( nNewIdEnt2) + local nMach2 = nMach + if sNameEnt and string.find( sNameEnt, '_HIDE') then + local b3f1 = EgtGetBBoxGlob( nNewIdEnt2, GDB_BB.EXACT) + local dYmin = b3f1:getMin():getY() + -- se il punto minimo è più in basso esco dalla funzione + if dYmin < ( pMax:getY() - dWideDoorWidth) then + nNumMachSkip = nNumMachSkip + 1 + if nMach2 >= 1 and nMach2 <= 3 then + nMach2 = nMach2 + 10 + end + EgtSetInfo( nNewIdEnt2, 'Mach', nMach2) + EgtSetInfo( nNewIdEnt2, 'SkipByLowerPos', 1) + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + end + end + end + + local bScroll = true + + -- LAVORAZIONI + + -- se prima lavorazione, valida, con chiave Shift abilitata, esco dal giro +--[[ + if ( nMach > 0 and nMach < 4) and + not bShiftMchng and + tLocMach[i].Shift == 1 then + + bShiftMchng = true -- flag per traslazione Y +-- nIndexStartMach = i -- ripartenza da questa posizione + nIndexStartMach = 1 -- ripartenza dall'inizio + nNumMach = 0 -- azzero le lavorazioni in modo da ricreare la disposizione traslata + bScroll = false -- salto l'applicazione delle lavorazioni in seguito + bEnBreak = true -- blocco il for della scansione tabella + + -- cancello tutti i percorsi ghost + local DelList = MB.FindEntitiesWithPartName( Pz, '_HIDE') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = nil + + -- se fase di ripresa rimetto la nota mach disabilitata + if not bFirstStep then + nMach = nMach + 10 + EgtSetInfo( EntList[j], 'Mach', nMach) + nNumMachSkip = nNumMachSkip + 1 + end + end +--]] + if not bScroll then + break -- esco dal ciclo for j + else + if nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + local bCalMach = true + -- se non primo passo e nota JoinMach differisce dal mach e dalla lavorazione + if not bFirstStep then + + local sJoinMach = EgtGetInfo( nNewIdEnt, 'JoinMach') + + if sJoinMach and #sJoinMach > 1 then + local tJoinMach = EgtSplitString( sJoinMach) + + if tJoinMach and #tJoinMach == 2 then + local nNumMachRef = tonumber( tJoinMach[1]) + local sMachRefJoin = tJoinMach[2] + if nNumMachRef ~= nMach then + bCalMach = false + elseif nNumMachRef == 1 and sMachRefJoin and tLocMach[i].Mach and tLocMach[i].Mach ~= sMachRefJoin then + bCalMach = false + elseif nNumMachRef == 2 and sMachRefJoin and tLocMach[i].MachUp and tLocMach[i].MachUp ~= sMachRefJoin then + bCalMach = false + elseif nNumMachRef == 3 and sMachRefJoin and tLocMach[i].MachDw and tLocMach[i].MachDw ~= sMachRefJoin then + bCalMach = false + end + end + end + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, + NOT_GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed, bCalMach) + else + local sLocMachName + if not nLocMach or nLocMach == 1 then + sLocMachName = tLocMach[i].Mach + elseif nLocMach == 2 then + sLocMachName = tLocMach[i].MachUp + elseif nLocMach == 3 then + sLocMachName = tLocMach[i].MachDw + elseif nLocMach == 21 then -- caso particolare quando falliscono sia la lavorazione top che bottom + sLocMachName = tLocMach[i].Mach + if tLocMach[i].MachUp then + sLocMachName = sLocMachName .. ' + ' .. tLocMach[i].MachUp + end + end + DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( sLocMachName, sLocMachName, '') .. + EgtDoorsMsg[596]..tostring( nNumPhase), 0) + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end -- end for + + local i = 1 + while i <= #tLocMachOrd and not bEnBreak do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGrp = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) + + if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0 + + if sProperty == 'MinDist' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local tMachining = {} + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se è fuori range o non corrispondono le lavorazioni + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, tMachining, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata + -- tolgo di mezzo le note secondarie + -- for j = 1, #EntList do + -- EgtRemoveInfo( EntList[j], 'Mach2nd') + -- end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + elseif sProperty == 'Layer' then -- lavorazione layer + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE') + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, + nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + end + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata + -- tolgo di mezzo le note secondarie + -- for j = 1, #EntList do + -- EgtRemoveInfo( EntList[j], 'Mach2nd') + -- end + end + end + elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore + DGD.ERR = -15 + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + if DGD.ERM and #DGD.ERM > 0 then + DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + end + + i = i + 1 + end + + -- se ci sono state lavorazioni accodo la disposizione delle fase + if nNumMach > 0 then + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + else -- altrimenti nessuna lavorazione + + if not bFirstStep then -- se non è il primo giro elimino la fase vuota + + -- se ho più di una fase elimino l'ultima fase + if nNumPhase > 1 then + EgtRemoveLastPhase() + end + + -- setto corrente fase precedente + if nPrevPhase then + EgtSetCurrPhase(nPrevPhase) + nNumPhase = nPrevPhase + end + end + end + + -- se sono al primissimo giro + if not bGenFirstStep then + + -- la lavorazione di traslazione ho rotazione (porta larga) hanno priorità sul ribaltamento + -- se trovata traslazione setto il flag per il prossimo giro + if bShiftMchng then + bGenFirstStep = true + if not bFirstStep then -- se sono già in ripresa porta resetto il contatore di lavorazioni saltate + nNumMachSkip = 0 -- resetto per il prossimo giro + end + else + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + -- con lavorazioni skippate ma già con pezzo non in prima fase e non shiftato, esco + if not bFirstStep then + bWork = false + else + bFirstStep = false + end + nNumMachSkip = 0 -- resetto per il prossimo giro + end + end + else -- altrimenti ho già fatto un giro e ho trovato la traslazione + -- se nessuna geometria skippata esco + if nNumMachSkip == 0 then bWork = false end + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + if bFirstStep then -- se ho terminato il giro con eventuale traslazione o rotazione disabilito la traslazione + -- disativo la traslazione sul giro successvo + bShiftMchng = false + -- disattivo il flag che indica di disporre la porta subito traslata + bSmallShiftedDoor = false + -- disattivo il flag che indica la porta larga + bWiderDoor = false + end + bFirstStep = false + end + end + + -- se porta larga inibisco il ribaltamento +-- if bWiderDoor then bWork = false end + + -- controllo di sicurezza + if nNumCycle > 4 then bWork = false end + + nNumCycle = nNumCycle + 1 + end -- end while + + -------------------------- + -------------------------- + -- *** Tools Setup *** + -------------------------- + -------------------------- + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + bSetUp = EgtImportSetup() + sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], ' ') .. ' (from Default)' + end + + -- se fallito quello di default o utensili mancanti provo quelli indicati nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + local nContImport = 0 + + -- ciclo tra quelli disponibili + for k = 1, 50 do + + if not bSetUp then + if k == 1 then + sSetup = mCamData[nNumMachFromCam].Setup1 + elseif k == 2 then + sSetup = mCamData[nNumMachFromCam].Setup2 + elseif k == 3 then + sSetup = mCamData[nNumMachFromCam].Setup3 + elseif k == 4 then + sSetup = mCamData[nNumMachFromCam].Setup4 + elseif k == 5 then + sSetup = mCamData[nNumMachFromCam].Setup5 + elseif k == 6 then + sSetup = mCamData[nNumMachFromCam].Setup6 + elseif k == 7 then + sSetup = mCamData[nNumMachFromCam].Setup7 + elseif k == 8 then + sSetup = mCamData[nNumMachFromCam].Setup8 + elseif k == 9 then + sSetup = mCamData[nNumMachFromCam].Setup9 + elseif k == 10 then + sSetup = mCamData[nNumMachFromCam].Setup10 + elseif k == 11 then + sSetup = mCamData[nNumMachFromCam].Setup11 + elseif k == 12 then + sSetup = mCamData[nNumMachFromCam].Setup12 + elseif k == 13 then + sSetup = mCamData[nNumMachFromCam].Setup13 + elseif k == 14 then + sSetup = mCamData[nNumMachFromCam].Setup14 + elseif k == 15 then + sSetup = mCamData[nNumMachFromCam].Setup15 + elseif k == 16 then + sSetup = mCamData[nNumMachFromCam].Setup16 + elseif k == 17 then + sSetup = mCamData[nNumMachFromCam].Setup17 + elseif k == 18 then + sSetup = mCamData[nNumMachFromCam].Setup18 + elseif k == 19 then + sSetup = mCamData[nNumMachFromCam].Setup19 + elseif k == 20 then + sSetup = mCamData[nNumMachFromCam].Setup20 + elseif k == 21 then + sSetup = mCamData[nNumMachFromCam].Setup21 + elseif k == 22 then + sSetup = mCamData[nNumMachFromCam].Setup22 + elseif k == 23 then + sSetup = mCamData[nNumMachFromCam].Setup23 + elseif k == 24 then + sSetup = mCamData[nNumMachFromCam].Setup24 + elseif k == 25 then + sSetup = mCamData[nNumMachFromCam].Setup25 + elseif k == 26 then + sSetup = mCamData[nNumMachFromCam].Setup26 + elseif k == 27 then + sSetup = mCamData[nNumMachFromCam].Setup27 + elseif k == 28 then + sSetup = mCamData[nNumMachFromCam].Setup28 + elseif k == 29 then + sSetup = mCamData[nNumMachFromCam].Setup29 + elseif k == 30 then + sSetup = mCamData[nNumMachFromCam].Setup30 + elseif k == 31 then + sSetup = mCamData[nNumMachFromCam].Setup31 + elseif k == 32 then + sSetup = mCamData[nNumMachFromCam].Setup32 + elseif k == 33 then + sSetup = mCamData[nNumMachFromCam].Setup33 + elseif k == 34 then + sSetup = mCamData[nNumMachFromCam].Setup34 + elseif k == 35 then + sSetup = mCamData[nNumMachFromCam].Setup35 + elseif k == 36 then + sSetup = mCamData[nNumMachFromCam].Setup36 + elseif k == 37 then + sSetup = mCamData[nNumMachFromCam].Setup37 + elseif k == 38 then + sSetup = mCamData[nNumMachFromCam].Setup38 + elseif k == 39 then + sSetup = mCamData[nNumMachFromCam].Setup39 + elseif k == 40 then + sSetup = mCamData[nNumMachFromCam].Setup40 + elseif k == 41 then + sSetup = mCamData[nNumMachFromCam].Setup41 + elseif k == 42 then + sSetup = mCamData[nNumMachFromCam].Setup42 + elseif k == 43 then + sSetup = mCamData[nNumMachFromCam].Setup43 + elseif k == 44 then + sSetup = mCamData[nNumMachFromCam].Setup44 + elseif k == 45 then + sSetup = mCamData[nNumMachFromCam].Setup45 + elseif k == 46 then + sSetup = mCamData[nNumMachFromCam].Setup46 + elseif k == 47 then + sSetup = mCamData[nNumMachFromCam].Setup47 + elseif k == 48 then + sSetup = mCamData[nNumMachFromCam].Setup48 + elseif k == 49 then + sSetup = mCamData[nNumMachFromCam].Setup49 + elseif k == 50 then + sSetup = mCamData[nNumMachFromCam].Setup50 + end + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + if bSetUp then -- se importato il fle da CurrCamInfo + nContImport = nContImport + 1 + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + break + else -- se utensili mancanti prendo la lista e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else -- se non importato carico il messaggio di errore e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + end + end + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + -- se ho importato almeno un attrezzaggio do errore + if ( sDefSetUp and #sDefSetUp > 0) or + nContImport > 0 then + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] + else + DGD.EMC = ' ' .. EgtDoorsMsg[551] + end + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + else -- setup default non definito + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + end + end + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], MachName), 0) -- Error on machining calculation + + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], MachName)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) + EgtApplyAllMachinings( false, false) + + -- Salvo progetto + EgtSaveFile() + + -- Estimation + bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath) + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo la disposizione nel log + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + else + + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], MachName, sSetup) + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], MachName, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( string.format(EgtDoorsMsg[478], MachName, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false, nNumGroup + end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup +end + +return MachiningLoc diff --git a/Machining_2.lua b/Machining_2.lua new file mode 100644 index 0000000..867f262 --- /dev/null +++ b/Machining_2.lua @@ -0,0 +1,2966 @@ +-- +-- 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 +-- +-- Machining_2.lua by EgalWare s.r.l. 2016/23/05 +-- Autore: Dario Sassi +-- Machining generation for Doors program machine Multiax N1216 +-- 2017.06.01 V1.011 FM Manage machining optimization +-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece +-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2017.12.08 V1.015 FM Manage two new probe pointposition , before and after the hinge/pivot to probe always on left of hinge +-- (according to MDC door dispostion on table) +-- 2017.12.28 V1.016 FM Set note about hinge side machining +-- 2017.12.28 V1.016 FM Set note about hinge side profile +-- 2017.12.28 V1.016 FM Set note about door shift on Y with hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about door probe error on hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about lock side machining +-- 2018.02.22 V1.017 FM Fix rename offsetted probe geometry to leave enabled always the left probe geometry +-- (according to MDC door dispostion on table) +-- 2018.02.26 V1.0b1 FM Manage door dimension checking +-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces +-- 2018.10.18 V1.0b3 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles +-- 2018.10.19 V1.0b4 FM Make sure that use only enabled shuttle ( give nForceUseShuttle into AdjustHead) +-- 2018.10.23 V1.0b5 FM Manage rough machining +-- 2018.11.05 V1.0b6 FM Change the percentage of shuttle assignement to variable dPercentDoorLength (by Mark requests) +-- 2019.01.14 V1.0b7 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set +-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name) +-- 2019.01.23 V1.0b8 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. +-- 2019.01.24 V1.0b9 FM Extend cases to machine with AdjustHeadChisel operation, +-- use new settings to use with this extended operation: NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL +-- 2019.03.27 V1.0c1 FM Manage check door/jamb dimension by function CheckPieceDimension +-- 2019.03.27 V1.0c2 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values +-- 2019.03.27 V1.0c2 FM Modify error messages format into CheckPieceDimension +-- 2019.03.27 V1.0c3 FM Manage estimate time +-- 2019.03.29 V1.0c4 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.08 V1.0c5 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines +-- Now it uses 1 line for antisplint blade and 1 line for normal blade +-- 2019.04.08 V1.0c5 FM Manage Blade groove function AdjustBladeVertCurve +-- 2019.04.30 v1.0c6 FM Manage function AdjustASplintWithBlade to manage anti-splint paths when machine groove by blade +-- 2019.04.30 v1.0c6 FM Manage function AdjustHeadOnASplint to manage hinge anti-splint paths when machine groove by blade +-- 2019.05.28 v1.0c7 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings +-- 2019.07.22 V1.0c8 FM Manage better the updoor/underdoor machinings counter that generate flags values +-- 2019.08.27 V1.0c9 FM Manage underneath machining checking (by machining note 'UD_CHECK') to disable vacuums +-- (use new underneath distance by variable dDistInterferUnder) +-- 2020.03.19 V1.0d0 FM Fix error on check door dimension into CheckPieceDimension (when door is shifted by Bullnose profile on hinge side) +-- 2021.05.06 V1.0d1 FM Change the percentage of shuttle assignement to variable dPercentDoorLength if door length is more than 2700mm (long door limit) +-- 2021.05.28 V1.0d2 FM Add managing new one special code p6 +-- 2021.06.01 v1.0d3 FM Fix error on calculate piece box +-- 2021.10.28 V1.0d4 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter +-- 2022.07.27 V1.0d5 FM Modification to use compiled code +-- 2023.03.29 V1.0d6 FM Fix error on calculate rough paths on Convex profile +-- 2023.03.31 V1.0d7 FM Manage offsetted path ( by path note) to extra path of Convex profile +-- 2023.12.01 V1.0d8 FM Manage small planes on Convex profile + + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local MachiningLoc = {} + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() +-- Definizione disposizione porta ( a sinistra : 1, a destra : -1) +local DISPMODE = -1 +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) +local NO_WORK_UPSQUARE = false +-- Definizione possibilità di lavorare testa chisel rimanendo solo orizzontale o seguendo il bevel ( per teste non shuttle) +local CHISEL_ONLY_HORIZONTAL = false +-- variabili generazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true +-- Variabile distanza minima tra pezzo finito e ventosa (in X) +local DIST_MIN_VAC_L = 5 +local DIST_MIN_VAC_R = 7.5 +-- variabile per applicare sempre la lavorazione degli anti-scheggia fatti con gli shuttle ( >= 4 inserisce solo quelle necessarie, < 4 inserisce tutte) +-- in caso il groove sia fatto con lama +local MAXMACH = 4 +-- variabile che indica se sono state inserite lavorazioni da sotto +local bMachUnder +-- variabile dimensione porta considerata lunga che segna il diverso parcheggio dello shuttle 1 come è settata nella macro P5INIT +local Big_Dorr_Height +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.EMC) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** Add machining combine in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng + +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, + sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, + bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed ) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + + if nMach == 1 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMach) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachUp) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil, + nil, nil, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachDw) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + end + + return bOk, nNumMach, tMachining +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed ) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if ( tLocTable[i].Oper == 'AdjustHead' or tLocTable[i].Oper == 'AdjustHeadOnASplint') and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j]) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, + nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Movimento ventose *** +----------------------------------------------------------------- +local ThroughId, BlindId +----------------------------------------------------------------- +local function StartVacVerify( nIdSolid, bFlipped) + -- regioni passante e cieca non definite + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + -- recupero le regioni sopra e sotto della porta messa in macchina + local UpId, DwId + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + end + -- creo le regioni complementari + local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT) + local CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) + local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) + local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end + EgtSurfFrSubtract( CompUpId, UpId) + if not EgtExistsObj( CompUpId) then CompUpId = nil end + local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT) + local CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) + local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) + local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end + EgtSurfFrSubtract( CompDwId, DwId) + if not EgtExistsObj( CompDwId) then CompDwId = nil end + if CompDwId then EgtInvertSurf( CompDwId) end + -- calcolo le regioni passante e cieca + local ThroughRegId = nil + local BlindRegId = nil + -- se ci sono entrambe le regioni + if CompUpId and CompDwId then + -- per ottenere la regione passante faccio intersezione tra sopra e sotto + EgtSurfFrIntersect( CompUpId, CompDwId) + if EgtExistsObj( CompUpId) then + ThroughRegId = CompUpId + end + -- per ottenere la regione cieca faccio differenza tra sotto e passante + if ThroughRegId then + EgtSurfFrSubtract( CompDwId, ThroughRegId) + if EgtExistsObj( CompDwId) then + BlindRegId = CompDwId + end + else + BlindRegId = CompDwId + end + -- se c'è solo la regione sotto è già quella delle lavorazioni cieche + elseif CompDwId then + BlindRegId = CompDwId + -- se c'è solo la sopra, non interessa e la cancello + elseif CompUpId then + EgtErase( CompUpId) + end + -- sistemazioni finali + if ThroughRegId then + ThroughId = EgtGroup( GDB_ID.ROOT) + EgtSetName( ThroughId, 'THROUGH') + EgtSetColor( ThroughId, RED()) + EgtSetLevel( ThroughId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + EgtErase( ThroughRegId) + --EgtSetName( ThroughRegId, 'THROUGH') + --EgtSetColor( ThroughRegId, RED()) + --EgtSetLevel( ThroughRegId, GDB_LV.TEMP) + end + if BlindRegId then + BlindId = EgtGroup( GDB_ID.ROOT) + EgtSetName( BlindId, 'BLIND') + EgtSetColor( BlindId, BLUE()) + EgtSetLevel( BlindId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do + nChunk = nChunk + 1 + end + EgtErase( BlindRegId) + --EgtSetName( BlindRegId, 'BLIND') + --EgtSetColor( BlindRegId, BLUE()) + --EgtSetLevel( BlindRegId, GDB_LV.TEMP) + end +end + +----------------------------------------------------------------- +local function ExecVacVerify( ptVac, Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder) + -- verifica con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferThru then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferBlind then + return false + end + end + nId = EgtGetNext( nId) + end + + -- se ho delle lavorazioni da sotto + if bMachUnder then + local tUnderList = {} + tUnderList = MB.FindGeomWithNote( Pz, 'UnderneathMach', 'b', true, tUnderList) + for i = 1, #tUnderList do + local ptNear = EgtNP( tUnderList[i], ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferUnder then + return false + end + end + end + end + + -- nessuna interferenza + return true +end + +----------------------------------------------------------------- +local function EndVacVerify() + -- cancello regioni passante e cieca + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil +end + +----------------------------------------------------------------- +local function MoveVac( nGroupId, sName, dVal) + local nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sName) + local dOldVal = EgtGetInfo( nId, 'Val', 'd') + EgtMove( nId, Vector3d( 0, 0, dVal - dOldVal), GDB_RT.GLOB) + EgtSetInfo( nId, 'Val', dVal) +end + +----------------------------------------------------------------- +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +----------------------------------------------------------------- +local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + local bFailDim = false + local sErrMess = '' + local dLimitToCheck + + dLimitToCheck = dMinDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMinDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMaxDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMinDoorThick + if dThickDoor < dLimitToCheck then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorThick + if dThickDoor > dLimitToCheck then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + return bFailDim +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) + + --macchina e tabella di default + local MachName = 'Multiax-' + + -- Machinings Tables + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- References on table (respect Zero machine) + -- Y Table + local Ori1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + local Ori2 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftVac = Vector3d(0,0,0) + local vShiftAct = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + local vShiftLockSide = Vector3d(0,0,0) + -- variabile per posizione media della porta per il cambio navette + local dPosShuttleChange = 40 * GEO.ONE_INCH + -- tabella raggi profili su ogni lato + local tsRadiusProf = {} + local tsPlaneProf = {} + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- variabili pezzo singolo + local nPz + local sAssemb + + -- variabile check dimensioni porta + local bFailDim = false + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- elimino percorsi eventualmente creati dal Mach + -- cancello tutti i percorsi ghost + local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + + -- se la variabile è una tabella, estrapolo solo la porta + local PzIsTab = type(tPz) == 'table' + if PzIsTab then + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + + -- se non ha nota o nota della prima porta esco + if not sAssemb or ( sAssemb and sAssemb == 'first') then + break + end + end + else + Pz = tPz + sAssemb = tsAssemb + end + +-------------------------------------------------------------------------------- + -- Dati della porta + local sDoorCode = EgtGetInfo( Pz, 'Code') + local dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + local dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + local dThickDoor = EgtGetInfo( Pz, 'T', 'd') + local sSwing = EgtGetInfo( Pz, 'Swing') + MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente + local sSecure = EgtGetInfo( Pz, 'Secure') + local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + local sTopTrim = EgtGetInfo( Pz, 'top_trimming') + local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra + local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) + local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' ) + tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') + tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') + tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') + tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') + tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') + tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') + tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') + local dRadiusPrf = tsRadiusProf[1] + local dPlanePrf = tsPlaneProf[1] + local dNumHingesPivots = EgtGetInfo( Pz, 'NumHingesPivots', 'd') or 0 + local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + + -- Box pezzo + local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + + local b3fx = BBox3d() -- inizializzo il box nullo + b3fx = MakeBoxFromSolidLayer( Ls, 0, Aux) + local b3Solid = b3fx +-- local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + + ------------------------------------------------------ + -- se codice porta contiene comandi speciali + -- che non producono la generazione del part program della porta ma dei part program speciali + if sDoorCode then + local sCode = string.lower(sDoorCode) + if sCode == 'p1' or sCode == 'p2' or sCode == 'p3' or sCode == 'p4' or sCode == 'p5' or sCode == 'p6' then + EgtSetInfo( Pz, 'SpecialCmd', sCode) + end + end + ------------------------------------------------------ + +-------------------------------------------------------------------------------- + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + local TAB + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato + return false + end + local MachinesName = TAB.MMachineData + if not MachinesName then + DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable + return false + end + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + local TABORD + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + + local dMaxDoorLength + local dMinDoorLength + local dMaxDoorWidth + local dMinDoorWidth + local dMaxDoorThick + local dMinDoorThick + local nForceUseShuttle + local nForceDisableHood + local dAltRef + local dTallRef + local sLocSecure + local dMaxOverMat + local dStepOverMat + local dMaxDistToChain + local dExtraThruDepth + local nGenCncAsDdfName + local dBladePerpLeadIn + local dPercRedFeed + + -- imposto i dati macchina secondo le informazioni del file cam + MachName = mCamData[nNumMachFromCam].MachName + Ori1 = mCamData[nNumMachFromCam].Ori1 + Ori2 = mCamData[nNumMachFromCam].Ori2 + vShiftAct = mCamData[nNumMachFromCam].Shift1 + vShiftLockSide = mCamData[nNumMachFromCam].ShiftLck + dMaxDoorLength = mCamData[nNumMachFromCam].MaxDoorLength + dMinDoorLength = mCamData[nNumMachFromCam].MinDoorLength + dMaxDoorWidth = mCamData[nNumMachFromCam].MaxDoorWidth + dMinDoorWidth = mCamData[nNumMachFromCam].MinDoorWidth + dMaxDoorThick = mCamData[nNumMachFromCam].MaxDoorThick + dMinDoorThick = mCamData[nNumMachFromCam].MinDoorThick + nForceUseShuttle = mCamData[nNumMachFromCam].ForceShuttleUse + nForceDisableHood = mCamData[nNumMachFromCam].ForceDisableHood + dAltRef = mCamData[nNumMachFromCam].dAltRef + dTallRef = mCamData[nNumMachFromCam].dTallRef + sLocSecure = mCamData[nNumMachFromCam].sLocSecure + dMaxOverMat = mCamData[nNumMachFromCam].MaxOverMat + dStepOverMat = mCamData[nNumMachFromCam].StepOverMat or 10 + dMaxDistToChain = mCamData[nNumMachFromCam].MaxDistToChain + dExtraThruDepth = mCamData[nNumMachFromCam].ExtraThruDepthMachining + nGenCncAsDdfName = mCamData[nNumMachFromCam].nGenCncAsDdfName or 0 + dBladePerpLeadIn = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) + dPercRedFeed = mCamData[nNumMachFromCam].PercRedFeed or 0.3 + Big_Dorr_Height = mCamData[nNumMachFromCam].BigDoorHeight or 2700.0 + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], MachName), 0) -- warning. Cnc generation disable + return true + end + + -- setto come generare il nome del file cnc (di default è uguale al nome del parametro interno ad ddf) + if nGenCncAsDdfName == 0 then + -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi + sFileName = sDoorCode + end + + local MTable = TAB.MTable + local MTableOrd = TABORD.MTable + -- variabile principale per definizione disposizione porta a destra o sinistra + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftedDoor = false + local sDispMode + local sTotDispMode = '' + local sNumGroup = '' + local bWork = true + -- variabili utilizzate dentro al ciclo + local nMchId + local sTab + local tabOri + local Ori + local ColA + local nRaw + local bMoveRaw + local bPush + local bFlip + local bTopOnRight + -- variabili per disposizione sottopezzi + local dMobOffs + local dVacOffs + local dDistMinX + local dDistMaxX + local dVacOn + local dInterAx + local OffsXSovr = 0 + local OffsYSovr = 0 + local dDistInterferThru + local dDistInterferBlind + local dDistInterferUnder + -- variabile per tool setup + local MSetup + local sSetup + -- variabili calcolo box + local b3SolidOnTab + local pMin + local pMax + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local sMachProf + local bNoVertProf = true + local bWorkUnder = true + -- variabile per conteggio lavorazioni + local nNumMach + local nNumSkip + local tSecMachTab = {} + -- variabili per fase + local nNumPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + local nNumGeomBottomHole = 0 + local nNumGeomTopHole = 0 + -- variabili per geometrie lato Hinge + local nNumTopGeom = 0 + local nNumBottomGeom = 0 + -- variabile piazzamento porta + local sLight + -- variabile direzione riordino gruppi + local nDirReorderGroups + -- tabella lavorazioni + local tLocMach = {} + local tLocMachOrd = {} + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( MachName) + + ------------------------------------------------------------------------------------------------------- + -- per questa macchina è importante differenziare il nome del profilo lato lock rispetto al lato hinge + -- in modo che venga lavorato prima il lato hinge e poi il lock + ------------------------------------------------------------------------------------------------------- + -- Recupero le entità + local nLockProf + -- se serratura è a destra cerco il nome dl profilo corrispondente a quel lato + if bAtRight then + nLockProf = EgtGetFirstNameInGroup( Pz, 'Right') + else + nLockProf = EgtGetFirstNameInGroup( Pz, 'Left') + end + + local EntListHg = MB.FindEntities( nLockProf) + sLockTrim = sLockTrim..'_LK' + + -- rinomino tutte le entità del gruppo + for j = 1, #EntListHg do + local sNameEnt = EgtGetName( EntListHg[j]) + if not string.find( sNameEnt, '_LK') then + sNameEnt = sNameEnt .. '_LK' + end + EgtSetName( EntListHg[j], sNameEnt) + end + + -- faccio tutte le fasi ( probabilmente solo una perché non sono previsti ribaltamenti) + while bWork do + + sDispMode = '' + bMachUnder = nil + + nNumGroup = nNumGroup + 1 + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName) + else + nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName) + end + nNumPhase = EgtGetCurrPhase() + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + dLeftOffs = 0 + dRightOffs = 0 + dTopOffs = 0 + dBottomOffs = 0 + end + + ColA = Color3d( 255, 165, 0, 15) + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, + b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs, dBottomOffs, 0), nRaw) + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitare inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + tLocMach = MTable + tLocMachOrd = MTableOrd + sMachProf = '' + + -- prendo nota dei profili tipo bevel e bull nose + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + local nUnderGeom + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + local sUpperProfName = string.upper(tLocMach[i].Name) + -- prendo i profili bevel direttamente dalla tabella + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName) then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Test delle lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + nNumGeomBottomHole = nNumGeomBottomHole + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + nNumGeomTopHole = nNumGeomTopHole + 1 + end + end + end + end + end + end + end + + ----------------------- + -- *** Disposizione *** + ----------------------- + + -- controllo se ho profili bullnose sul lato hinge (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sHingeTrim == '1B' or sHingeTrim == '2B') then -- se profilo cerniere è bullnose + bShiftedDoor = true + end + + -- controllo se ho profili bullnose sul lato serratura (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK') then -- se profilo serratura indicato è bullnose + vShiftVac = vShiftLockSide + else + vShiftVac = vNullShift + end + + -- Scelta della tavola + sTab = 'Tab' + EgtSetTable( sTab) + + -- Origine tavola corrente rispetto a Zero macchina + tabOri = EgtGetTableRef( 1) + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + Ori = EgtIf( DISPMODE > 0, Ori1, Ori2) + + -- se porta da traslare setto lo shift da applicare + if bShiftedDoor then + vShift = vShiftAct + else + vShift = vNullShift + end + + Ori = Ori + vShift + + -- Rotazione porta in base alla macchina + bMoveRaw = false + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- se non c'è il parametro considero la porta come se avesse bevel down + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or + sSwing == 'LH' or sSwing == 'LHA' or sSwing == 'LHI' then + bPush = true + else + bPush = false + end + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. tostring( nNumPhase) + elseif nNumPhase then + sNumPhase = tostring( nNumPhase) + else + sNumPhase = '0' + end + + local bOkDisp = false + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure +-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel e da lavorare + if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or + ( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) +-- if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK') and bLockMach and not bOkDisp then + if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB_LK') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sLockTrim == 'BD_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BD_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- a meno che ho il profilo opposto, in questo caso non ribalto la porta, altrimenti devo ribaltare la porta + -- e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') and bPush) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and not bPush and not bOppoBevelProf) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and bPush and bOppoBevelProf) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or + ( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or + ( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore + if sSecure and string.upper(sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not sLocSecure or ( string.upper(sLocSecure) ~= 'UP' and string.upper(sLocSecure) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + sSecure = sLocSecure + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if sSecure and string.upper(sSecure) == 'UP' then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif sSecure and string.upper(sSecure) == 'DN' then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) quella di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + -- se porta a tirare non la ribalto perché si presta già ad essere bevel down + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + else -- in base alle geometrie trovate ribalto o meno la porta + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + else -- altrimenti vecchio metodo + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + end + end + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftedDoor then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local vExtraYDelta + local dExtraY = 0 + local dDeltaProbe = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ + + if sHingeTrim == 'SQ' or sHingeTrim == 'EB' then + nSideType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then + nSideType = 1 + if dThickDoor > dAltRef then + dExtraY = ( dThickDoor - dAltRef) * TAN3 + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY + -- se disposizione bevel up uso il riferimento in basso + elseif sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then + nSideType = 2 + dExtraY = ( dAltRef - dTallRef) * TAN3 + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sHingeTrim == '1B' or sHingeTrim == '2B' or + sHingeTrim == '3B' or sHingeTrim == '4B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( dAltRef - dTallRef) then + dAltcalc = dAltRef - dTallRef - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > dAltRef then + dAltcalc = dAltProf - dAltRef + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- se profilo convex verifico in base al raggio + elseif sHingeTrim == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = (dTallRef/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-((dAltProf-dPlanePrf)*(dAltProf-dPlanePrf))) + + -- se riferimento è sul max ingombro porta + if ( dThickDoor < dAltRef) and ( dThickDoor > ( dAltRef - dTallRef)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( dAltRef - (dTallRef/2)) then + dAltcalc = dAltRef - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( dAltRef - (dTallRef/2)) then + dAltcalc = dAltProf - dAltRef + dTallRef + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = dRadiusPrf - dExtraY + end + + -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota + if bHingeMach then + dExtraY = 0 + nHingeMach = 1 + dDeltaProbe = 0 + end + -- se profilo lock da lavorare setto la variabile per la nota + if bLockMach then + nLockMach = 1 + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'SideDisposition', DISPMODE) + -- scrivo nota disabilitazione cuffia + EgtSetInfo( Pz, 'ForceDisableHood', nForceDisableHood) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- scrivo nota tipo profilo lato hinge + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + + -- sommo il delta spostamento + Ori = Ori + vExtraYDelta + + -- Muovo porta con l'angolo indicato dal tipo di disposizione nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + if bShiftedDoor then + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, 'SHIFT') + else + -- salvo una nota con le info della disposizione normale + EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, 'NORMAL') + end + + if bFlip then -- se porta capovolta + if bTopOnRight then -- se top a destra + -- il lato sinistro è quello delle hinges + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato destro è quello delle hinges + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) + end + else -- altrimenti non è capovolta + if bTopOnRight then -- se top a destra + -- il lato destro è quello delle hinges + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato sinistro è quello delle hinges + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) + end + end + + -- Controllo dimensioni pezzo + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + vShift:getX(), vShift:getY(), dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + if bFailDim then + + DGD.ERR = 19 + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( DGD.EMC, 0) + EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + + ------------------------------------------------------------------------------------------------------------- + -- abilito/disabilito geometrie probe in base alla lavorazione del lato hinge e alla disposizione sulla tavola + ------------------------------------------------------------------------------------------------------------- + if bHingeMach then -- se profilo hinge è da lavorare rinomino nome entita + + -- Recupero le entità probe + local ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + -- Recupero le entità pivot + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + else -- profilo hinge non lavorato + + -- il probe deve essere sempre quello a sinistra rispetto al piazzamento + -- considerando lo swing perché le cerniere a seconda di questo vengono tuotate e il probe _POS e _NED risultano + -- scambiati rispetto al top della porta + local sProbeHingeToFind = '' + local sProbeHingeDis = '' + local sProbePivotToFind = '' + local sProbePivotDis = '' + + if DISPMODE > 0 then -- se disposizione a sinistra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + if not bTopOnRight then -- se top a sinistra + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + else -- top a destra + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + end + else + if not bTopOnRight then -- se top a sinistra + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + else -- top a destra + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + end + end + if not bTopOnRight then -- se top a sinistra + sProbePivotToFind = 'Pivot_Probe_NEG' + sProbePivotDis = 'NO_Pivot_Probe_NEG' + else -- se top è a destra + sProbePivotToFind = 'Pivot_Probe_POS' + sProbePivotDis = 'NO_Pivot_Probe_POS' + end + else -- disposizione a destra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + if bTopOnRight then -- se top a destra + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + else -- top a sinistra + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + end + else + if bTopOnRight then -- se top a destra + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + else -- top a sinistra + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + end + end + if bTopOnRight then -- se top a destra + sProbePivotToFind = 'Pivot_Probe_POS' + sProbePivotDis = 'NO_Pivot_Probe_POS' + else -- se top a sinistra + sProbePivotToFind = 'Pivot_Probe_NEG' + sProbePivotDis = 'NO_Pivot_Probe_NEG' + end + end + local ProbeList = MB.FindEntitiesWithName( Pz, sProbeHingeToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbeHingeDis) + end + ProbeList = MB.FindEntitiesWithName( Pz, sProbePivotToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbePivotDis) + end + end + + -- *** Lavorazioni *** + -- setto variabili in funzione della disposizione porta + local bMakeGhost = true + nDirReorderGroups = DISPMODE + local dPercentDoorLength + --------------------------------------------------------------------------------------------------------------------------- + -- 06/05/2021 in base al seguente avvenimento: porta lunga 3025 con 4 cerniere, 2 per ogni shuttle, e con una groove che + -- sborda sul lato cerniere. Alla chiamata della DANGER_L (nel Processo4) lo shuttle 1 a sinistra chiede di parcheggiare + -- nella posizione calcolata (L88) nel P5INIT che è a pacco con lo shuttle 2 nella parte destra della porta. L'arbitro non + -- da il consenso al parcheggio perchè la posizione è ancora occupata dallo shuttle 2 che sta lavorando e quindi manda + -- in parcheggio lo shuttle 1 fuori (tutto a sinistra) ma che, data la lunghezza elevata della porta, quando il gruppo 4 + -- andando a lavorare la groove vicino al lato hinge, rischia di collidere con lo shuttle 1. + -- Quindi per ovviare al problema è stato stabilito, in accordo con Carlo Viviani, di controllare per prima + -- la dimensione della porta, e se la lunghezza porta è maggiore del valore stabilito nella macro P5INIT nella variabile + -- L116 (ad oggi al valore 2700mm) allora la percentuale di distribuzione cerniere passa a 52% da sinistra in ogni caso + --------------------------------------------------------------------------------------------------------------------------- + if dLengthDoor >= Big_Dorr_Height then + dPercentDoorLength = EgtIf( DISPMODE > 0, 0.52, 0.48) + else + ------------------------------------------------------------------------------------------- + -- in base alla richiesta di Mark Offman 18/10/2018 + ------------------------------------------------------------------------------------------- + -- assegno una percentuale di 0.5 allo shuttle di sinistra (Mark 18/10/2018) + -- ma con 3 cerniere o 3 pivot, cambio la percentuale, cioè 0.4 da sinistra + dPercentDoorLength = EgtIf( DISPMODE > 0, EgtIf( dNumHingesPivots == 3 ,0.5, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.5)) + ------------------------------------------------------------------------------------------- + + ------------------------------------------------------------------------------------------- + -- Vecchia disposizione di Viviani + ------------------------------------------------------------------------------------------- + -- assegno una percentuale di 0.6 sempre verso lo shuttle di sinistra (Viviani 30/01/2017) + -- se disposta a sinistra assegno 0.6 da sinistra, se disposta a destra assegno 0.4 da destra, il risultato è quindi + -- sempre 0.6 da sinistra + -- ma con 3 cerniere o 3 pivot, inverto la percentuale, cioè sempre 0.4 da sinistra + -- dPercentDoorLength = EgtIf( DISPMODE > 0, EgtIf( dNumHingesPivots == 3 ,0.4, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) + ------------------------------------------------------------------------------------------- + end + + -- Se uso shuttle forzato su uno dei due shuttle cambio la percentuale + if nForceUseShuttle then + if nForceUseShuttle == 1 then + dPercentDoorLength = 0 + elseif nForceUseShuttle == 2 then + dPercentDoorLength = 1 + else + nForceUseShuttle = 0 + end + else + nForceUseShuttle = 0 + end + + -- scrivo la nota + EgtSetInfo( Pz, 'ForceShuttle', nForceUseShuttle) + + -- quanto segue nella sottostante spiegazione è stato cambiato + ---- determino la posizione del cambio shuttle utilizzando un coefficiente di 0.4 verso destra se il posizionamento è a destra + ---- e un coefficiente di 0.6 verso destra se il posizionamento è a sinistra, in modo + ---- da favorire lo shuttle che è dalla parte del riferimento ( a destra con assegnazione nMach a 2 e a sinistra con assegnazione nMach a 3) + dPosShuttleChange = EgtIf( DISPMODE > 0, Ori1:getX(), Ori2:getX()) + ( dLengthDoor * dPercentDoorLength * nDirReorderGroups) + ( OffsXSovr * nDirReorderGroups) + tabOri:getX() + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + local tOrderGrp = {} + + -- print Machining table + -- solo il primo giro: aggiusto i profili bevel per essere coerente con la sequenza di tabella + -- riordino i gruppi geometrici che hanno l'operazione AdjustHead o AdjustHeadOnASplint in ordine di X decrescente + for i = 1, #tLocMach do + + -- print Machining table + DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper then + if tLocMach[i].Oper == 'AdjustBevel' then + local sNewName + _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf) + elseif tLocMach[i].Oper == 'AdjustHead' or tLocMach[i].Oper == 'AdjustHeadOnASplint' then + -- nDirReorderGroups = -1 = ordine decrescente ( da dx a sx <--); nDirReorderGroups = 1 ordine crescente ( da sx a dx -->) + MB.ReorderGroup( EntList[j], tOrderGrp, nDirReorderGroups) + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + nValAppo = nNumGeomBottomHole + nNumGeomBottomHole = nNumGeomTopHole + nNumGeomTopHole = nValAppo + end + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = 1, #tLocMach do + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + + local bAdjustHead = false + local nNewIdEnt + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' then + + local sNewName + bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf, bMakeGhost) + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + end + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' then + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc) + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andata a buon punto vedo di sottrarle ai contatori degli skip + if nMach == 1 then + if nNumGeomTop > 0 then + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottom > 0 then + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' then + bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadChisel' then + bLocMach, nNewIdEnt, nNumMachSkipResult = MB.AdjustHeadChisel( EntList[j], bMakeGhost, CHISEL_ONLY_HORIZONTAL, nNumMachSkip, NO_WORK_UPSQUARE, NO_WORK_UNDERSQUARE) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andato a buon fine, verifico di sottrarlo alle variabili skip + if nMach == 1 then + if nNumGeomTopHole > 0 then + nNumGeomTopHole = nNumGeomTopHole - 1 + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottomHole > 0 then + nNumGeomBottomHole = nNumGeomBottomHole - 1 + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustHole' then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHead' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHead( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadOnASplint' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHeadOnASplint( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nil, + DISPMODE, bFlip, MAXMACH) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then + bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustASplintWithBlade' then + bOk, nNewIdEnt = MB.AdjustASplintWithBlade( EntList[j], bMakeGhost, DISPMODE, bFlip) + end + else -- se nessuna operazione + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + end + + -- LAVORAZIONI + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + if bAdjustHead and nMach > 0 and nMach < 4 then -- se navette + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = FindAndCalcGroupMachining( EntList[j], nNewIdEnt, tLocMach, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed) + elseif nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, + NOT_GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + else + if not bAdjustHead then + DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') .. + EgtDoorsMsg[596]..tostring( nNumPhase), 0) + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end + + local i = 1 + while i <= #tLocMachOrd do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGrp = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) + + if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0 + + if sProperty == 'MinDist' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local tMachining = {} + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se lavorazione esiste e corrisponde e numero lavorazione è = 1 + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, tMachining, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + elseif sProperty == 'Shuttle' then -- lavorazione con shuttle + + -- per ogni layer padre nella lista fatta con il reordergroup + for k = 1, #tOrderGrp do + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( tOrderGrp[k][1], true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, tOrderGrp[k][1], tGroup, nMach, nNumGrp, + nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + end + elseif sProperty == 'Layer' then -- lavorazione layer + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE') + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, + nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + end + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + end + elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore + DGD.ERR = -15 + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + if DGD.ERM and #DGD.ERM > 0 then + DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + end + + i = i + 1 + end + + ---------------------------------------- + -- Inserimento riferimenti e ventose + ---------------------------------------- + + -- Offset ventose da bordo pezzo in Y + dVacOffs = 52 + -- Offset barra riferimenti mobile da riferimenti quando posizione 0 + dMobOffs = 160 + 65 + -- Lunghezza minima per alzare prima ventosa da bordo sinistro + dDistMinX = 120.61 + 40 + DIST_MIN_VAC_L -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Lunghezza minima per alzare prima ventosa da bordo destro + dDistMaxX = 168.2 + 40 + DIST_MIN_VAC_R -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Posizione ventose in alto + dVacOn = 110 + -- Interasse ventose + dInterAx = 232 + -- distanza interferenza con cave passanti + dDistInterferThru = 42 + 8 -- modificato da 8 a 12 il 21/12/2017 su richiesta di Mark + dDistInterferBlind = 42 + 45 + dDistInterferUnder = 42 + 55 + + -- Ventose + local nTabId = EgtGetTableId( 'Tab') + local nMobId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE') + local nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') + local nDispId = EgtGetPhaseDisposition( nNumPhase) + -- se gruppi richiesti non trovati + if not nMobId or not nFixId then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' + break + end + -- Posizionamento barra mobile + local dOldVal = EgtGetInfo( nMobId, 'Val', 'd') + -- calcolo nuova posizione con: larghezza finita porta ( uso getDimX perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento in basso - distanza ventose - offset barra + local dNewVal = b3Solid:getDimX() + OffsYSovr + vShift:getY() + vShiftVac:getY() - dVacOffs - dMobOffs + EgtMove( nMobId, Vector3d( 0, dNewVal - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId, 'Val', dNewVal) + EgtSetInfo( nDispId, 'MOB', dNewVal) + -- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa + local dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( DISPMODE > 0, dDistMinX, dDistMaxX) + + -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto + StartVacVerify( Ls, bFlip) + + -- ciclo sulle ventose + local nInd = 1 + local nIndVac + local nNumTotVacRow = 13 + local nCountFailed = 0 + local nIniFailed = 0 + local nMiddleFailed = 0 + local nEndFailed = 0 + local nMaxIniFailed = 0 + local nMaxMiddleFailed = 0 + local nMaxEndFailed = 0 + + while dCalcLen > 0 and nInd <= nNumTotVacRow do + + nIndVac = EgtIf( DISPMODE > 0, nInd, ( nNumTotVacRow - nInd + 1)) + + local sInd = tostring( nIndVac) + + -- eseguo verifica + local nCenFixId = EgtGetFirstNameInGroup( nFixId, 'CEN'..sInd) + local bCanUpFix = ExecVacVerify( EgtSP( nCenFixId, GDB_ID.ROOT), Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder) + local nCenMobId = EgtGetFirstNameInGroup( nMobId, 'CEN'..sInd) + local bCanUpMob = ExecVacVerify( EgtSP( nCenMobId, GDB_ID.ROOT), Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder) + -- eventuale movimento + if bCanUpFix and bCanUpMob then + -- alzo le due ventose + MoveVac( nFixId, 'VAC'..sInd, dVacOn) + MoveVac( nFixId, 'ROD'..sInd, dVacOn) + MoveVac( nMobId, 'VAC'..sInd, dVacOn) + MoveVac( nMobId, 'ROD'..sInd, dVacOn) + -- salvo lo stato + EgtSetInfo( nDispId, 'VAC'..sInd, dVacOn) + -- interrompo le serie negative + if nInd > 1 then + nCountFailed = 0 + if nMaxIniFailed < nIniFailed then + nMaxIniFailed = nIniFailed + end + if nMaxMiddleFailed < nMiddleFailed then + nMaxMiddleFailed = nMiddleFailed + end + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nIniFailed = 0 + nMiddleFailed = 0 + nEndFailed = 0 + end + else + EgtRemoveInfo( nDispId, 'VAC'..sInd) + nCountFailed = nCountFailed + 1 + if nInd == 1 then -- setto solo il fallimento iniziale + nIniFailed = nCountFailed + elseif nInd == nNumTotVacRow or ( dCalcLen - dInterAx) <= 0 then -- setto solo quello finale e annullo il medio + nEndFailed = nCountFailed + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nMiddleFailed = 0 + else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati + if nIniFailed > 0 then + nIniFailed = nCountFailed + elseif nEndFailed > 0 then + nEndFailed = nCountFailed - 1 + else + nMiddleFailed = nCountFailed + end + end + end + -- aggiorno la lunghezza di calcolo e l'indice + dCalcLen = dCalcLen - dInterAx + nInd = nInd + 1 + end + -- elimino geometrie per verifica + EndVacVerify() + + -- riassegno la quantità di file che effettivamente potrebbero essere alzate + nInd = nInd - 1 + + -- casi di scarse ventose + if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then -- tutte le ventose basse + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + elseif nInd > 0 and nMaxIniFailed / nInd > 0.25 then -- ventose iniziali ( parte destra) + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then -- ventose intermedie + DGD.EMC = ' ' .. EgtDoorsMsg[533] + bOk = false + break + elseif nInd > 0 and nMaxEndFailed / nInd > 0.25 then -- ventose finale ( parte sinistra) + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then -- somma di vari intervalli + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + end + + ------------------------------------------------- + -- gestione messaggi LIGHT: red, yellow, green + ------------------------------------------------- + + -- se ho geometrie da entrambe le parti la luce è red + if nNumGeomBottom > 0 and nNumGeomTop > 0 then + sLight = 'RED' + -- se non ho geometrie la luce è green + elseif nNumGeomBottom == 0 and nNumGeomTop == 0 then + sLight = 'GREEN' + -- se una delle due ha delle geometrie + else + -- in caso di geometrie tutte sotto luce yellow + if nNumGeomBottom > 0 then + sLight = 'YELLOW' + -- in caso di geometrie tutte sopra luce green + elseif nNumGeomTop > 0 then + sLight = 'GREEN' + end + end + + -- *** Tools Setup *** + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + local bSetUp = EgtImportSetup() + local tListError + local sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + end + + -- se fallito quello di default o utensili mancanti provo quello indicato nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + sSetup = mCamData[nNumMachFromCam].Setup1 + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + if sDefSetUp and #sDefSetUp > 0 then + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] + else + DGD.EMC = ' ' .. EgtDoorsMsg[551] + end + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + break + else + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + else -- ha importato il fle da CurrCamInfo + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- se utensili mancanti + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', 1) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + DGD.EMC = DGD.EMC .. sListTool + bOk = false + break + end + end + end + + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + -- per interrompere il giro forzatamente ( perché nessun ribaltamento) setto bWork + bWork = false + end + + nNumCycle = nNumCycle + 1 + end -- end while + +--bOk = false -- per forzare l'errore + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], MachName), 0) -- Error on machining calculation + + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], MachName)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) + EgtApplyAllMachinings( false, false) + + -- Salvo progetto + EgtSaveFile() + + -- Estimation + bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath) + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + + -- luce di caricamento porta + if sLight then + DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM + end + + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + else + + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], MachName, sSetup) + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], MachName, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( string.format(EgtDoorsMsg[478], MachName, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + + return false, nNumGroup + end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup +end + +return MachiningLoc diff --git a/Machining_3v3.lua b/Machining_3v3.lua new file mode 100644 index 0000000..9b83e5d --- /dev/null +++ b/Machining_3v3.lua @@ -0,0 +1,7544 @@ +-- +-- 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 +-- +-- Machining_3v3.lua by EgalWare s.r.l. 2019.02.05 +-- Autore: Filippo Monchi +-- Machining generation for Doors program machine Multiax NE +-- New mode to manage properties and manage materials, manage 2 tables + +-- 2017.06.05 V1.011 DS Fix main cycle at 10 times +-- 2017.06.13 V1.012 FM Manage machining optimization +-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece +-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2018.02.26 V1.0b1 FM Manage piece dimension checking +-- 2018.03.01 V1.0b2 FM use a table tMainTabPar instead of many variables ( more than 200 variables) +-- 2018.03.22 V1.0b3 FM Manage checking effective lock/hinge side machining and adjust the second disposition. Before not recognize if +-- lock/hinge side was machined or not in 1st phase +-- 2018.03.23 V1.0b4 FM Manage parameter for probe extra Z position and adjust probe error values +-- 2018.03.23 V1.0b4 FM Fix problem on second phase disposition by side path notes +-- 2018.05.04 V1.0b5 FM Fix write 2nd phase disposition notes when first phase is empty and substitute by second phase +-- 2018.05.09 V1.0b6 FM Fix error message on vacuums disposition +-- 2018.05.09 V1.0b6 FM Calculate the solid box without extra surfaces +-- 2018.06.18 V1.0b7 FM Manage door in probe mode and rebuilded +-- 2018.06.22 V1.0b8 FM Manage second phase on rebuilded door and fix some bugs +-- 2018.06.26 V1.0b9 FM Manage to use 2 bars with small width door +-- 2018.06.27 V1.0c1 FM write note about number of probez geometries and if generate one of their machinings +-- 2018.07.17 V1.0c2 FM Manage vacuum disposition: in case it uses only 2 bars use the vacuum for 3rd bar on 2nd bar +-- 2018.07.24 V1.0d1 FM Read Properties (start managing properties) +-- 2018.08.22 V1.0d2 FM Fix error on calculare roughing on bevel side profiles +-- 2018.08.29 V1.0d3 FM Manage Arc Vacuum for top arc doors +-- 2018.08.31 V1.0d4 ES Manage door with property 'narrowstile' (force door position like frame position, force to use smaller vacuum on 1st ad 3rd bars ) +-- 2018.08.31 V1.0d5 ES Manage jamb position by parameter MachineJambsTogether from CurrCamInfo.lua +-- 2018.10.17 V1.0d6 FM Fix error on Manage vacuum disposition: in case it uses only 2 bars use the vacuum for 3rd bar on 2nd bar +-- 2019.01.10 V1.0d7 FM Manage assignement of dMinDistGroup variable from CurrCamInfo.lua file (by optional variable dMinDistBetweenBars) +-- 2019.01.11 V1.0d8 FM Manage better group note Mach2nd to fix a problem of double machining (on 1st and 2nd phase) of same geometries into same group +-- 2019.01.14 V1.0d9 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set +-- which name use to generate the cnc file (by default as ddf file name) +-- 2019.01.18 V1.0e1 FM Remove empty phase (after the first one) +-- 2019.01.21 V1.0e2 FM if machine can work underneath (by bWorkUnder) and fail to machine thru drill, +-- try to apply also the underneath machining (If present into Mtable) +-- 2019.01.23 V1.0d8 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. +-- 2019.01.31 V1.0d9 FM Move on CurrCamInfo file the vacuums data definition: point name on bars, name vacuum type, name vacuum type with lifter +-- radius to apply on any type of vacuum +-- 2019.02.01 V2.001 FM Change version by Egtcam5 new version +-- 2019.02.01 V2.002 FM Manage 3 kind of vacuums for bar 1 and bar3 (on bar 2 only 1 type) +-- 2019.02.01 V2.002 FM Rewrite function CalcDispositionSubPieces to manage better information of vacuums type (by use table of tables ttBaseDataVac) +-- 2019.02.04 V2.003 FM Define version 2 to indentificate the new mode to calculate vacuums: Machining_3v2.lua +-- 2019.02.04 V2.004 FM Manage new Egt function to calculate vacuums position (that use region defined into vacuum nge file) +-- 2019.02.08 V2.005 FM Fix bug into CalcDispositionSubPieces when it's missing a vacuum lock point on nge machien table, and print a log message too +-- 2019.02.18 V2.006 FM Manage better bar position and calculate better the bars position according by overmaterial +-- 2019.02.19 V2.007 FM Manage check door/jamb dimension by function CheckPieceDimension +-- 2019.02.25 V2.008 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values +-- 2019.02.25 V2.008 FM Modify error messages format into CheckPieceDimension +-- 2019.03.22 V2.009 FM Change % values of middle bar into function CheckEnoughVacuums +-- 2019.03.27 V2.00a FM Manage estimate time +-- 2019.03.29 V2.00b FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.08 V2.00c FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines +-- Now it uses 1 line for antisplint blade and 1 line for normal blade +-- 2019.04.08 V2.00c FM Manage Blade groove function AdjustBladeVertCurve +-- 2019.04.11 V2.00d FM Manage special arc vacuum disposition as standard vacuum check (that use vacuum region) by function InsertSpecialSubPiece +-- 2019.05.28 V2.00e FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings +-- 2019.07.02 V2.00f FM Fix error on AdjustProbeHole section, if its machining is not present into MTable it cause the flip door on 2nd phase +-- 2019.07.09 V2.010 FM On Vacuum disposition now it consider also the external rectangular region of bottom face into StartVacVerify, +-- ExecVacVerify, ExecVacShapeVerify, EndVacVerify. it uses the new CurrCamInfo dSafetyDistVacSide and +-- dArcSafetyDistVacSide variables to compare the vacuum distance to external side path +-- 2019.07.09 V2.010 FM Disable re-calculate bars position on 2nd phase (and next phases) +-- 2019.07.09 V2.010 FM On 1st Mtable scan modify the condition about shifted door, before it skip also by narrow style door (because it results shifted door), +-- Now it skip olny shifted doors but not in case the door is narrow stile +-- 2019.07.09 V2.010 FM Modify the % of not disposed vacuum on middle bar, now is 55%. +-- When external bar have enough vacuums, the middle bar can accept less vacuums +-- 2019.07.09 V2.010 FM Insert Arc Vacuum also in case on the bar is admitted only 1 vacuum type (arc vacuum is a special vacuum that has another code) +-- 2019.07.17 V2.011 FM Add Tolerance on horizontal drill by GangDrill: add nProbeMode variable to AdjustHorizDrillX and AdjustHorizDrillY function call +-- 2019.07.18 V2.012 FM Manage better the rare case to invert a single thru path (machining on top) if all others paths are machined in second phase +-- and the opposite case ( a single thru path machine on bottom and all other paths machined fist phase). near line 2296 +-- 2019.09.12 V2.013 FM Manage machine with 2 or more tables +-- 2019.09.16 V2.014 FM Manage properties definition into CurrDoorCustomData (as DGC. variables), and his identification into Main, stop here. +-- 2019.09.16 V2.014 FM Stop Manage properties definition into CurrDoorCustomData (as DGC. variables), and his identification into Main +-- 2019.10.17 V2.015 FM New Managing of materials (steel) and properties +-- 2019.10.17 V2.016 FM Add note into piece of table used +-- 2019.10.24 V2.017 FM Add blind geometries (made by components) into blind group +-- 2019.11.12 V2.018 FM Manage disposition of Top Chamfer shape by using 3 number code (1st for top rectangle, 2nd for top arc, 3rd for top angle) +-- 2019.11.14 V2.014 FM Manage door resize machining, only on sides not at reference +-- 2019.11.27 V2.015 FM Write new error message into log file if vacuum model are too old and without region (into ExecVacShapeVerify function) +-- 2019.12.03 V2.016 FM Basic collision detection for underneath aggregate with references +-- include Reference Disposition on table (it need references data into CurrCamInfo) +-- 2020.06.05 V2.020 FM Manage aluminum doors and frame disposition on narrow side and wide side +-- 2020.06.11 V2.021 FM Manage number pods on any bars by CurrCamInfo variable ( tMainTabPar.NTVR) +-- 2020.06.25 V2.021 FM Check better if table is set right (and show error message when happen error) +-- 2020.07.02 V2.022 FM Manage clamp subpieces with jambs ( only with single jamb on first bar) +-- 2020.10.02 V2.023 FM Manage frame disposition head by new CurrCamInfo parameter FrameTopSideDriveDisp +-- 2020.10.14 V2.024 FM Set Piece Type info for machine post pprocessor (mlpe) +-- 2020.11.03 V2.025 FM Extend values of CurrCamInfo FrameTopSideDriveDisp parameter to customize the header (frame top) disposition +-- 2021.04.06 V2.100 FM Now int ExecVacShapeVerify function it search double pod region (1st is standard region as before, 2nd one region is for blind geometries) +-- The 2nd region is bigger than 1st region and could be equal or bigger than base pod area +-- 2021.05.03 V2.101 FM Manage simulation in background to verify collisions, if something collide, not generate CNC program +-- 2021.05.04 V2.102 FM Manage new CurrCamInfo parameter (nDisableAutoCncName) to disable the automatic cnc name composed when generate cnc by GENERATE button +-- to have always the same cnc file name +-- 2021.05.20 V2.103 FM Manage new CurrCamInfo parameter (EnableCollisionDetect) to enable/disable the collision detect +-- 2021.05.24 V2.104 FM Add the CurrCamInfo machine name as a note +-- 2021.07.23 V2.105 FM Fix error on not return to Machining.lua the variable nNumGroup +-- 2021.10.28 V2.106 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter +-- 2021.11.23 V2.107 FM Manage option side probing. Expand function number of CurrDoorCustomData DGC.Pms: 3 side probe on all hardware (for NE machines) ; +-- 4: side probe on all hardware except hardware on hinge side (for machines with shuttles) +-- 2022.01.17 V2.108 FM Manage Split door cut by new CurrCamInfo parameter sCutDirectionAdmitted: = 'H' for cut along door Height; +-- = 'W' for cut along door Width +-- 2022.01.18 V2.109 FM Manage rectangle CutOut clean corners by cone tool on tilting aggregate and generate machine stop before execute these machinings +-- 2022.05.03 V2.110 FM Use EgtNumToString function instead of tostring +-- 2022.07.06 V2.111 FM Fix error ino machining section on not check if exists the new path nNewIdEnt +-- 2022.11.15 V2.112 FM Manage side groove region as throu path and not as blind region +-- 2022.07.27 V2.114 FM Modification to use compiled code +-- 2023.01.20 V2.115 FM Manage vacuums with custom type number +-- 2023.03.07 V2.116 FM Fix error on manage region into StartVacVerify function +-- 2023.03.29 V2.117 FM Fix error on calculate rough paths on Convex profile +-- 2023.03.31 V2.118 FM Manage offsetted path ( by path note) to extra path of Convex profile +-- 2023.04.03 V2.119 FM Manage Scrap piece removing +-- 2023.05.12 V2.120 FM Manage virtual milling option into collision avoid check +-- 2023.05.24 V2.121 FM Manage by new function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides +-- 2023.05.26 V2.122 FM Manage new CurrCamInfo parameter ExportTableView to export 3d table view ( disposed door + table) with html format +-- or export piece view with png format +-- 2023.12.01 V2.123 FM Manage small planes on Convex profile +-- 2024.03.11 V2.124 FM Add to piece the further info (from CurrCamInfo): dAltRef, dTallRef +-- 2024.03.14 V2.125 FM Manage new CurrCamInfo parameter dMaxPosMobBar to check if 2nd bar position not go over than max value +-- 2024.06.19 V2.126 FM Manage new DGD.GHT to let with suffix '_HIDE' ( or '_2HIDE' to manage the machining geometries on different machines (like Five lakes machines)) +-- 2024.12.03 V2.127 FM Fix error on checking the machining BBox3d, now also add :isEmpty() +-- 2024.12.20 V2.128 FM Change error numbers ( used into main.lua): 26 -> 34, 28 -> 35 + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local MachiningLoc = {} + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() + +----------------- SETTAGGI ------------------------------------------------- +-- Definizione disposizione pezzi ( a sinistra : 1, a destra : -1) +local DISPMODE = -1 +-- Variabile distanza minima tra pezzo finito e ventosa (in X) +local DIST_MIN_VAC = 5.5 +-- variabile numero tavole utilizzate (al momento utilizzata solo per smistare differenti materiali di porta) +local NUMTABLE = 1 + +----------------- COSTANTI ------------------------------------------------- +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) +local NO_WORK_UPSQUARE = true +-- variabili genarazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true +---------------- VARIABILI GLOBALI ----------------------------------------- +-- variabili disposizione porta +local bPush +local bFlip +local bNoVertProf = false -- true: for 5 axif head, leave not vertical path (like bevel) false: for 4 axis head, modify not vertical path to vertical +local bWorkUnder = true + +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. EgtNumToString( DGD.ERR, 0) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. EgtNumToString( DGD.ERR, 0)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. EgtNumToString( DGD.ERR, 0) .. DGD.EMC) + else + nIdFile:write( 'Err=' .. EgtNumToString( DGD.ERR, 0)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +local function GetChoice() + + local sChoice = 'CB:' + sChoice = sChoice .. '1 : Top on Right' .. ',' .. '2 : Top on Left' + local sChose + local tChose = EgtDialogBox( 'Set Header Disposition', { 'Header Top dispose on: ', sChoice }) + + if tChose then + sChose = tChose[1] + else + return + end + + if sChose then + local PosComm = sChose:find('1', 1, true) + if PosComm and PosComm == 1 then + return true + else + return false + end + else + return + end +end + +----------------------------------------------------------------- +-- *** calculate door disposition by parameters *** +----------------------------------------------------------------- +local function CalcTopPosition( nTopSideDriveDisp, bAtRight, dTopRadius, dTopAngle, sFrameName) + local bTopOnRight + + -- controllo se la variabile ha la tripla cifra + if nTopSideDriveDisp and nTopSideDriveDisp > 100 then + -- se porta ad angolo + if dTopAngle then + -- guardo la cifra meno significativa + nTopSideDriveDisp = nTopSideDriveDisp - 100 + if nTopSideDriveDisp > 100 then + nTopSideDriveDisp = nTopSideDriveDisp - 100 + end + nTopSideDriveDisp = nTopSideDriveDisp - 10 + if nTopSideDriveDisp > 10 then + nTopSideDriveDisp = nTopSideDriveDisp - 10 + end + if nTopSideDriveDisp == 1 then + bTopOnRight = true + else + bTopOnRight = false + end + elseif dTopRadius then -- altrimenti se è una porta ad arco + -- guardo la seconda cifra meno significativa + nTopSideDriveDisp = nTopSideDriveDisp - 100 + if nTopSideDriveDisp > 100 then + nTopSideDriveDisp = nTopSideDriveDisp - 100 + end + if nTopSideDriveDisp >= 20 then + bTopOnRight = false + else + bTopOnRight = true + end + else -- altrimenti è rettangolare + if nTopSideDriveDisp >= 200 then + bTopOnRight = false + else + bTopOnRight = true + end + end + -- controllo se la variabile ha la doppia cifra + elseif nTopSideDriveDisp and nTopSideDriveDisp > 10 then + -- se porta ad arco o ad angolo + if dTopRadius or dTopAngle then + -- guardo la cifra meno significativa + nTopSideDriveDisp = nTopSideDriveDisp - 10 + if nTopSideDriveDisp > 10 then + nTopSideDriveDisp = nTopSideDriveDisp - 10 + end + if nTopSideDriveDisp == 1 then + bTopOnRight = true + else + bTopOnRight = false + end + else -- altrimenti porta rettangolare + + -- Nel caso della disposizione frame, se è il frame top (header) e ho la cifra più significativa == 1 ( quindi valori 11 o 12) + -- allora lancio una richiesta di input all'utente. + -- Se frame top e parametro coerende con disposizione personalizzata + if sFrameName == 'frametop' and nTopSideDriveDisp >= 10 and nTopSideDriveDisp < 20 then + -- lancio richiesta input utente + bTopOnRight = GetChoice() + -- se restituisce nill, scelgo il vecchio metodo + if bTopOnRight == nil then + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + elseif nTopSideDriveDisp >= 20 then -- altrimenti se non è un frame mi baso sulla cifra più significativa + -- guardo la cifra più significativa + if nTopSideDriveDisp >= 20 then + bTopOnRight = false + else + bTopOnRight = true + end + -- negli altri casi considero la cifra meno significatica + else + -- riduco ad una sola cifra + repeat + if nTopSideDriveDisp >= 10 then + nTopSideDriveDisp = nTopSideDriveDisp -10 + end + until nTopSideDriveDisp < 10 + if nTopSideDriveDisp == 2 then + bTopOnRight = false + else + bTopOnRight = true + end + end + end + -- ha cifra singola: non si fanno distinzioni tra porte ad arco o ad angolo o normali + elseif nTopSideDriveDisp then + if nTopSideDriveDisp == 1 then + bTopOnRight = true + else + bTopOnRight = false + end + else + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + + return bTopOnRight +end + +----------------------------------------------------------------- +-- *** Add Machining in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng +end + +----------------------------------------------------------------- +-- *** Vacuums disposition *** +----------------------------------------------------------------- +local ThroughId, BlindId, FaceDwId +----------------------------------------------------------------- +local function StartVacVerify( nIdSolid, bFlipped, nProbeMode, dThDoor, bFlipFrame) + -- regioni passante e cieca non definite + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + EgtErase( FaceDwId or GDB_ID.NULL) + FaceDwId = nil + -- recupero le regioni sopra e sotto della porta messa in macchina + local UpId, DwId + local UpId2, DwId2 + local DwIdExtraBlind = {} + local sExtraBlindRegName + local DwIdExtraGrvBlind = {} + local sExtraGrvBlindRegName + local dZedToMove + -- se porta ribaltata + if bFlipped or bFlipFrame then + if nProbeMode == 2 then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie a contatto con le ventose + DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) + -- superficie sopra + UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + end + sExtraBlindRegName = 'FLAT_UP_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_UP_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = dThDoor + else + if nProbeMode == 2 then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie a contatto con le ventose + DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) + -- superficie sopra + UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + end + sExtraBlindRegName = 'FLAT_DW_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_DW_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = 0 + end + -- creo le regioni complementari + local CompUpId + if nProbeMode == 2 then + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nCurveId = EgtExtractSurfFrChunkLoops( UpId2, 0, nRecId) -- prendo il contorno della regione piena + CompUpId = EgtSurfFlatRegion( nIdSolid, nCurveId) -- creo regione rettangolare piena + else + local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT) + CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) -- creo regione rettangolare piena + end + local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) + local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end + EgtSurfFrSubtract( CompUpId, UpId) + if not EgtExistsObj( CompUpId) then CompUpId = nil end + + local CompDwId + if nProbeMode == 2 then + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nCurveId = EgtExtractSurfFrChunkLoops( DwId2, 0, nRecId) + CompDwId = EgtSurfFlatRegion( nIdSolid, nCurveId) + else + local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT) + CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) + end + -- faccio una copia per gli altri controlli + local DownRegId = nil + if CompDwId then + DownRegId = EgtCopyGlob( CompDwId, nIdSolid) + EgtInvertSurf( DownRegId) + end + local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) + local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end + EgtSurfFrSubtract( CompDwId, DwId) + if not EgtExistsObj( CompDwId) then CompDwId = nil end + if CompDwId then EgtInvertSurf( CompDwId) end + + -- calcolo le regioni passante e cieca e contorno + local ThroughRegId = nil + local BlindRegId = nil + -- se ci sono entrambe le regioni + if CompUpId and CompDwId then + -- per ottenere la regione passante faccio intersezione tra sopra e sotto + EgtSurfFrIntersect( CompUpId, CompDwId) + if EgtExistsObj( CompUpId) then + ThroughRegId = CompUpId + end + -- per ottenere la regione cieca faccio differenza tra sotto e passante + if ThroughRegId then + EgtSurfFrSubtract( CompDwId, ThroughRegId) + if EgtExistsObj( CompDwId) then + BlindRegId = CompDwId + end + else + BlindRegId = CompDwId + end + -- se c'è solo la regione sotto è già quella delle lavorazioni cieche + elseif CompDwId then + BlindRegId = CompDwId + -- se c'è solo la sopra, non interessa e la cancello + elseif CompUpId then + EgtErase( CompUpId) + end + -- sistemazioni finali + if ThroughRegId or #DwIdExtraGrvBlind > 0 then + ThroughId = EgtGroup( GDB_ID.ROOT) + EgtSetName( ThroughId, 'THROUGH') + EgtSetColor( ThroughId, RED()) + EgtSetLevel( ThroughId, GDB_LV.TEMP) + local nChunk = 0 + if ThroughRegId then + while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraGrvBlind do + local nIdBl = DwIdExtraGrvBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + EgtErase( ThroughRegId) + --EgtSetName( ThroughRegId, 'THROUGH') + --EgtSetColor( ThroughRegId, RED()) + --EgtSetLevel( ThroughRegId, GDB_LV.TEMP) + end + if BlindRegId or #DwIdExtraBlind > 0 then + BlindId = EgtGroup( GDB_ID.ROOT) + EgtSetName( BlindId, 'BLIND') + EgtSetColor( BlindId, BLUE()) + EgtSetLevel( BlindId, GDB_LV.TEMP) + local nChunk = 0 + if BlindRegId then + while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraBlind do + local nIdBl = DwIdExtraBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, BlindId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + if BlindRegId then + EgtErase( BlindRegId) + --EgtSetName( BlindRegId, 'BLIND') + --EgtSetColor( BlindRegId, BLUE()) + --EgtSetLevel( BlindRegId, GDB_LV.TEMP) + end + end + if DownRegId then + FaceDwId = EgtGroup( GDB_ID.ROOT) + EgtSetName( FaceDwId, 'DWREG') + EgtSetColor( FaceDwId, BLUE()) + EgtSetLevel( FaceDwId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( DownRegId, nChunk, FaceDwId) do + nChunk = nChunk + 1 + end + EgtErase( DownRegId) + --EgtSetName( DownRegId, 'DWREG') + --EgtSetColor( DownRegId, GREEN()) + --EgtSetLevel( DownRegId, GDB_LV.TEMP) + end +end + +----------------------------------------------------------------- +local function GetBoxViseRegion( nIdVise, sRegName) + + local nShapeId + local nShapeMoveId + local nAreaId + local nAreaMoveId + local tViseArea = {} + + if nIdVise then + -- cerco l'id della geometria shape + nAreaId = EgtGetFirstNameInGroup( nIdVise, 'BASE') + nAreaMoveId = EgtGetFirstNameInGroup( nIdVise, 'MOBILE') + + if nAreaId then + -- cerco il nome della regione + nShapeId = EgtGetFirstNameInGroup( nAreaId, sRegName) + end + + if nAreaMoveId then + -- cerco il nome della regione + nShapeMoveId = EgtGetFirstNameInGroup( nAreaMoveId, sRegName) + end + + -- se ho le regioni provo a verificare + if nShapeId and nShapeMoveId then + local bBoxReg = EgtGetBBoxGlob ( nShapeId, GDB_BB.EXACT) + table.insert( tViseArea, bBoxReg) + bBoxReg = EgtGetBBoxGlob ( nShapeMoveId, GDB_BB.EXACT) + table.insert( tViseArea, bBoxReg) + end + end + + return tViseArea +end + +----------------------------------------------------------------- +local function VerifyIntersXYZ( bRefBox, bMachBox, dDeltaBody, bCheckZ) + + local bNoCollisionX + local bNoCollisionY + local bNoCollisionZ + + -- prendo punti box della lavorazione e del pezzo (riferimento/morsa) + local pMinMach = bMachBox:getMin() + local pMaxMach = bMachBox:getMax() + local pMinRef = bRefBox:getMin() + local pMaxRef = bRefBox:getMax() + + -- verifico collisioni + if ( pMinRef:getX() - dDeltaBody > pMaxMach:getX()) or + ( pMaxRef:getX() + dDeltaBody < pMinMach:getX()) then -- se non toccano in x + bNoCollisionX = true + else + bNoCollisionX = false + end + + if ( pMaxRef:getY() + dDeltaBody < pMinMach:getY()) or + ( pMinRef:getY() - dDeltaBody > pMaxMach:getY()) then -- se non si toccano in y + bNoCollisionY = true + else + bNoCollisionY = false + end + + if bCheckZ then + if ( pMinMach:getZ() - dDeltaBody) > pMaxRef:getZ() then -- se non toccano in z + bNoCollisionZ = true + else + bNoCollisionZ = false + end + end + + return bNoCollisionX, bNoCollisionY, bNoCollisionZ +end + +----------------------------------------------------------------- +local function RemoveSubPieceAtPos( sRawDisp, nPos, nNumPieceOnBar, DISPMODE, nNumChar) + + local sNewRow = '' + local nNumTotChar = nNumPieceOnBar * nNumChar + + if #sRawDisp == nNumTotChar then + -- se non in prima posizione compongo la parte iniziale + if nPos > 1 then + sNewRow = sNewRow .. string.sub ( sRawDisp, 1 , ( ( nPos * nNumChar) - nNumChar )) + end + -- aggiungo la posizione vuota + sNewRow = sNewRow .. '0_' + -- se non in ultima posizione compongo la parte finale + if nPos < nNumPieceOnBar then + sNewRow = sNewRow .. string.sub ( sRawDisp, ( ( nPos * nNumChar) + 1 )) + end + else + sNewRow = sRawDisp + end + + return sNewRow +end + +----------------------------------------------------------------- +local function ReduceViseNumber( tIdViseDisp, nMinViseNumber, Pz, nNumPhase, DISPMODE, nNumPieceOnBar, sRawDisp, nNumChar) + + -- calcolo le distanze tra le ventose + local nTotNumVise = #tIdViseDisp + local nLastVise = tIdViseDisp[nTotNumVise][2] + local nFirstVise = tIdViseDisp[1][2] + local tDeleteVise = {} + -- posizione intermedia tra le posizioni occupate + local dMiddleDist = ( nFirstVise + nLastVise) / 2 + local nMiddlePos = 0 + local dMinDistance = 15 + + -- ciclo sulla tabella per trovare la posizione più vicina alla posizione media + for i = 2, ( nTotNumVise -1) do + + local nPosLoc = tIdViseDisp[i][2] + local nDist = abs( dMiddleDist - nPosLoc) + if nDist < dMinDistance then + dMinDistance = nDist + nMiddlePos = i + end + end + + -- se trovata una posizione + if nMiddlePos > 0 then + -- ciclo per eliminare tutte le posizioni tranne (gli estremi) e la candidata + for i = 2, ( nTotNumVise -1) do + local nPosLoc = tIdViseDisp[i][2] + if i ~= nMiddlePos then + -- rimuovo la morsa dalla disposizione e anche nella tabella + EgtRemoveFixture( tIdViseDisp[i][1]) + table.insert( tDeleteVise, i) + -- rimuovo la posizione dalla stringa delle posizioni + sRawDisp = RemoveSubPieceAtPos( sRawDisp, tIdViseDisp[i][2], nNumPieceOnBar, DISPMODE, nNumChar) + -- se stringa valida riscrivo la nota corretta + if #sRawDisp > 0 then + EgtSetInfo( Pz, 'FixVacRow_Phase_'..EgtNumToString( nNumPhase, 0), sRawDisp) + end + end + end + end + -- cancello dalla tabella le morse eliminate + for i = #tDeleteVise, 1, -1 do + table.remove( tIdViseDisp, tDeleteVise[i]) + end + + return sRawDisp +end + +----------------------------------------------------------------- +local function VerifyViseCollision( tIdViseDisp, bMachBox, Pz, nNumPhase, DISPMODE, nNumPieceOnBar, sRawDisp, nNumChar) + + if tIdViseDisp and #tIdViseDisp > 0 then + + local tDeleteVise = {} + + for i = 1, #tIdViseDisp do + + local bOkCollision = true + + -- prendo gli ingombri delle regioni esterne e più in alto della morsa + local tViseArea = GetBoxViseRegion( tIdViseDisp[i][1], 'REG_UP') + + if tViseArea then + + for j = 1, #tViseArea do + -- verifico se c'è possibile collisione in X e/o Y + local bNoCollisionX, bNoCollisionY, bNoCollisionZ = VerifyIntersXYZ( tViseArea[j], bMachBox, 1, true) + -- controllo se c'è solo collisione in Y + bOkCollision = bOkCollision and ( bNoCollisionX or bNoCollisionY or ( bNoCollisionX and bNoCollisionY and bNoCollisionZ)) + end + + -- Se ho collisione rimuovo la morsa + if not bOkCollision then + -- ottengo la posizione della morsa + local nPos = tIdViseDisp[i][2] + -- rimuovo la morsa dalla disposizione e anche nella tabella + EgtRemoveFixture( tIdViseDisp[i][1]) + table.insert( tDeleteVise, i) + -- rimuovo la posizione dalla stringa delle posizioni + sRawDisp = RemoveSubPieceAtPos( sRawDisp, nPos, nNumPieceOnBar, DISPMODE, nNumChar) + -- se stringa valida riscrivo la nota corretta + if #sRawDisp > 0 then + EgtSetInfo( Pz, 'FixVacRow_Phase_'..EgtNumToString( nNumPhase, 0), sRawDisp) + end + end + end + + -- se non ho rimosso la morsa + if bOkCollision then + -- prendo gli ingombri delle regioni interne e più basse della morsa + tViseArea = {} + tViseArea = GetBoxViseRegion( tIdViseDisp[i][1], 'REG_0') + + if tViseArea then + + for j = 1, #tViseArea do + -- verifico se c'è possibile collisione in X e/o Y + local bNoCollisionX, bNoCollisionY, bNoCollisionZ = VerifyIntersXYZ( tViseArea[j], bMachBox, 1, true) + -- controllo se c'è solo collisione in Y + bOkCollision = bOkCollision and ( bNoCollisionX or bNoCollisionY or ( bNoCollisionX and bNoCollisionY and bNoCollisionZ)) + end + + -- Se ho collisione rimuovo la morsa + if not bOkCollision then + -- ottengo la posizione della morsa + local nPos = tIdViseDisp[i][2] + -- rimuovo la morsa dalla disposizione e anche nella tabella + EgtRemoveFixture( tIdViseDisp[i][1]) + table.insert( tDeleteVise, i) + -- rimuovo la posizione dalla stringa delle posizioni + sRawDisp = RemoveSubPieceAtPos( sRawDisp, nPos, nNumPieceOnBar, DISPMODE, nNumChar) + -- se stringa valida riscrivo la nota corretta + if #sRawDisp > 0 then + EgtSetInfo( Pz, 'FixVacRow_Phase_'..EgtNumToString( nNumPhase, 0), sRawDisp) + end + end + end + end + end + -- cancello dalla tabella le morse eliminate + for i = #tDeleteVise, 1, -1 do + table.remove( tIdViseDisp, tDeleteVise[i]) + end + end + return sRawDisp +end + +----------------------------------------------------------------- +local function VerifyRowCollision( tRefBox, bMachBox) + + local bOkCollisionX = true + local bOkCollisionY = true + local bOkCollision = true + local dDeltaBody = 40 + + -- devono esserci almeno un box di un riferimento e il box lavorazione + if ( tRefBox.ref1 or tRefBox.ref2 or tRefBox.ref3 or tRefBox.ref4) and bMachBox then + + if tRefBox.ref1 then + bOkCollisionX, bOkCollisionY = VerifyIntersXYZ( tRefBox.ref1, bMachBox, dDeltaBody) + bOkCollision = bOkCollision and ( bOkCollisionX or bOkCollisionY) + end + if tRefBox.ref2 then + bOkCollisionX, bOkCollisionY = VerifyIntersXYZ( tRefBox.ref2, bMachBox, dDeltaBody) + bOkCollision = bOkCollision and ( bOkCollisionX or bOkCollisionY) + end + if tRefBox.ref3 then + bOkCollisionX, bOkCollisionY = VerifyIntersXYZ( tRefBox.ref3, bMachBox, dDeltaBody) + bOkCollision = bOkCollision and ( bOkCollisionX or bOkCollisionY) + end + if tRefBox.ref4 then + bOkCollisionX, bOkCollisionY = VerifyIntersXYZ( tRefBox.ref4, bMachBox, dDeltaBody) + bOkCollision = bOkCollision and ( bOkCollisionX or bOkCollisionY) + end + end + + return bOkCollision +end + +----------------------------------------------------------------- +local function FindRefInTable( nTab, sParzName) + + local tRefList = MB.FindGroupWithPartName( nTab, sParzName) + local bBoxRef + local tBoxRef = {} + local tFoundRef = {} + + if tRefList then + for i = 1, #tRefList do + local sNameEnt = EgtGetName(tRefList[i]) + local sNumRef = string.sub( sNameEnt, #sNameEnt) + -- trasformo in numero + local nLocNumRef = tonumber(sNumRef) + if nLocNumRef == 1 then + tFoundRef.r1 = tRefList[i] + elseif nLocNumRef == 2 then + tFoundRef.r2 = tRefList[i] + elseif nLocNumRef == 3 then + tFoundRef.r3 = tRefList[i] + elseif nLocNumRef == 4 then + tFoundRef.r4 = tRefList[i] + end + end + + if tFoundRef.r1 or tFoundRef.r2 or tFoundRef.r3 or tFoundRef.r4 then + + local nRefId + if tFoundRef.r1 then + -- ottengo il sottogruppo ref + nRefId = EgtGetFirstNameInGroup( tFoundRef.r1, 'BASE2') + if nRefId then + tBoxRef.ref1 = EgtGetBBoxGlob ( nRefId, GDB_BB.EXACT) + end + end + if tFoundRef.r2 then + -- ottengo il sottogruppo ref + nRefId = EgtGetFirstNameInGroup( tFoundRef.r2, 'BASE2') + if nRefId then + tBoxRef.ref2 = EgtGetBBoxGlob ( nRefId, GDB_BB.EXACT) + end + end + if tFoundRef.r3 then + -- ottengo il sottogruppo ref + nRefId = EgtGetFirstNameInGroup( tFoundRef.r3, 'BASE2') + if nRefId then + tBoxRef.ref3 = EgtGetBBoxGlob ( nRefId, GDB_BB.EXACT) + end + end + if tFoundRef.r4 then + -- ottengo il sottogruppo ref + nRefId = EgtGetFirstNameInGroup( tFoundRef.r4, 'BASE2') + if nRefId then + tBoxRef.ref4 = EgtGetBBoxGlob ( nRefId, GDB_BB.EXACT) + end + end + end + end + + return tBoxRef +end + +----------------------------------------------------------------- +local function ExecVacVerify( ptVac, dDistVac) -- This function is not more used, now it uses ExecVacShapeVerify + -- verifica con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistVac + 15 then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistVac + 45 then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con il contorno esterno inferiore + nId = EgtGetFirstInGroup( FaceDwId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al contorno + una piccola distanza + if dDist < dDistVac + 1 then + return false + end + end + nId = EgtGetNext( nId) + end + -- nessuna interferenza + return true +end + +----------------------------------------------------------------- +local function ExecViseShapeVerify( ptVac, sNameVac, tabOri, dDistThru, dDistBlind, + dDistCont, dRotVal, dMove2) + + local nShapeId + local nShapeMoveId + local nAreaId + local nAreaMoveId + local nRetErr = 0 + + -- inserisco la ventosa e ne ottengo l'id + local nFixVac = EgtAddFixture( sNameVac, ( ptVac - tabOri), dRotVal, dMove2) + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + if nFixVac then + + -- cerco l'id della geometria shape + nAreaId = EgtGetFirstNameInGroup( nFixVac, 'BASE') + nAreaMoveId = EgtGetFirstNameInGroup( nFixVac, 'MOBILE') + + if nAreaId then + -- cerco il nome della regione + nShapeId = EgtGetFirstNameInGroup( nAreaId, 'REG_UP') + else + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 1 + return false, nRetErr + end + + if nAreaMoveId then + -- cerco il nome della regione + nShapeMoveId = EgtGetFirstNameInGroup( nAreaMoveId, 'REG_UP') + else + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 1 + return false, nRetErr + end + end + + -- se ho le regioni provo a verificare + if nShapeId and nShapeMoveId then + + -- verifica se regione ventosa interferisce con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) +-- EgtSaveFile() + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistThru) + local bDistBtwRegionM = not EgtSurfFrTestExternal( nShapeMoveId, nId, dDistThru) + if bDistBtwRegion or bDistBtwRegionM then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistBlind) + local bDistBtwRegionM = not EgtSurfFrTestExternal( nShapeMoveId, nId, dDistBlind) + if bDistBtwRegion or bDistBtwRegionM then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr, true + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni contorno + nId = EgtGetFirstInGroup( FaceDwId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistCont) + local bDistBtwRegionM = not EgtSurfFrTestExternal( nShapeMoveId, nId, dDistCont) + if bDistBtwRegion or bDistBtwRegionM then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + else -- regione non trovata + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 2 + return false, nRetErr + end + + -- nessuna interferenza + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + return true, nRetErr +end + +----------------------------------------------------------------- +local function ExecVacShapeVerify( ptVac, sNameVac, tabOri, dDistThru, dDistBlind, + dDistCont, bCodeMobileVac, dRotVal, dMove2) + + local nShapeId + local nShapeBlindId + local nAreaId + local dMoveLoc = EgtIf( bCodeMobileVac, dMove2, 0) + local dRotLoc = EgtIf( bCodeMobileVac, dRotVal, 0) + local dMaxMov = 0 + local nRetErr = 0 + local nCustomType + + -- inserisco la ventosa e ne ottengo l'id + local nFixVac = EgtAddFixture( sNameVac, ( ptVac - tabOri), dRotLoc, dMoveLoc) + + if nFixVac then + + -- cerco l'id della geometria shape + if bCodeMobileVac then + nAreaId = EgtGetFirstNameInGroup( nFixVac, 'MOBILE') + else + nAreaId = EgtGetFirstNameInGroup( nFixVac, 'AREA') + end + + -- leggo la nota del typo custom + nCustomType = EgtGetInfo( nFixVac, 'CustomType', 'i') + + if nAreaId then + if bCodeMobileVac then -- se mobile leggo la nota di movimento massimo + dMaxMov = EgtGetInfo( nAreaId, 'MAXMOV', 'd') or 0 + end + -- cerco il nome della regione + nShapeId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE') + -- cerco il nome della regione dedicata alle geometrie cieche + nShapeBlindId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE_BL') + -- se non ho la doppia regione prendo l'unica + if nShapeId and not nShapeBlindId then + nShapeBlindId = nShapeId + end + else + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 1 + return false, nRetErr + end + end + + -- se ho la regione provo a verificare + if nShapeId then + + -- se ventosa mobile controllo se la distanza di movimento è superiore a quella ammessa + if bCodeMobileVac and dMoveLoc > dMaxMov then + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + -- verifica se regione ventosa interferisce con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) +-- EgtSaveFile() + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistThru) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeBlindId, nId, dDistBlind) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr, true + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni contorno + nId = EgtGetFirstInGroup( FaceDwId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistCont) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + else -- regione non trovata + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 2 + return false, nRetErr + end + + -- nessuna interferenza + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + return true, nRetErr, nil, nCustomType +end + +----------------------------------------------------------------- +local function EndVacVerify() + -- cancello regioni passante e cieca + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + EgtErase( FaceDwId or GDB_ID.NULL) + FaceDwId = nil +end + +-------------------------------------------------------------------------------- +-- * Abilitazione/disabilitazione geometrie * +local function ShowHideGeom( nGroupId, sName, dVal) + local nId = EgtGetFirstNameInGroup( nGroupId, sName) + if nId then + local dOldVal = EgtGetInfo( nId, 'Val', 'd') or 0.1 + if dVal ~= dOldVal then + if dVal > 0.5 then + EgtSetStatus( nId, GDB_ST.ON) + else + EgtSetStatus( nId, GDB_ST.OFF) + end + EgtSetInfo( nId, 'Val', dVal) + end + end +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +local function CheckExtSideMach( tListEnt) + local sEdgeNote + for j = 1, #tListEnt do + if tListEnt[j] then + sEdgeNote = EgtGetInfo( tListEnt[j], 'EdgeDoor') or '' + if sEdgeNote == 'T' then -- se lavorato lato top + DGD.MTS = 1 + elseif sEdgeNote == 'B' then -- se lavorato lato bottom + DGD.MBS = 1 + elseif sEdgeNote == 'H' then -- se lavorato lato hinge + DGD.MHS = 1 + elseif sEdgeNote == 'L' then -- se lavorato lato lock + DGD.MLS = 1 + end + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, + sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, + bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed, bCalMach) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') + local sKeepBackSet = EgtGetInfo( tEndId[1], 'KeepBackSet') + local sProbeSide = EgtGetInfo( tEndId[1], 'ProbeSide') -- ProbeMachXY + local nActiveStop = EgtGetInfo( tEndId[1], 'ActiveStopMach', 'i') + local nSetMaxElev = EgtGetInfo( tEndId[1], 'SetMaxElev', 'i') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + local sKeepBackSetCode + local sActiveStop + local sSetMaxElev + local sProbeSideCode + + -- determino in base alla disposizione quale codice KeepBackSet dare alla lavorazione + if sKeepBackSet and not bNotGenMachining then + if (bPush and bFlip) or ( not bPush and not bFlip) then -- se lato narrow è in basso (BD) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + end + else -- altrimenti lato narrow è in alto (BU) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + end + end + end + -- + if sProbeSide and not bNotGenMachining then + sProbeSideCode = 'CPBP' -- CORR_POS_BY_PROBE + end + -- + if nActiveStop and not bNotGenMachining then + sActiveStop = 'ActiveStopMach=1' + end + -- + if nSetMaxElev and not bNotGenMachining then + sSetMaxElev = 'MaxElev=0.0' + end + + if nMach == 1 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup, 0), sMach, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMach) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup, 0), sMachUp, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMachUp) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup, 0), sMachDw, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + if bCalMach then + SetInfoTable( tEndId, 'Machining', sMachDw) + nNumMach = nNumMach + 1 + end + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + end + + return bOk, nNumMach, tMachining +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed ) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if tLocTable[i].Oper == 'AdjustHead' and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j]) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, + nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** calc disposition references *** +----------------------------------------------------------------- +local function CalcDispositionRef( bLeftPiece, bTopOnRight, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip, nKeepSideDoorInFront) + + local dExtraX, dExtraY, nCorner + + if DISPMODE > 0 then -- se disposizione a sinistra della tavola + if bTopOnRight then -- se top a destra + dExtraX = -dBottomOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.BL + dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) + else + -- se orientamento teste definito + if nKeepSideDoorInFront > 0 then + nCorner = MCH_CR.BL + else + nCorner = MCH_CR.TL + end + dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) + end + else -- se top a sinistra + dExtraX = -dTopOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + -- se orientamento teste definito + if nKeepSideDoorInFront > 0 then + nCorner = MCH_CR.BL + else + nCorner = MCH_CR.TL + end + dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) + else + nCorner = MCH_CR.BL + dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) + end + end + else -- altrimenti disposizione a destra della tavola + if bTopOnRight then -- se top a destra + dExtraX = dTopOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.BR + dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) + else + -- se orientamento teste definito + if nKeepSideDoorInFront > 0 then + nCorner = MCH_CR.BR + else + nCorner = MCH_CR.TR + end + dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) + end + else -- se top a sinistra + dExtraX = dBottomOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + -- se orientamento teste definito + if nKeepSideDoorInFront > 0 then + nCorner = MCH_CR.BR + else + nCorner = MCH_CR.TR + end + dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) + else + nCorner = MCH_CR.BR + dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) + end + end + end + + return dExtraX, dExtraY, nCorner +end + +----------------------------------------------------------------- +-- *** calc disposition subpieces *** +----------------------------------------------------------------- +local function CalcDispositionSubPieces( nNumB, nRowId, bFixSameVac, tsBaseNameVac, ttBaseDataVac, + sInd, tnNumVacInsert, tnNumKindVac, tdYCommpos, nInd, + tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, + tnMaxEndFailed, tnEndFailed, nNumTotVacRow, dLenCalc, bNarrowStile, + tabOri, tnTypeSingleVacOnBar, bFrameOnNarrow, bUseViseOnFrameOnWide, dDimY) + + local ptPos -- punto posizioni ventose + local bCanUp + local tPosSubPiece = {} + local tPosRowSubPieceRow = {} + local nCenterId + local nTypeVacSel = 0 + local bCheckNext = true + local nCountTypeVac = 1 + local nVacErr + local bBlindColl + local nCustType + + -- se uso morsa + if bUseViseOnFrameOnWide then + + nTypeVacSel = 1 -- inizio con il primo + + while nCountTypeVac <= #ttBaseDataVac do + + -- parto con il controllo del primo tipo di morsa + if nTypeVacSel == nCountTypeVac and bCheckNext then + + nCenterId = EgtGetFirstNameInGroup( nRowId, ttBaseDataVac[nCountTypeVac][nNumB][1]..sInd) + -- se nome punto di riferimento presente e numero tipi di ventose sulla barra non nullo + if nCenterId and #ttBaseDataVac > 0 then + + local dDistThru = ttBaseDataVac[nCountTypeVac][nNumB][3] + local dDistBlind = ttBaseDataVac[nCountTypeVac][nNumB][4] + local dDistCont = ttBaseDataVac[nCountTypeVac][nNumB][5] + + ptPos = EgtSP( nCenterId, GDB_ID.ROOT) + bBlindColl = false + bCanUp, nVacErr, bBlindColl = ExecViseShapeVerify( ptPos, ttBaseDataVac[nCountTypeVac][nNumB][2], tabOri, dDistThru, dDistBlind, dDistCont, 0, dDimY) + if not bCanUp and nVacErr > 0 then + if nVacErr == 1 then + DoorOutLog( 'Group Mobile or Area not found into Vise model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vise nge model', 0) + else + DoorOutLog( 'Region REG_x not found into vise model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vise nge model', 0) + end + end + else + bCanUp = false + DoorOutLog( 'Point on .nge machine table not found: '.. ttBaseDataVac[nCountTypeVac][nNumB][1]..sInd, 0) + end + + if bCanUp then -- è andata bene la ventosa + if #tsBaseNameVac[nNumB][1] > 0 then -- ho già il tipo ventosa + -- confermo questo tipo + tnNumKindVac[nNumB] = tsBaseNameVac[nNumB][3] + bCheckNext = false + else -- setto il nuovo tipo (in questo caso è il primo) + tsBaseNameVac[nNumB][1] = ttBaseDataVac[nCountTypeVac][nNumB][2] + tsBaseNameVac[nNumB][2] = ttBaseDataVac[nCountTypeVac][nNumB][2] + tsBaseNameVac[nNumB][3] = nTypeVacSel + tdYCommpos[nNumB] = ptPos:getY() + -- confermo questo tipo + tnNumKindVac[nNumB] = tsBaseNameVac[nNumB][3] + bCheckNext = false + end + end + end + + nCountTypeVac = nCountTypeVac + 1 + end -- end while + else + -- se ventosa fissa + if bFixSameVac then + if bNarrowStile and nNumB ~= 2 then + nTypeVacSel = tnNumVacInsert[nNumB] -- setto pari al numero di tipi gestito (può essere 1, 2 ,3, ecc) + else + -- controllo se ho già il tipo di ventosa usata + if #tsBaseNameVac[nNumB][1] > 0 then -- ho già il tipo ventosa + nTypeVacSel = tsBaseNameVac[nNumB][3] + else + nTypeVacSel = 1 -- inizio con il primo + end + end + elseif bNarrowStile and nNumB ~= 2 then -- se ho la proprietà per la narrow stile passo subito con quella più piccola + nTypeVacSel = tnNumVacInsert[nNumB] -- setto pari al numero di tipi gestito (può essere 1, 2 ,3, ecc) + else + if tnTypeSingleVacOnBar[nNumB] and tnTypeSingleVacOnBar[nNumB] >= 0 then + nTypeVacSel = tnTypeSingleVacOnBar[nNumB] + else + nTypeVacSel = 1 -- inizio con il primo + end + end + + while nCountTypeVac <= #ttBaseDataVac do + + -- parto con il controllo del primo tipo di ventosa + if nTypeVacSel == nCountTypeVac and bCheckNext then + + nCenterId = EgtGetFirstNameInGroup( nRowId, ttBaseDataVac[nCountTypeVac][nNumB][1]..sInd) + -- se nome punto di riferimento presente e numero tipi di ventose sulla barra non nullo + if nCenterId and tnNumVacInsert[nNumB] > 0 then + local dDistThru = ttBaseDataVac[nCountTypeVac][nNumB][4] + local dDistBlind = ttBaseDataVac[nCountTypeVac][nNumB][5] + local dDistCont = ttBaseDataVac[nCountTypeVac][nNumB][6] + if bFrameOnNarrow then + dDistThru = ttBaseDataVac[nCountTypeVac][nNumB][7] + dDistBlind = ttBaseDataVac[nCountTypeVac][nNumB][8] + dDistCont = ttBaseDataVac[nCountTypeVac][nNumB][9] + end + ptPos = EgtSP( nCenterId, GDB_ID.ROOT) + bBlindColl = false + bCanUp, nVacErr, bBlindColl, nCustType = ExecVacShapeVerify( ptPos, ttBaseDataVac[nCountTypeVac][nNumB][2], tabOri, dDistThru, dDistBlind, dDistCont) + if not bCanUp and nVacErr > 0 then + if nVacErr == 1 then + DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + else + DoorOutLog( 'Region SHAPE not found into vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + end + end + else + bCanUp = false + DoorOutLog( 'Point on .nge machine table not found: '.. ttBaseDataVac[nCountTypeVac][nNumB][1]..sInd, 0) + end + + if bCanUp then -- è andata bene la ventosa + if #tsBaseNameVac[nNumB][1] > 0 then -- ho già il tipo ventosa + -- se ventosa fissa e corrisponde con questo tipo, setto quella fissa + if bFixSameVac and tsBaseNameVac[nNumB][3] == nTypeVacSel then + -- confermo questo tipo + tnNumKindVac[nNumB] = nCustType or tsBaseNameVac[nNumB][3] + bCheckNext = false + elseif not( bNarrowStile and nNumB ~= 2) then -- se non è tipo narrow stile setto questa + tsBaseNameVac[nNumB][1] = ttBaseDataVac[nCountTypeVac][nNumB][2] + tsBaseNameVac[nNumB][2] = ttBaseDataVac[nCountTypeVac][nNumB][3] + tsBaseNameVac[nNumB][3] = nTypeVacSel + tdYCommpos[nNumB] = ptPos:getY() + -- confermo questo tipo + tnNumKindVac[nNumB] = nCustType or tsBaseNameVac[nNumB][3] + bCheckNext = false + elseif ( bNarrowStile and nNumB ~= 2) then -- se tipo narrow stile + if tnNumVacInsert[nNumB] == nTypeVacSel then -- se sono all'ultimo tipo ventosa la confermo + tsBaseNameVac[nNumB][1] = ttBaseDataVac[nCountTypeVac][nNumB][2] + tsBaseNameVac[nNumB][2] = ttBaseDataVac[nCountTypeVac][nNumB][3] + tsBaseNameVac[nNumB][3] = nTypeVacSel + tdYCommpos[nNumB] = ptPos:getY() + -- confermo questo tipo + tnNumKindVac[nNumB] = nCustType or tsBaseNameVac[nNumB][3] + bCheckNext = false + elseif tnNumVacInsert[nNumB] > nTypeVacSel then + nTypeVacSel = nTypeVacSel + 1 + end + end + else -- setto il nuovo tipo (in questo caso è il primo) + tsBaseNameVac[nNumB][1] = ttBaseDataVac[nCountTypeVac][nNumB][2] + tsBaseNameVac[nNumB][2] = ttBaseDataVac[nCountTypeVac][nNumB][3] + tsBaseNameVac[nNumB][3] = nTypeVacSel + tdYCommpos[nNumB] = ptPos:getY() + -- confermo questo tipo + tnNumKindVac[nNumB] = nCustType or tsBaseNameVac[nNumB][3] + + if bFixSameVac then -- se ventosa fissa + if bNarrowStile and nNumB ~= 2 then -- se narrow stile + if tnNumVacInsert[nNumB] == nTypeVacSel then -- se ultima ventosa + bCheckNext = false + elseif tnNumVacInsert[nNumB] > nTypeVacSel then + nTypeVacSel = nTypeVacSel + 1 + end + else -- non è narrow + bCheckNext = false + end + end + end + else + if nCountTypeVac < #ttBaseDataVac then + if bFixSameVac or not( bNarrowStile and nNumB ~= 2) then -- se ventose uguali o non ha propietà narrow stile + -- se posso incrementare il tipo ventosa + if tnNumVacInsert[nNumB] > nTypeVacSel then + nTypeVacSel = nTypeVacSel + 1 + end + end + end + end + end + + nCountTypeVac = nCountTypeVac + 1 + end -- end while + end + + -- eventuale abilitazione parte fissa + if bCanUp then -- se sottopezzo da inserire + + local nCodVac + nCodVac = tnNumKindVac[nNumB] + + -- inserisco la ventosa sul fisso + tPosSubPiece[1] = ptPos + tPosSubPiece[2] = nCodVac + tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} + + -- interrompo le serie negative + if nInd > 1 then + tnCountFailed[nNumB] = 0 + if tnMaxIniFailed[nNumB] < tnIniFailed[nNumB] then + tnMaxIniFailed[nNumB] = tnIniFailed[nNumB] + end + if tnMaxMiddleFailed[nNumB] < tnMiddleFailed[nNumB] then + tnMaxMiddleFailed[nNumB] = tnMiddleFailed[nNumB] + end + if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then + tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] + end + tnIniFailed[nNumB] = 0 + tnMiddleFailed[nNumB] = 0 + tnEndFailed[nNumB] = 0 + end + else -- sottopezzo non inserito + if nNumB == 2 then -- se barra intermedia scrivo lo stesso la posizione + tPosSubPiece[1] = ptPos + else + tPosSubPiece[1] = '' + end + tPosSubPiece[2] = 0 + tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} + + tnCountFailed[nNumB] = tnCountFailed[nNumB] + 1 + if nInd == 1 then -- setto solo il fallimento iniziale + tnIniFailed[nNumB] = tnCountFailed[nNumB] + elseif nInd == nNumTotVacRow or dLenCalc <= 0 then -- setto solo quello finale e annullo il medio + tnEndFailed[nNumB] = tnCountFailed[nNumB] + if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then + tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] + end + tnMiddleFailed[nNumB] = 0 + else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati + if tnIniFailed[nNumB] > 0 then + tnIniFailed[nNumB] = tnCountFailed[nNumB] + elseif tnEndFailed[nNumB] > 0 then + tnEndFailed[nNumB] = tnCountFailed[nNumB] - 1 + else + tnMiddleFailed[nNumB] = tnCountFailed[nNumB] + end + end + end + + return tPosRowSubPieceRow, bBlindColl +end + +----------------------------------------------------------------- +-- *** insert special subpieces *** +----------------------------------------------------------------- +local function InsertSpecialSubPiece( tPosRowSubPieceRow, nNumTotVacRow, bTopOnRight, tsSpecialNameVac, tabOri, + dDistThru, dDistBlind, dDistSide, pPiecePos, nNumB, + tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, DISPMODE) + + local bFound = false + local bRotVac = EgtIf( bTopOnRight, true, false) + local dMove = 0 + local nFoundFirst = 0 + local nPrecVacType = 0 + local nVacErr + + for l = 1, nNumTotVacRow do + + local nIndVac = EgtIf( not bTopOnRight, l, ( nNumTotVacRow - l + 1)) + local tnCodVac = tPosRowSubPieceRow[nIndVac] + + if tnCodVac then -- se codice presente + + if nFoundFirst == 0 then + nFoundFirst = EgtIf( bTopOnRight, nIndVac, l) + end + + if bRotVac then + dMove = pPiecePos:getX() - tnCodVac[1]:getX() + else + dMove = tnCodVac[1]:getX() - pPiecePos:getX() + end + + nPrecVacType = tnCodVac[2] + + -- provo ad inserire la ventosa con il codice collisione + local bCanUp, nVacErr = ExecVacShapeVerify( tnCodVac[1], tsSpecialNameVac, tabOri, dDistThru, dDistBlind, + dDistSide, true, EgtIf( bRotVac, 180, 0), dMove) + + if bCanUp then + + tnCodVac[2] = EgtIf( bRotVac, 6, 5) + bFound = true + + if nFoundFirst == l then -- se prima ventosa trovata dalla parte finale ( a sinistra) + if DISPMODE > 0 then -- se porta disposta a sinistra + if nPrecVacType == 0 then -- se ventosa precedente vuota + if tnMaxIniFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + tnMaxIniFailed[nNumB] - 1 + tnMaxIniFailed[nNumB] = 0 + end + end + else + if nPrecVacType == 0 then -- se ventosa precedente vuota + if tnMaxEndFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + tnMaxEndFailed[nNumB] - 1 + tnMaxEndFailed[nNumB] = 0 + end + end + end + -- se ( top a sinistra e ultima ventosa trovata ( a destra)) o ( top a destra e prima ventosa dalla parte iniziale ( a destra)) + elseif (not bTopOnRight and l == nIndVac) or ( bTopOnRight and nFoundFirst == nIndVac) then + if DISPMODE > 0 then -- se porta disposta a sinistra + if nPrecVacType == 0 then -- se ventosa precedente vuota + if tnMaxEndFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + tnMaxEndFailed[nNumB] - 1 + tnMaxEndFailed[nNumB] = 0 + end + end + else + if nPrecVacType == 0 then -- se ventosa precedente vuota + if tnMaxIniFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + tnMaxIniFailed[nNumB] - 1 + tnMaxIniFailed[nNumB] = 0 + end + end + end + else -- se sono in posizione intermedia + if nPrecVacType == 0 then -- se ventosa vuota + -- se ( porta a sinistra e top a destra) o ( porta a destra e top a sinistra) + if ( DISPMODE > 0 and bTopOnRight) or ( DISPMODE < 0 and not bTopOnRight) then + if tnMaxEndFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + ( tnMaxEndFailed[nNumB] - ( nFoundFirst - nIndVac + 1)) + tnMaxEndFailed[nNumB] = nFoundFirst - nIndVac - 1 -- sottraggo ancora 1 perché la base occupa due spazi + end + else + if tnMaxIniFailed[nNumB] > 0 then + tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] + ( tnMaxIniFailed[nNumB] - ( nIndVac - nFoundFirst + 1)) + tnMaxIniFailed[nNumB] = nIndVac - nFoundFirst - 1 -- sottraggo ancora 1 perché la base occupa due spazi + end + end +-- if tnMaxMiddleFailed[nNumB] > 0 then +-- tnMaxMiddleFailed[nNumB] = tnMaxMiddleFailed[nNumB] - 1 +-- end + end + end + else + if nVacErr == 1 then + DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. tsSpecialNameVac .. '. Please update vacuum nge model', 0) + break + elseif nVacErr > 1 then + DoorOutLog( 'Region SHAPE not found into vacuum model: '.. tsSpecialNameVac .. '. Please update vacuum nge model', 0) + break + end + end + end + if bFound then break end + end + return tPosRowSubPieceRow, bFound +end + +----------------------------------------------------------------- +-- *** disposition subpieces *** +----------------------------------------------------------------- +local function DispositionSubPieces( nNumB, nIndVac, tPosRowSubPieceRow, bFixSameVac, tsBaseNameVac, + tdYCommpos, ttBaseDataVac, nIndOri, tabOri, tsNoteRow, + nDispId, tsSpecialNameVac, pPiecePos, Pz, bInsSpecVac, + bUseViseOnFrameOnWide, dDimY) + + local tnCodVac = tPosRowSubPieceRow[nIndVac] + local sCodVac + local sNameV, sNameVSld + local dMove = 0 + local nFixVac + + if tnCodVac then -- se codice presente + if tnCodVac[2] == 0 then + sCodVac = '0_' + else + if bInsSpecVac and tnCodVac[2] >= 5 and bFixSameVac then -- se ho inserito la ventosa speciale ma ho il codice di uniformare tutte le ventose, lo disabilito + bFixSameVac = false + end + if bUseViseOnFrameOnWide then + sNameV = ttBaseDataVac[1][nNumB][2] + sNameVSld = ttBaseDataVac[1][nNumB][2] + sCodVac = 'V_' + dMove = dDimY + elseif bFixSameVac and #tsBaseNameVac[nNumB][1] > 0 then -- se fissa sulla stessa ventosa + sNameV = tsBaseNameVac[nNumB][1] + sNameVSld = tsBaseNameVac[nNumB][2] + sCodVac = string.format( '%s_', tsBaseNameVac[nNumB][3]) + tnCodVac[1] = Point3d{ tnCodVac[1]:getX(), tdYCommpos[nNumB], tnCodVac[1]:getZ()} + elseif tnCodVac[2] == 1 then + sNameV = ttBaseDataVac[1][nNumB][2] + sNameVSld = ttBaseDataVac[1][nNumB][3] + sCodVac = '1_' + elseif tnCodVac[2] == 2 then + sNameV = ttBaseDataVac[2][nNumB][2] + sNameVSld = ttBaseDataVac[2][nNumB][3] + sCodVac = '2_' + elseif tnCodVac[2] == 3 then + sNameV = ttBaseDataVac[3][nNumB][2] + sNameVSld = ttBaseDataVac[3][nNumB][3] + sCodVac = '3_' + elseif tnCodVac[2] == 5 then + sNameV = tsSpecialNameVac + sNameVSld = tsSpecialNameVac + sCodVac = '5_' + dMove = tnCodVac[1]:getX() - pPiecePos:getX() + -- scrivo una nota con la posizione della ventosa ad arco + EgtSetInfo( Pz, 'TopVacArcPos', Point3d( pPiecePos:getX(), tnCodVac[1]:getY(),0)) + elseif tnCodVac[2] == 6 then + sNameV = tsSpecialNameVac + sNameVSld = tsSpecialNameVac + sCodVac = '6_' + dMove = pPiecePos:getX() - tnCodVac[1]:getX() + -- scrivo una nota con la posizione della ventosa ad arco + EgtSetInfo( Pz, 'TopVacArcPos', Point3d( pPiecePos:getX(), tnCodVac[1]:getY(),0)) + elseif tnCodVac[2] == 7 then + sNameV = ttBaseDataVac[3][nNumB][2] + sNameVSld = ttBaseDataVac[3][nNumB][3] + sCodVac = '7_' + end + + -- inserisco la ventosa + local sNameVac = EgtIf( fmod( nIndOri, 2) == 1, sNameVSld, sNameV) + nFixVac = EgtAddFixture( sNameVac, ( tnCodVac[1] - tabOri), EgtIf( tnCodVac[2] == 6, 180,0), dMove) + EgtSetInfo( nDispId, 'POS'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0), ( tnCodVac[1] - tabOri)) + EgtSetInfo( nDispId, 'MOD'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0), sNameVac) + EgtSetInfo( nDispId, 'COD'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0), sCodVac) + end + tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. sCodVac, sCodVac .. tsNoteRow[nNumB]) + else + tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. '0_', '0_' .. tsNoteRow[nNumB]) + EgtRemoveInfo( nDispId, 'POS'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0)) + EgtRemoveInfo( nDispId, 'MOD'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0)) + EgtRemoveInfo( nDispId, 'COD'..EgtNumToString( nNumB, 0)..'_'..EgtNumToString( nIndVac, 0)) + end + + return nFixVac +end + +----------------------------------------------------------------- +-- *** disposition references *** +----------------------------------------------------------------- +local function DispositionReferences( sNameRef, ptPosRef, nRotRef) + if sNameRef and ptPosRef and nRotRef then + local ptLoc = Point3d( ptPosRef) + local nRef = EgtAddFixture( sNameRef, ptLoc, nRotRef, 0) + end +end + +local function CheckEnoughVacuums( nInd, nIdVac, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, + bUseOnly2Bars, dTopRadius, bTopOnRight, bUseVise, + tIdViseDisp) + + local bOk = true + local sMess = '' + + if nIdVac == 0 then -- se codice per porta + if bUseOnly2Bars then -- in caso di due barre, inferiore e media + if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or + ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd)) then -- tutte le ventose basse + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[1] / nInd > 0.25) and + ( tnMaxIniFailed[2] / nInd > 0.25) then -- ventose iniziali ( parte sinistra) + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and + ( tnMaxMiddleFailed[2] / nInd > 0.45) then -- ventose centrali + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[1] / nInd > 0.25) and + ( tnMaxEndFailed[2] / nInd > 0.25) then -- ventose finali ( parte destra) + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and + (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) then -- somma di vari intervalli + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + else + -- casi di scarse ventose: solo per le file esterne, quella centrale le considero solo per le porte ad arco + -- perché è capitato che la disposizione porta risultasse corretta con solo la fila centrale + if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or + -- ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd) or + ( tnMaxIniFailed[3] == nInd or tnMaxMiddleFailed[3] == nInd or tnMaxEndFailed[3] == nInd)) then -- tutte le ventose basse + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and not dTopRadius and ( tnMaxIniFailed[1] / nInd > 0.25) and + -- ( tnMaxIniFailed[2] / nInd > 0.25) and + ( tnMaxIniFailed[3] / nInd > 0.25) then -- ventose iniziali ( parte destra) senza top ad arco + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and dTopRadius and not bTopOnRight and ( tnMaxIniFailed[1] / nInd > 0.25) and + -- ( tnMaxIniFailed[2] / nInd > 0.25) and + ( tnMaxIniFailed[3] / nInd > 0.25) then -- ventose iniziali ( parte destra) top ad arco opposto + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and dTopRadius and bTopOnRight and not ( tnMaxIniFailed[1] / nInd <= 0.35 and + tnMaxIniFailed[2] / nInd <= 0.55 and + tnMaxIniFailed[3] / nInd <= 0.35) then -- ventose iniziali ( parte destra) top ad arco su questo lato + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and + -- ( tnMaxMiddleFailed[2] / nInd > 0.45) and + ( tnMaxMiddleFailed[3] / nInd > 0.45) then -- ventose centrali + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and not dTopRadius and ( tnMaxEndFailed[1] / nInd > 0.25) and + -- ( tnMaxEndFailed[2] / nInd > 0.25) and + ( tnMaxEndFailed[3] / nInd > 0.25) then -- ventose finali ( parte sinistra) senza top ad arco + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and dTopRadius and bTopOnRight and ( tnMaxEndFailed[1] / nInd > 0.25) and + -- ( tnMaxEndFailed[2] / nInd > 0.25) and + ( tnMaxEndFailed[3] / nInd > 0.25) then -- ventose finali ( parte sinistra) top ad arco opposto + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and dTopRadius and not bTopOnRight and not ( tnMaxEndFailed[1] / nInd <= 0.35 and + tnMaxEndFailed[2] / nInd <= 0.55 and + tnMaxEndFailed[3] / nInd <= 0.35) then -- ventose finali ( parte sinistra) top ad arco su questo lato + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and + -- (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) and + (( tnMaxIniFailed[3] + tnMaxMiddleFailed[3] + tnMaxEndFailed[3]) >= nInd/2) then -- somma di vari intervalli + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + end + else -- altrimenti frame + if bUseVise then + -- numero morse insufficente + if tIdViseDisp and #tIdViseDisp < 3 then + sMess = ' ' .. EgtDoorsMsg[683] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[nIdVac] > 2) then + local nNumMsg = EgtIf( DISPMODE > 0, 684, 685) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[nIdVac] > 2) then + local nNumMsg = EgtIf( DISPMODE > 0, 685, 684) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + end + else + -- casi di scarse ventose: solo per la fila 1 + if nInd > 0 and ( tnMaxIniFailed[nIdVac] == nInd or tnMaxMiddleFailed[nIdVac] == nInd or tnMaxEndFailed[nIdVac] == nInd) then + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[nIdVac] / nInd > 0.25) then + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[nIdVac] / nInd > 0.45) then + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[nIdVac] / nInd > 0.25) then + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[nIdVac] + tnMaxMiddleFailed[nIdVac] + tnMaxEndFailed[nIdVac]) >= nInd/2) then + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + end + end + + return bOk, sMess +end + +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +local function CheckPieceDimension ( bFrame, dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, ShiftXOri, ShiftYOri) + + local bFailDim = false + local sErrMess = '' + local dLimitToCheck + local nNumMess + + nNumMess = EgtIf( bFrame, 623, 622) + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MnJL, ( tMainTabPar.MnDL - abs(ShiftXOri))) + if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[nNumMess], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MxJL, ( tMainTabPar.MxDL - abs(ShiftXOri))) + if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[nNumMess], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MnJW, ( tMainTabPar.MnDW - abs(2*ShiftYOri))) + if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[nNumMess], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MxJW, ( tMainTabPar.MxDW - abs(2*ShiftYOri))) + if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[nNumMess], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MnJT, tMainTabPar.MnDT) + if dThickDoor < dLimitToCheck then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[nNumMess], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = EgtIf( bFrame, tMainTabPar.MxJT, tMainTabPar.MxDT) + if dThickDoor > dLimitToCheck then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[nNumMess], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + return bFailDim +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) + + --local nTime + + -- inizializzo il contatore + --EgtStartCounter() + + -- macchina e tabella di default + -- tabella parametri d'uso per variabili CurrcamInfo + tMainTabPar = {} + -- Machine name + tMainTabPar.MN = 'Multiax-' -- id 1 + + -- Machinings Table + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- References on table (respect Zero machine) + -- Y Table + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftVac = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- setto nuova variabile suffisso ghost DGD.GHT + DGD.GHT = '_HIDE' + + -- elimino percorsi eventualmente creati dal Mach + -- cancello i percorsi ghost e tutti i percorsi di sgrossatura + local DelList = MB.FindEntitiesWithPartName( tPz, DGD.GHT) + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + +-------------------------------------------------------------------------------- + -- Dati del pezzo (porta, frame) + local tsProperties = {} + local tsRadiusProf = {} + local tsPlaneProf = {} + local tsDispJambByMat = {} + local tsStringData = {} + local tsDoubleData = {} + local tsBoolData = {} + local nProbeMode + local nPostProbeSet + + -- Box pezzo + local Ls + local Aux + local b3Part, b3Solid + local tb3Part = {} + local tb3Solid = {} + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + +-------------------------------------------------------------------------------- + -- variabili CAM + local TAB + local MachinesName + -- *** settaggi CAM *** -- Mtable 2 + local TABORD + -- variabili disposizione su più tavole + local nNumTblForOthMat = 2 + local nForceAsMultiTbl + +-------------------------------------------------------------------------------- + -- variabili sottopezzi + local nTabId, nMobId1, nMobId2, nFixId, nDispId + local dFixval, dOldVal, dNewVal_2, dNewVal_1, dCalcLen + local tRefArea = {} + -- Interasse minimo gruppi ventose + local dMinDistGroup = 139.5 + +-------------------------------------------------------------------------------- + -- assegnazione variabili CurrCamInfo + + -- imposto i dati macchina secondo le informazioni del file cam + tMainTabPar.MN = mCamData[nNumMachFromCam].MachName -- MachName + tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength -- dMaxDoorLength + tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength -- dMinDoorLength + tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth -- dMaxDoorWidth + tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth -- dMinDoorWidth + tMainTabPar.MxDT = mCamData[nNumMachFromCam].MaxDoorThick -- dMaxDoorThick + tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick -- dMinDoorThick + tMainTabPar.MxJL = mCamData[nNumMachFromCam].MaxJambLength -- dMaxJambLength + tMainTabPar.MnJL = mCamData[nNumMachFromCam].MinJambLength -- dMinJambLength + tMainTabPar.MxJW = mCamData[nNumMachFromCam].MaxJambWidth -- dMaxJambWidth + tMainTabPar.MnJW = mCamData[nNumMachFromCam].MinJambWidth -- dMinJambWidth + tMainTabPar.MxJT = mCamData[nNumMachFromCam].MaxJambThick -- dMaxJambThick + tMainTabPar.MnJT = mCamData[nNumMachFromCam].MinJambThick -- dMinJambThick + tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef -- dAltRef + tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef -- dTallRef + tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure -- sLocSecure + tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat -- dMaxOverMat + tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 -- dStepOverMat + tMainTabPar.TDD = mCamData[nNumMachFromCam].TopSideDriveDisp -- nTopSideDriveDisp + tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain -- dMaxDistToChain + tMainTabPar.FPB = mCamData[nNumMachFromCam].FramePosBar -- dPosBarForJamb + tMainTabPar.FVR = mCamData[nNumMachFromCam].nFixSameVacOnRaw == 1 -- bFixSameVac + tMainTabPar.NTVB1 = mCamData[nNumMachFromCam].nNumTypeVacOnBar1 -- nNumTypeVacOnBar1 + tMainTabPar.NTVB2 = mCamData[nNumMachFromCam].nNumTypeVacOnBar2 -- nNumTypeVacOnBar2 + tMainTabPar.NTVB3 = mCamData[nNumMachFromCam].nNumTypeVacOnBar3 -- nNumTypeVacOnBar3 + tMainTabPar.TSVB1 = mCamData[nNumMachFromCam].nTypeSingleVacOnBar1 -- new + tMainTabPar.TSVB2 = mCamData[nNumMachFromCam].nTypeSingleVacOnBar2 -- new + tMainTabPar.TSVB3 = mCamData[nNumMachFromCam].nTypeSingleVacOnBar3 -- new + -- nomi punti associati ai tipi ventosa sulle barre + tMainTabPar.P1T = mCamData[nNumMachFromCam].sNamePntOnBarsType1 -- new + tMainTabPar.P2T = mCamData[nNumMachFromCam].sNamePntOnBarsType2 -- new + tMainTabPar.P3T = mCamData[nNumMachFromCam].sNamePntOnBarsType3 -- new + -- tolleranza di ricerca per ventose + tMainTabPar.DTG = mCamData[nNumMachFromCam].dSafetyDistVacThru or 15 -- new + tMainTabPar.DBG = mCamData[nNumMachFromCam].dSafetyDistVacBlind or 45 -- new + tMainTabPar.DSG = mCamData[nNumMachFromCam].dSafetyDistVacSide or 1 -- new + tMainTabPar.DTGN = mCamData[nNumMachFromCam].dSafetyDistVacThruOnSide or 5 -- new + tMainTabPar.DBGN = mCamData[nNumMachFromCam].dSafetyDistVacBlindOnSide or 15 -- new + tMainTabPar.DSGN = mCamData[nNumMachFromCam].dSafetyDistVacSideOnSide or 1 -- new + -- primo tipo ventose + tMainTabPar.V1T1 = mCamData[nNumMachFromCam].sNameVacOnFixBarType1 -- new + tMainTabPar.V2T1 = mCamData[nNumMachFromCam].sNameVacOnMob1BarType1 -- new + tMainTabPar.V3T1 = mCamData[nNumMachFromCam].sNameVacOnMob2BarType1 -- new + tMainTabPar.V1T1E = mCamData[nNumMachFromCam].sNameVacElvOnFixBarType1 -- new + tMainTabPar.V2T1E = mCamData[nNumMachFromCam].sNameVacElvOnMob1BarType1 -- new + tMainTabPar.V3T1E = mCamData[nNumMachFromCam].sNameVacElvOnMob2BarType1 -- new + -- secondo tipo ventose + tMainTabPar.V1T2 = mCamData[nNumMachFromCam].sNameVacOnFixBarType2 -- new + tMainTabPar.V2T2 = mCamData[nNumMachFromCam].sNameVacOnMob1BarType2 -- new + tMainTabPar.V3T2 = mCamData[nNumMachFromCam].sNameVacOnMob2BarType2 -- new + tMainTabPar.V1T2E = mCamData[nNumMachFromCam].sNameVacElvOnFixBarType2 -- new + tMainTabPar.V2T2E = mCamData[nNumMachFromCam].sNameVacElvOnMob1BarType2 -- new + tMainTabPar.V3T2E = mCamData[nNumMachFromCam].sNameVacElvOnMob2BarType2 -- new + -- terzo tipo ventose + tMainTabPar.V1T3 = mCamData[nNumMachFromCam].sNameVacOnFixBarType3 -- new + tMainTabPar.V2T3 = mCamData[nNumMachFromCam].sNameVacOnMob1BarType3 -- new + tMainTabPar.V3T3 = mCamData[nNumMachFromCam].sNameVacOnMob2BarType3 -- new + tMainTabPar.V1T3E = mCamData[nNumMachFromCam].sNameVacElvOnFixBarType3 -- new + tMainTabPar.V2T3E = mCamData[nNumMachFromCam].sNameVacElvOnMob1BarType3 -- new + tMainTabPar.V3T3E = mCamData[nNumMachFromCam].sNameVacElvOnMob2BarType3 -- new + + tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining -- dExtraThruDepth + tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 -- Ori1 + tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 -- Ori2 + tMainTabPar.OR1f = mCamData[nNumMachFromCam].Ori1f -- Ori1f + tMainTabPar.OR2f = mCamData[nNumMachFromCam].Ori2f -- Ori2f + tMainTabPar.OR1fv = mCamData[nNumMachFromCam].Ori1fv -- Ori1fv + tMainTabPar.OR2fv = mCamData[nNumMachFromCam].Ori2fv -- Ori2fv + tMainTabPar.OR3f = mCamData[nNumMachFromCam].Ori3f -- Ori3f + tMainTabPar.OR4f = mCamData[nNumMachFromCam].Ori4f -- Ori4f + tMainTabPar.OR5f = mCamData[nNumMachFromCam].Ori5f -- Ori5f + tMainTabPar.OR6f = mCamData[nNumMachFromCam].Ori6f -- Ori6f + tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 -- vShiftAct + tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck -- vShiftLockSide not used + tMainTabPar.DVL = mCamData[nNumMachFromCam].dDistanceVacLeft -- new + tMainTabPar.DVR = mCamData[nNumMachFromCam].dDistanceVacRight -- new + tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels -- new + tMainTabPar.PTK = mCamData[nNumMachFromCam].dProbeThickness -- new + tMainTabPar.MJT = mCamData[nNumMachFromCam].MachineJambsTogether -- MachineJambsTogether + -- nome ventosa ad arco e parametri di sicurezza + tMainTabPar.AVNM = mCamData[nNumMachFromCam].ArcVacuumName_Mob1 -- new + tMainTabPar.ADTG = mCamData[nNumMachFromCam].dArcSafetyDistVacThru or 3 -- new + tMainTabPar.ADBG = mCamData[nNumMachFromCam].dArcSafetyDistVacBlind or 45 -- new + tMainTabPar.ADSG = mCamData[nNumMachFromCam].dArcSafetyDistVacSide or 1 -- new + tMainTabPar.GCDN = mCamData[nNumMachFromCam].nGenCncAsDdfName or 1 -- new + tMainTabPar.DACN = mCamData[nNumMachFromCam].nDisableAutoCncName or 0 -- new + tMainTabPar.BPLI = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) -- new + tMainTabPar.PRF = mCamData[nNumMachFromCam].PercRedFeed or 0.3 -- new + dMinDistGroup = mCamData[nNumMachFromCam].dMinDistBetweenBars or dMinDistGroup -- new + tMainTabPar.MPMB = mCamData[nNumMachFromCam].dMaxPosMobBar or 1100.000 -- new + DISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or DISPMODE -- SideDoorDispose + NUMTABLE = mCamData[nNumMachFromCam].nNumTableOnMachine or NUMTABLE -- new + nNumTblForOthMat = mCamData[nNumMachFromCam].nNumTableForOtherMaterial or nNumTblForOthMat -- new + nForceAsMultiTbl = mCamData[nNumMachFromCam].nForceUseAsMultiTable or nForceAsMultiTbl -- new + tMainTabPar.CUC = mCamData[nNumMachFromCam].nCheckUnderNCollision or 0 -- new + tMainTabPar.REF1 = mCamData[nNumMachFromCam].tDefinitionRef1 -- new + tMainTabPar.REF2 = mCamData[nNumMachFromCam].tDefinitionRef2 -- new + tMainTabPar.REF3 = mCamData[nNumMachFromCam].tDefinitionRef3 -- new + tMainTabPar.REF4 = mCamData[nNumMachFromCam].tDefinitionRef4 -- new + tMainTabPar.FWHB = mCamData[nNumMachFromCam].nWoodForceHorizMachOnBevelProf -- new + tMainTabPar.FSHB = mCamData[nNumMachFromCam].nSteelForceHorizMachOnBevelProf -- new + tMainTabPar.FAHB = mCamData[nNumMachFromCam].nAluminForceHorizMachOnBevelProf -- new + tMainTabPar.FFHB = mCamData[nNumMachFromCam].nFiberGForceHorizMachOnBevelProf -- new + tMainTabPar.NTVR = mCamData[nNumMachFromCam].nNumTotVacRow or 15 -- new + tMainTabPar.UVFF = mCamData[nNumMachFromCam].nUseViseForFrames or 0 -- new + -- primo tipo morse + tMainTabPar.VSF1 = mCamData[nNumMachFromCam].sNameViseOnFixBarType1 -- new + -- tolleranza di ricerca per morse + tMainTabPar.DTGV = mCamData[nNumMachFromCam].dSafetyDistVisThru or 15 -- new + tMainTabPar.DBGV = mCamData[nNumMachFromCam].dSafetyDistVisBlind or 45 -- new + tMainTabPar.DSGV = mCamData[nNumMachFromCam].dSafetyDistVisSide or 1 -- new + -- codice disposizione frames + tMainTabPar.FTDD = mCamData[nNumMachFromCam].FrameTopSideDriveDisp or 0 -- new + -- abilitazione collision detect + tMainTabPar.ECD = mCamData[nNumMachFromCam].EnableCollisionDetect or 0 -- new + -- flag che indica la direzione taglio porta + tMainTabPar.CDA = mCamData[nNumMachFromCam].sCutDirectionAdmitted or '' -- new + -- parametri per gestione scrap mode (limita le sgrossature solo all'ultima passata) + tMainTabPar.RSM = mCamData[nNumMachFromCam].RemoveScrapMode or 0 -- new + tMainTabPar.MSV = mCamData[nNumMachFromCam].MinScrapValue or 0 -- new + -- parametro esportazione vista tavola + tMainTabPar.ETV = mCamData[nNumMachFromCam].ExportTableView or 0 -- new + +-------------------------------------------------------------------------------- + + local MTable, MTableOrd + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftMchng = false + local bSmallShiftedDoor = false + local sDispMode + local sNotePhase + local sTotDispMode = '' + local sNumGroup = '' + local bGenFirstStep = false + local nIndexStartMach = 1 + local bWork = true + local sIdList = '' + -- variabili utilizzate dentro al ciclo + local tMchId = {} + local nMchId + local sTab + local sTabx + local tabOri + local Ori + local vExtraYDelta + local ColA + local nRaw + local tnRaw = {} + local bSetTable + local bMoveRaw + local bTopOnRight + local bFrame + local bHingeOnRef + local bTopOnRef + -- variabili per disposizione sottopezzi + local dMobOffs1 + local dMobOffs2 + local dDistMinX + local dDistMaxX + local dVacOn + local dInterAx + local bUseOnly2Bars + local OffsXSovr = 0 + local OffsYSovr = 0 + local bUseVise + -- variabile per tool setup + local bSetUp + local MSetup + local sSetup + local tListError + local sListTool + -- variabili calcolo box + local b3SolidPiece = {} + local b3SolidPiece2 = {} + local b3SolidOnTab + local pMin + local pMinRecalc + local pMax + local dOffsX = 0 + local dOffsY = 0 + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local tsMachProf = {} + -- variabile per conteggio lavorazioni + local nNumMach = 0 + local nNumSkip + local tSecMachTab = {} + local tSecMachTabOrd = {} + -- variabili per fase + local nNumPhase + local nPrevPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + local pDistToMove + local dAngleToAlign = 0 + -- variabile materiale porta + local bWoodDoor + local bSteelDoor + local bAlumDoor + -- variabili proprietà speciali + local bSkinned + local bExtruded + local bNarrowStile + -- variabile check dimensioni porta + local bFailDim = false + -- variabile forza lavorazioni bevel orizzontali + local bForceHorizontalDir = false + -- variabile disposizione jambs + local nDispJambsMode = 0 + -- variabile per disposizione frame + local bFlipFrame + local bFrameOnNarrow + + -- tabella lavorazioni + local tLocMach = {} + local tLocMachOrd = {} + local tSplitDoorEnt = {} + local tSplitDataInf = {} + + local bEnBreak = false + local bGetSplitCuts = false + local nNumProbeZ + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( tMainTabPar.MN) + + -- raccolgo gli id dei pezzi + for v = 1, #tPz do + sIdList = sIdList .. '_' .. EgtNumToString(tPz[v],0) + end + + -- faccio tutte le fasi + while bWork do + + -- per ogni pezzo passato + for v = 1, #tPz do + + --nTime = EgtStopCounter() + --if not DGD or not DGD.NCGEN then + -- EgtOutBox( string.format( 'tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') + --end + + -- inizializzo il contatore + --EgtStartCounter() + + Pz = tPz[v] + sAssemb = tsAssemb[v] + -- assegnamento variabili + bFrame = sAssemb and string.find( sAssemb, 'frame') == 1 + Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + Aux = EgtGetFirstNameInGroup( Pz, 'AUX') + tsStringData.sCode = EgtGetInfo( Pz, 'Code') + tsDoubleData.dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + tsDoubleData.dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + tsDoubleData.dThickDoor = EgtGetInfo( Pz, 'T', 'd') + tsStringData.sSwing = EgtGetInfo( Pz, 'Swing') + tsStringData.sSecure = EgtGetInfo( Pz, 'Secure') + tsStringData.sDoorMaterial = EgtGetInfo( Pz, 'Material') + tsProperties = EgtSplitString( EgtGetInfo( Pz, 'Properties') or '') + tsDoubleData.TypePiece = EgtGetInfo( Pz, 'Piece Type', 'i') + tsStringData.sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + tsStringData.sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + tsStringData.sTopTrim = EgtGetInfo( Pz, 'top_trimming') + tsStringData.sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + tsBoolData.bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + tsBoolData.bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + tsBoolData.bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + tsBoolData.bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + tsDoubleData.dTopRadius = EgtGetInfo( Pz, 'top_radius', 'd') + tsDoubleData.dTopAngle = EgtGetInfo( Pz, 'top_angle', 'd') + tsDoubleData.dTopxDeltapos = EgtGetInfo( Pz, 'top_xdeltapos', 'd') + tsBoolData.bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b') + tsBoolData.bFrameOnWide = EgtGetInfo( Pz, 'FrameDispositionOnSide', 'b') + tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') + tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') + tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') + tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') + tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') + tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') + tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') + tsDispJambByMat[1] = EgtGetInfo( Pz, 'DisposeWJambsOnSide', 'i') + tsDispJambByMat[2] = EgtGetInfo( Pz, 'DisposeSJambsOnSide', 'i') + tsDispJambByMat[3] = EgtGetInfo( Pz, 'DisposeAJambsOnSide', 'i') + tsDispJambByMat[4] = EgtGetInfo( Pz, 'DisposeFJambsOnSide', 'i') + nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 + nPostProbeSet = EgtGetInfo( Pz, 'PostProbeSet', 'i') or 0 + tsDoubleData.dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + tsDoubleData.dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + tsDoubleData.dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + tsDoubleData.dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + -- flag posizione serratura ( vero se serratura a destra) + tsBoolData.bAtRight = ( tsStringData.sSwing:sub(1,1) == 'L') + + -- setto il movimento di apertura della porta + if tsStringData.sSwing == 'RH' or tsStringData.sSwing == 'RHA' or tsStringData.sSwing == 'RHI' or + tsStringData.sSwing == 'LH' or tsStringData.sSwing == 'LHI' or tsStringData.sSwing == 'LHA' then + bPush = true + else + bPush = false + end + + if bFirstStep and not bShiftMchng then + + if v == 1 and tMainTabPar.GCDN == 0 then -- solo il primo pezzo e se il flag ha valore nullo + -- assegno al nome file il nome del campo Code del ddf + -- di default è uguale al nome del file ddf + sFileName = tsStringData.sCode + end + + -- determino se la porta ha il materiale + bWoodDoor = FindMaterial( tsStringData.sDoorMaterial, 'wood') -- per wood ddors + bSteelDoor = FindMaterial( tsStringData.sDoorMaterial, 'steel') -- old nNumProperties = 4 -- per steeldoors + bAlumDoor = FindMaterial( tsStringData.sDoorMaterial, 'aluminum') -- per aluminum doors + + if bWoodDoor then + ColA = Color3d( 255, 165, 0, 25) + -- setto forzatura lavorazioni orizzontali in base alla variabile nel CurrCamInfo inerente al materiale + if tMainTabPar.FWHB and tMainTabPar.FWHB > 0 then bForceHorizontalDir = true end + -- setto disposizione frame in base alla nota del pezzo (proviene dal file CurrDoorCustomData) + if tsDispJambByMat[1] then nDispJambsMode = tsDispJambByMat[1] end + elseif bSteelDoor then + ColA = Color3d( 167,196,197, 25) + -- setto forzatura lavorazioni orizzontali in base alla variabile nel CurrCamInfo inerente al materiale + if tMainTabPar.FSHB and tMainTabPar.FSHB > 0 then bForceHorizontalDir = true end + -- setto disposizione frame in base alla nota del pezzo (proviene dal file CurrDoorCustomData) + if tsDispJambByMat[2] then nDispJambsMode = tsDispJambByMat[2] end + elseif bAlumDoor then + ColA = Color3d( 208,213,217, 25) + -- setto forzatura lavorazioni orizzontali in base alla variabile nel CurrCamInfo inerente al materiale + if tMainTabPar.FAHB and tMainTabPar.FAHB > 0 then bForceHorizontalDir = true end + -- setto disposizione frame in base alla nota del pezzo (proviene dal file CurrDoorCustomData) + if tsDispJambByMat[3] then nDispJambsMode = tsDispJambByMat[3] end + else + ColA = Color3d( 255, 165, 0, 25) + -- setto forzatura lavorazioni orizzontali in base alla variabile nel CurrCamInfo inerente al materiale + if tMainTabPar.FFHB and tMainTabPar.FFHB > 0 then bForceHorizontalDir = true end + -- setto disposizione frame in base alla nota del pezzo (proviene dal file CurrDoorCustomData) + if tsDispJambByMat[4] then nDispJambsMode = tsDispJambByMat[4] end + end + + -- se pezzo ( porta o telaio) in alluminio o acciaio + if bAlumDoor or bSteelDoor then + -- setto a 0 tutti i sovramateriali e li segno da non lavorare + tsDoubleData.dLeftOffs = 0 + tsDoubleData.dRightOffs = 0 + tsDoubleData.dTopOffs = 0 + tsDoubleData.dBottomOffs = 0 + tsBoolData.bHingeMach = false + tsBoolData.bLockMach = false + tsBoolData.bTopMach = false + tsBoolData.bBottomMach = false + end + + -- determino se la porta ha speciali proprietà + bSkinned = FindProperty( tsProperties, 'skinned') -- old nNumProperties = 1 -- per skinned + bExtruded = FindProperty( tsProperties, 'extruded') -- old nNumProperties = 2 -- per extruded + bNarrowStile = FindProperty( tsProperties, 'narrowstile') -- old nNumProperties = 3 -- per narrowstile + + -- ottengo la tabella corrente del primo pezzo + MachiningsTable = EgtGetInfo( tPz[1], 'MTable') + -- Box pezzo + table.insert( tb3Part, v, EgtGetBBoxGlob( Pz, GDB_BB.EXACT)) + + local b3fx = BBox3d() -- inizializzo il box nullo + b3fx = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + + table.insert( tb3Solid, v, b3fx) + end + + -- assegno i box del pezzo + b3Part = tb3Part[v] + b3Solid = tb3Solid[v] + + if v == 1 then -- solo il primo pezzo + + if bFirstStep and not bShiftMchng then + + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DGD.ERR = 34 + local sErrMess = string.format(EgtDoorsMsg[597], MachiningsTable) + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DGD.ERR = 27 + local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + else + DGD.ERR = 35 + local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + MachinesName = TAB.MMachineData + if not MachinesName then + DGD.ERR = 29 + local sErrMess = string.format(EgtDoorsMsg[491], '') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- Errore! Nome macchina: non presente in MTable + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable, 0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DGD.ERR = 30 + local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + else + DGD.ERR = 31 + local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable + return true + end + + if tsStringData.sHingeTrim ~= 'SQ' and tsStringData.sHingeTrim ~= 'EB' and bNarrowStile then + DGD.ERR = 32 + local sErrMess = string.format(EgtDoorsMsg[636], '') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( sErrMess, 0) -- errore, la proprietà narrow stile è compatibile solo con lato bevel + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + MTable = TAB.MTable + MTableOrd = TABORD.MTable + end + end + + sDispMode = '' + + if bFirstStep and not bShiftMchng then + + if v == 1 then nNumGroup = nNumGroup + 1 end + + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup, 0) .. '_' .. tMainTabPar.MN) + else + -- creo gruppo lavoro + if v == 1 then + nMchId = EgtAddMachGroup( 'Ids'.. sIdList ..'_'..'Mach_' .. EgtNumToString(nNumGroup, 0) .. '_' .. tMainTabPar.MN) + end + end + if nMchId then + if tMainTabPar.DACN == 1 then + local sLocNumGroup = '' + if nNumGroup > 1 then sLocNumGroup = '_'..EgtNumToString(nNumGroup, 0) end + EgtSetInfo( nMchId, 'NcName', sFileName .. sLocNumGroup .. EgtIf( nProbeMode ~= 1,'.cnc','.prb')) + end + -- assegno al gruppo di lavoro l'info relativo allo stato del controllo collisione + EgtSetInfo( nMchId, 'EnableCollisionDetect', tMainTabPar.ECD) + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + EgtSetInfo( nMchId, 'Vm', '1') + end + -- metto il gruppo lavorazione nella tabella + table.insert( tMchId, { tMainTabPar.MN, nMchId, Pz}) + end + nNumPhase = EgtGetCurrPhase() + else + + if v == 1 then + +-- -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto +-- if nProbeMode == 0 and nPostProbeSet >= 3 then +-- -- Cancello i percorsi _HIDE di sideprobe perchè se viene ribaltata la porta la posizione del percorso _HIDE viene a +-- -- trovarsi a filo ventose +-- local DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_HIDE') +-- -- ciclo su tutte le entità trovate +-- for j = 1, #DelList do +-- EgtErase( DelList[j] ) +-- end +-- end + + -- se nessuna lavorazione riutilizzo la vecchia fase + if nNumMach == 0 then + + -- elimino i vecchi grezzi + for t = 1, #tnRaw do + EgtRemoveRawPart( tnRaw[t]) -- elimino il grezzo + end + + -- elimino la disposizione dei sottopezzi + local nNumFix = EgtGetFirstFixture() + while nNumFix do + EgtRemoveFixture( nNumFix) + nNumFix = EgtGetFirstFixture() + end + else + nPrevPhase = nNumPhase + nNumPhase = EgtAddPhase() -- creo nuova fase + end + end + + -- rendo corrente la fase + if nNumPhase then + EgtSetCurrPhase(nNumPhase) + end + end + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + if bFirstStep and not bShiftMchng then + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + tsDoubleData.dLeftOffs = 0 + tsDoubleData.dRightOffs = 0 + tsDoubleData.dTopOffs = 0 + tsDoubleData.dBottomOffs = 0 + end + else -- fase successiva ribaltata o spostata + + -- i profili con lavorazione disabilitata li posso mettere subito a zero + if ( not tsBoolData.bLockMach and tsBoolData.bAtRight) or ( not tsBoolData.bHingeMach and not tsBoolData.bAtRight) then -- lavorazione lato destro disabilitata + tsDoubleData.dRightOffs = 0 + end + + if ( not tsBoolData.bLockMach and not tsBoolData.bAtRight) or ( not tsBoolData.bHingeMach and tsBoolData.bAtRight) then -- lavorazione lato sinistro disabilitata + tsDoubleData.dLeftOffs = 0 + end + + if not tsBoolData.bTopMach then -- lavorazione lato top disabilitata + tsDoubleData.dTopOffs = 0 + end + + if not tsBoolData.bBottomMach then -- lavorazione lato top disabilitata + tsDoubleData.dBottomOffs = 0 + end + + -- azzero i sovramateriali dei profili che sono stati lavorati + if tsMachProf and #tsMachProf[v] > 0 then + + local sListProf = EgtSplitString( tsMachProf[v], ',') + for m = 1, #sListProf do + if string.lower( sListProf[m]) == 'left' then + tsDoubleData.dLeftOffs = 0 + elseif string.lower( sListProf[m]) == 'right' then + tsDoubleData.dRightOffs = 0 + elseif string.lower( sListProf[m]) == 'top' then + tsDoubleData.dTopOffs = 0 + elseif string.lower( sListProf[m]) == 'bottom' then + tsDoubleData.dBottomOffs = 0 + end + end + end + end + + -- in base ai valori di sovramateriale sui lati, se tutti sono al di sotto di 3 volte il valore di attivazione della sgrossatura + -- allora disabilito lo scrapmode + if tsDoubleData.dLeftOffs < tMainTabPar.MSV and tsDoubleData.dRightOffs < tMainTabPar.MSV and + tsDoubleData.dTopOffs < tMainTabPar.MSV and tsDoubleData.dBottomOffs < tMainTabPar.MSV then + tMainTabPar.RSM = 0 + end + + -- se sono in ribaltamento e in rebuild della porta devo ruotare la porta + -- con il lato opposto parallelo a Y (prima della disposizione) + if not bFirstStep and nProbeMode == 2 then + + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nSideToAlign + local sSideToAlign + local nSideToAlignMid + local sSideToAlignMid + local nSideToAlignTop + local sSideToAlignTop + local bInvert + + if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then + sSideToAlign = 'Right' + sSideToAlignMid = 'RightMid' + sSideToAlignTop = 'RightTop' + bInvert = false + else + sSideToAlign = 'Left' + sSideToAlignMid = 'LeftMid' + sSideToAlignTop = 'LeftTop' + bInvert = true + end + + nSideToAlign = EgtGetFirstNameInGroup( nRecId, sSideToAlign) + nSideToAlignMid = EgtGetFirstNameInGroup( nRecId, sSideToAlignMid) + nSideToAlignTop = EgtGetFirstNameInGroup( nRecId, sSideToAlignTop) + + local vVectorToAlign + + if nSideToAlign then + if bInvert then + vVectorToAlign = EgtSV( nSideToAlign) + dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) - 180 + else + vVectorToAlign = EgtSV( nSideToAlign) + dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) + end + + -- allineo il pezzo prendendo il riferimento del lato opposto al lato riferito nella prima fase + EgtRotate( Pz , ORIG(), Z_AX(), dAngleToAlign ) + + -- muovo la porta nelle origini + if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then -- lato allineato right + if tsBoolData.bAtRight then -- se serratura a destra + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif tsStringData.sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) + end + else + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif tsStringData.sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) + end + end + else -- lato allineato left + if tsBoolData.bAtRight then -- se serratura a destra + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif tsStringData.sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) + end + else + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif tsStringData.sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) + end + end + end + + -- muovo il pezzo sull'origine + EgtMove( Pz, ORIG() - Point3d( pDistToMove:getX(), pDistToMove:getY(), 0), GDB_RT.GLOB) + + -- ricalcolo il box del solido + b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + -- ricalcolo il box del pezzo + b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + end +-- bEnBreak = true +-- bWork = false +-- break + end + + if bFirstStep then + table.insert( b3SolidPiece, EgtGetBBoxGlob( Pz, GDB_BB.EXACT)) + else + table.insert( b3SolidPiece2, EgtGetBBoxGlob( Pz, GDB_BB.EXACT)) + end + + if b3SolidPiece[v] and b3SolidPiece2[v] and nProbeMode ~= 2 then + dOffsX = b3SolidPiece2[v]:getMin():getX() - b3SolidPiece[v]:getMin():getX() + dOffsY = b3SolidPiece2[v]:getMin():getY() - b3SolidPiece[v]:getMin():getY() + else + dOffsX = 0 + dOffsY = 0 + end + + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + tsDoubleData.dLeftOffs + tsDoubleData.dRightOffs, + b3Solid:getDimY() + tsDoubleData.dTopOffs + tsDoubleData.dBottomOffs, b3Solid:getDimZ(), ColA) + table.insert( tnRaw, v, nRaw) + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( tsDoubleData.dLeftOffs + dOffsX, tsDoubleData.dBottomOffs + dOffsY, 0), nRaw) + + if not bFirstStep and nProbeMode == 2 then + -- contromovimento e controrotazione del pezzo per riportarlo nelle condizioni originarie + EgtResetCurrMachGroup() + EgtMove( Pz, Point3d( pDistToMove:getX(), pDistToMove:getY(), 0) - ORIG(), GDB_RT.GLOB) + EgtRotate( Pz , ORIG(), Z_AX(), -dAngleToAlign ) + EgtSetCurrMachGroup() + EgtSetCurrPhase(nNumPhase) + end + + if bFirstStep then + -- se pezzo del telaio faccio l'opportuna rotazione + -- nDispJambsMode = 1: geometria verso il basso; = 2: geometria verso l'alto + if bFrame then + if nDispJambsMode > 0 then + bFlipFrame = false + if sAssemb == 'framesx' and not tsBoolData.bFrameOnWide then + bFrameOnNarrow = true + if (bPush and nDispJambsMode == 1) or (not bPush and nDispJambsMode == 2) then + EgtRotateRawPart( nRaw , Y_AX(), 90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + else + EgtRotateRawPart( nRaw , Y_AX(), -90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + bFlipFrame = true + end + elseif sAssemb == 'framedx' and not tsBoolData.bFrameOnWide then + bFrameOnNarrow = true + if (bPush and nDispJambsMode == 1) or (not bPush and nDispJambsMode == 2) then + EgtRotateRawPart( nRaw , Y_AX(), -90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + else + EgtRotateRawPart( nRaw , Y_AX(), 90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + bFlipFrame = true + end + elseif sAssemb == 'frametop' and not tsBoolData.bFrameOnWide then + bFrameOnNarrow = true + if (bPush and nDispJambsMode == 1) or (not bPush and nDispJambsMode == 2) then + EgtRotateRawPart( nRaw , Y_AX(), 90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + else + EgtRotateRawPart( nRaw , Y_AX(), -90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + bFlipFrame = true + end + elseif sAssemb == 'framebot' and not tsBoolData.bFrameOnWide then + bFrameOnNarrow = true + if (bPush and nDispJambsMode == 1) or (not bPush and nDispJambsMode == 2) then + EgtRotateRawPart( nRaw , Y_AX(), -90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + else + EgtRotateRawPart( nRaw , Y_AX(), 90) + EgtRotateRawPart( nRaw , Z_AX(), 180) + bFlipFrame = true + end + end + end + + -- se non è un frame disposto sul lato narrow verifico se il flag abilita le morse + if not bFrameOnNarrow then + bUseVise = tMainTabPar.UVFF and tMainTabPar.UVFF == 1 + end + end + end + + if bFirstStep and nProbeMode == 2 then + local dtempX = EgtIf( abs(b3Solid:getMin():getX()) < abs(b3Solid:getMax():getX()), b3Solid:getMin():getX(), b3Solid:getMax():getX()) + local dtempY = EgtIf( abs(b3Solid:getMin():getY()) < abs(b3Solid:getMax():getY()), b3Solid:getMin():getY(), b3Solid:getMax():getY()) + pMinRecalc = Point3d( dtempX, dtempY, 0) + else + pMinRecalc = Point3d( 0, 0, 0) + end + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitare inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + if v == 1 then -- solo il primo pezzo + + if bFirstStep then + tLocMach = MTable + tLocMachOrd = MTableOrd + if not bShiftMchng then + nIndexStartMach = 1 + end + else + tLocMach = tSecMachTab + tLocMachOrd = MTableOrd + if not bShiftMchng then + nIndexStartMach = 1 + end + end + end + + if bFirstStep and not bShiftMchng then + tsMachProf[v] = '' + end + + if v == #tPz then -- solo all'ultimo pezzo + + -- solo il primo giro, prendo nota dei profili tipo bevel + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + if bFirstStep and not bShiftMchng then + + local nUnderGeom + local tGeomThruUp = {} + local tGeomThruDw = {} + local tGeomBlindUp = {} + local tGeomBlindDw = {} + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + -- prendo i profili bevel direttamente dalla tabella + local sUpperProfName = string.upper(tLocMach[i].Name) + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName .. ',') then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) + + -- se è una porta + if not bFrame then + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata .. + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + tLocMach[i].Shift and tLocMach[i].Shift > 0 then + bSmallShiftedDoor = true + end + end + -- Test delle lavorazioni + for j = 1, #EntList do + local nTypeGeom = 0 + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom, nTypeGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + if nTypeGeom == 1 then -- se passante up + table.insert( tGeomThruUp, EntList[j]) + elseif nTypeGeom == 2 then -- se passante dw + table.insert( tGeomThruDw, EntList[j]) + elseif nTypeGeom == 3 then -- se cieca up + table.insert( tGeomBlindUp, EntList[j]) + elseif nTypeGeom == 4 then -- se cieca dw + table.insert( tGeomBlindDw, EntList[j]) + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom, nTypeGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + if nTypeGeom == 1 then -- se passante up + table.insert( tGeomThruUp, EntList[j]) + elseif nTypeGeom == 2 then -- se passante dw + table.insert( tGeomThruDw, EntList[j]) + elseif nTypeGeom == 3 then -- se cieca up + table.insert( tGeomBlindUp, EntList[j]) + elseif nTypeGeom == 4 then -- se cieca dw + table.insert( tGeomBlindDw, EntList[j]) + end + elseif tLocMach[i].Oper == 'AdjustBevel' then + table.insert( tGeomThruUp, EntList[j]) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + table.insert( tGeomThruUp, EntList[j]) + elseif tLocMach[i].Oper == 'AdjPrfThrouCurve' then + table.insert( tGeomThruUp, EntList[j]) + end + end + end + end + end + -- in base al tipo e al numero geometrie, vedo se invertire una sola geometria + if #tGeomThruUp == 1 and #tGeomThruDw == 0 and #tGeomBlindUp == 0 and #tGeomBlindDw > 1 then -- se condizione per invertire l'unica geometria UP + if nNumGeomBottom > 0 then + MB.InvertGeom(tGeomThruUp[1]) + end + end + if #tGeomThruDw == 1 and #tGeomThruUp == 0 and #tGeomBlindDw == 0 and #tGeomBlindUp > 1 then -- se condizione per invertire l'unica geometria UP + if nNumGeomTop > 0 then + MB.InvertGeom(tGeomThruDw[1]) + end + end + elseif not bFirstStep and not bShiftMchng then -- se porta ribaltata + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) + + -- se è una porta + if not bFrame then + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + tLocMach[i].Shift and tLocMach[i].Shift > 0 then + bSmallShiftedDoor = true + end + end + end + end + end + end + + -- se porta da disporre subito traslata o attiva proprietà narrow stile, setto i flag + if bSmallShiftedDoor or ( not bFrame and bNarrowStile) then + -- se narrowstile attiva, ricalcolo il valore dello shift + -- come differenza tra l'origine della porta e l'origine della barra fissa + if bNarrowStile then + if DISPMODE > 0 then -- se porta disposta a sinistra + tMainTabPar.SH1 = tMainTabPar.OR1f - tMainTabPar.OR1 + else -- altrimenti porta disposta a destra + tMainTabPar.SH1 = tMainTabPar.OR2f - tMainTabPar.OR2 + end + end + bShiftMchng = true -- porta traslata + bGenFirstStep = true -- flag per saltare il primo giro + end + end + + ----------------------- + -- *** Disposizione *** + ----------------------- + + if v == 1 then -- solo il primo pezzo + + local sTabPrev = sTab + -- Scelta della tavola (per ora gestisco max 2 tavole) + if NUMTABLE and NUMTABLE > 1 then -- se ho la seconda tavola + if nForceAsMultiTbl and nForceAsMultiTbl > 0 then + sTab = string.format( 'Tab%s', nForceAsMultiTbl) -- setto la tavola + EgtSetInfo( Pz, 'TableUsed', nForceAsMultiTbl) + else -- altrimenti assegno la tavola in base al materiale + if bWoodDoor then -- se ho una wood door la metto sulla prima + -- se altro materiale messo sulla tavola 1 lo standard lo metto sulla seconda + if nNumTblForOthMat and nNumTblForOthMat == 1 then -- se ho il numero tavola per altro materiale + sTab = string.format( 'Tab%s', NUMTABLE) -- setto la tavola + EgtSetInfo( Pz, 'TableUsed', NUMTABLE) + else -- altrimenti forzo sulla prima tavola + sTab = 'Tab1' -- setto la prima tavola + EgtSetInfo( Pz, 'TableUsed', 1) + end + elseif bSteelDoor then -- se ho una steel door la metto sulla seconda tavola + if nNumTblForOthMat and nNumTblForOthMat > 0 then -- se ho il numero tavola per altro materiale + sTab = string.format( 'Tab%s', nNumTblForOthMat) -- setto la tavola + EgtSetInfo( Pz, 'TableUsed', nNumTblForOthMat) + else -- altrimenti forzo sulla seconda tavola + sTab = 'Tab2' -- setto la seconda + EgtSetInfo( Pz, 'TableUsed', 2) + end + else -- altrimenti materiale standard + -- se altro materiale messo sulla tavola 1 lo standard lo metto sulla seconda + if nNumTblForOthMat and nNumTblForOthMat == 1 then -- se ho il numero tavola per altro materiale + sTab = string.format( 'Tab%s', NUMTABLE) -- setto la tavola + EgtSetInfo( Pz, 'TableUsed', NUMTABLE) + else -- altrimenti forzo sulla prima tavola + sTab = 'Tab1' -- setto la prima tavola + EgtSetInfo( Pz, 'TableUsed', 1) + end + end + end + else -- se macchina ha solo una tavola + -- se uso macchina con due tavole ma forzata a una sola tavola (solo la 1) + if nForceAsMultiTbl then + if nForceAsMultiTbl > 0 then + sTab = string.format( 'Tab%s', nForceAsMultiTbl) -- setto la tavola + EgtSetInfo( Pz, 'TableUsed', nForceAsMultiTbl) + else + sTab = 'Tab1' -- setto la prima tavola + EgtSetInfo( Pz, 'TableUsed', 1) + sTabx = 'Tab' + end + else + sTab = 'Tab' + EgtSetInfo( Pz, 'TableUsed', 1) + end + end + + if bFirstStep then + bSetTable = EgtSetTable( sTab) + if not bSetTable then + -- se sono nel caso che ho una sola tavola, probabilmente usa il nome semplice della tavola + if sTabx and sTabx ~= sTab then + sTab = sTabx + bSetTable = EgtSetTable( sTab) + end + if not bSetTable then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[676]..EgtDoorsMsg[682] -- Error in table setting. + break + end + end + else + if sTabPrev ~= sTab then + sTab = sTabPrev + end + end + + -- Origine tavola corrente rispetto a Zero macchina (anche se la macchina ha 2 tavole si deve mettere l'indice 1) + tabOri = EgtGetTableRef( 1) + end + + -- Rotazione porta in base alla macchina + bMoveRaw = false + local nCodeVacDisp = 0 + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- se non c'è il parametro considero la porta come se avesse bevel down + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. EgtNumToString( nNumPhase, 0) + elseif nNumPhase then + sNumPhase = EgtNumToString( nNumPhase, 0) + else + sNumPhase = '0' + end + + if bFirstStep then + + local bOkDisp = false + nNumProbeZ = 0 + + if bFrame then + + bOkDisp = true + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.FTDD, not tsBoolData.bAtRight, nil, nil, sAssemb) + +-- if not bFrameOnNarrow then + if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + -- forzo per a true + bTopOnRight = true + if bPush then + bTopOnRight = not bTopOnRight + end + end + elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + -- forzo per a true + bTopOnRight = true + if bPush then + bTopOnRight = not bTopOnRight + end + end + end +-- end + else + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if bPush and tsStringData.sHingeTrim == 'BD' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and tsStringData.sHingeTrim == 'BDEB' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif not bPush and tsStringData.sHingeTrim == 'BD' and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and tsStringData.sHingeTrim == 'BDEB'and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and tsStringData.sHingeTrim == 'BU' and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and tsStringData.sHingeTrim == 'BUEB' and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif bPush and tsStringData.sHingeTrim == 'BU' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and tsStringData.sHingeTrim == 'BUEB' and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel currcaminfo + if ( bPush and ( tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BDEB')) or + ( not bPush and ( tsStringData.sHingeTrim == 'BU' or tsStringData.sHingeTrim == 'BUEB')) then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- in caso la porta è ad arco, dispongo la porta + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) + if not bOkDisp and ( tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB') then + + -- verifico se i profili risultanti sono presenti in tabella + if bPush and tsStringData.sLockTrim == 'BD' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and tsStringData.sLockTrim == 'BDEB' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and tsStringData.sLockTrim == 'BD' and not string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif bPush and tsStringData.sLockTrim == 'BDEB' and not string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and tsStringData.sLockTrim == 'BU' and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and tsStringData.sLockTrim == 'BUEB' and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif bPush and tsStringData.sLockTrim == 'BU' and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and tsStringData.sLockTrim == 'BUEB' and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + if ( bPush and ( tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BDEB')) or + ( not bPush and ( tsStringData.sLockTrim == 'BU' or tsStringData.sLockTrim == 'BUEB')) then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + end + end + + -- se arco abilitato e profilo top indicato bevel (e da lavorare) + if not bOkDisp and ( tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BD_H' or + tsStringData.sTopTrim == 'BU' or tsStringData.sTopTrim == 'BU_H' or + tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BDEB_H' or + tsStringData.sTopTrim == 'BUEB' or tsStringData.sTopTrim == 'BUEB_H') then + + -- verifico se i profili risultanti sono presenti in tabella + if bPush and ( tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BD_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and ( tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BDEB_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BD_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BDEB_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sTopTrim == 'BU' or tsStringData.sTopTrim == 'BU_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sTopTrim == 'BUEB' or tsStringData.sTopTrim == 'BUEB_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif bPush and ( tsStringData.sTopTrim == 'BU' or tsStringData.sTopTrim == 'BU_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and ( tsStringData.sTopTrim == 'BUEB' or tsStringData.sTopTrim == 'BUEB_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + if ( bPush and ( tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BD_H' or + tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BDEB_H')) or + ( not bPush and ( tsStringData.sTopTrim == 'BU' or tsStringData.sTopTrim == 'BU_H' or + tsStringData.sTopTrim == 'BUEB' or tsStringData.sTopTrim == 'BUEB_H')) then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if not bOkDisp and ( tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BD_H' or + tsStringData.sBottomTrim == 'BU' or tsStringData.sBottomTrim == 'BU_H' or + tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BDEB_H' or + tsStringData.sBottomTrim == 'BUEB' or tsStringData.sBottomTrim == 'BUEB_H') then + + -- verifico se i profili risultanti sono presenti in tabella + if bPush and ( tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BD_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and ( tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BDEB_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BD_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BDEB_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sBottomTrim == 'BU' or tsStringData.sBottomTrim == 'BU_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif not bPush and ( tsStringData.sBottomTrim == 'BUEB' or tsStringData.sBottomTrim == 'BUEB_H') and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif bPush and ( tsStringData.sBottomTrim == 'BU' or tsStringData.sBottomTrim == 'BU_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif bPush and ( tsStringData.sBottomTrim == 'BUEB' or tsStringData.sBottomTrim == 'BUEB_H') and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + if ( bPush and ( tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BD_H' or + tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BDEB_H')) or + ( not bPush and ( tsStringData.sBottomTrim == 'BU' or tsStringData.sBottomTrim == 'BU_H' or + tsStringData.sBottomTrim == 'BUEB' or tsStringData.sBottomTrim == 'BUEB_H')) then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo + else + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore + if tsStringData.sSecure and string.upper(tsStringData.sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + tsStringData.sSecure = tMainTabPar.LS + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if tsStringData.sSecure and string.upper(tsStringData.sSecure) == 'UP' then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + elseif tsStringData.sSecure and string.upper(tsStringData.sSecure) == 'DN' then + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) qualla di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if tsBoolData.bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + -- se porta a tirare non la ribalto perché si presta già ad essere bevel down + else + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + -- in attesa delle considerazioni del cliente, in base alle geometrie trovate ribalto oppure no la porta + else + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + else -- altrimenti vecchio metodo + bFlip = true + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, tsBoolData.bAtRight, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + end + end + end + + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sAssemb == 'framesx' then + if bPush then + if bTopOnRight then -- se top a destra + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + bTopOnRight = true + end + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + else + if bTopOnRight then -- se top a destra + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + bTopOnRight = false + end + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + end + end + elseif sAssemb == 'framedx' then + if bPush then + if bTopOnRight then -- se top a destra + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + bTopOnRight = false + end + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + end + else + if bTopOnRight then -- se top a destra + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + bTopOnRight = true + end + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + end + elseif sAssemb == 'frametop' then + if tMainTabPar.MJT == 0 then -- da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + if tMainTabPar.FTDD == 0 then -- se mantengo il lato porta sul fronte + bTopOnRight = not bTopOnRight + end + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) + nCodeVacDisp = 2 + end + elseif sAssemb == 'framebot' then + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + -- door + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) + end + + if v == #tPz then -- solo all'ultimo pezzo + -- se porta da traslare setto lo shift da applicare + if bShiftMchng then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto + if nProbeMode == 1 then + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimenenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + end + -- mi tengo via il numero di probe in Z + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbePoint') + end + -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto + elseif nProbeMode == 0 and nPostProbeSet >= 3 then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimenenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + end + -- mi tengo via il numero di probe sul fianco + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbeSidePoint') + end + else -- se non c'è il probe point elimino tutti i percorsi di probe (in Z e xy) + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + end + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ + local nSideOppoType = -1 -- 0 per profili SQ + local sProfName + local sProfOppoName -- nome profilo lato opposto alla battuta + local bCalcProf = false + local bCalcProfOppo = false + + -- per i frame non calcolo distanza profilo su finito + if bFrame then + bCalcProf = false + bCalcProfOppo = false + else + + -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota + if tsBoolData.bHingeMach then + nHingeMach = 1 + end + -- se profilo lock da lavorare setto la variabile per la nota + if tsBoolData.bLockMach then + nLockMach = 1 + end + + -- se il profilo hinge è in battuta + if ( not bFlip and bTopOnRight and not tsBoolData.bAtRight) or ( not bFlip and not bTopOnRight and tsBoolData.bAtRight) or + ( bFlip and bTopOnRight and tsBoolData.bAtRight) or ( bFlip and not bTopOnRight and not tsBoolData.bAtRight) then + sProfName = tsStringData.sHingeTrim + sProfOppoName = tsStringData.sLockTrim + tsDoubleData.dRadiusPrf = tsRadiusProf[1] + tsDoubleData.dPlanePrf = tsPlaneProf[1] + bHingeOnRef = true + -- se il profilo hinge non è da lavorare + if not tsBoolData.bHingeMach then + bCalcProf = true + end + -- se il profilo lock non è da lavorare + if not tsBoolData.bLockMach then + bCalcProfOppo = true + end + else -- altrimenti è il profilo lock in battuta + sProfName = tsStringData.sLockTrim + sProfOppoName = tsStringData.sHingeTrim + tsDoubleData.dRadiusPrf = tsRadiusProf[2] + tsDoubleData.dPlanePrf = tsPlaneProf[2] + bHingeOnRef = false + -- se il profilo lock non è da lavorare + if not tsBoolData.bLockMach then + bCalcProf = true + end + -- se il profilo hinge non è da lavorare + if not tsBoolData.bHingeMach then + bCalcProfOppo = true + end + end + bTopOnRef = ( bTopOnRight and DISPMODE < 0) or ( not bTopOnRight and DISPMODE > 0) + + if nProbeMode == 2 then + bCalcProf = false + bCalcProfOppo = false + end + end + + -- se devo calcolare eventuale spostamento dato dal profilo in battuta + if bCalcProf then + if sProfName == 'SQ' or sProfName == 'EB' then + nSideType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sProfName == 'BD' or sProfName == 'BDEB' then + nSideType = 1 + if tsDoubleData.dThickDoor > tMainTabPar.AR then + dExtraY = ( tsDoubleData.dThickDoor - tMainTabPar.AR) * TAN3 + end + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( tsDoubleData.dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up uso il riferimento in basso + elseif sProfName == 'BU' or sProfName == 'BUEB' then + nSideType = 2 + dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = (( tsDoubleData.dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( tsDoubleData.dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sProfName == '1B' or sProfName == '2B' or sProfName == '3B' or sProfName == '4B' or + sProfName == '5B' or sProfName == '6B' or sProfName == '7B' or sProfName == '8B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then + dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > tMainTabPar.AR then + dAltcalc = dAltProf - tMainTabPar.AR + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = tsDoubleData.dRadiusPrf - sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sProfName == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 + local dAltcalc = (tMainTabPar.TR/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-((dAltProf-tsDoubleData.dPlanePrf)*(dAltProf-tsDoubleData.dPlanePrf))) + + -- se riferimento è sul max ingombro porta + if ( tsDoubleData.dThickDoor < tMainTabPar.AR) and ( tsDoubleData.dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = tMainTabPar.AR - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = tsDoubleData.dRadiusPrf - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + end + + if bCalcProfOppo then + if sProfOppoName == 'SQ' or sProfOppoName == 'EB' then + nSideOppoType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfOppoName == 'BD' or sProfOppoName == 'BDEB' then + nSideOppoType = 1 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra p + dDeltaProfOppo = ((( tsDoubleData.dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + -- se disposizione bevel up uso il riferimento in basso + elseif sProfOppoName == 'BU' or sProfOppoName == 'BUEB' then + nSideOppoType = 2 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = (( tsDoubleData.dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( tsDoubleData.dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + -- se profilo bull nose verifico in base al raggio + elseif sProfOppoName == '1B' or sProfOppoName == '2B' or sProfOppoName == '3B' or sProfOppoName == '4B' or + sProfOppoName == '5B' or sProfOppoName == '6B' or sProfOppoName == '7B' or sProfOppoName == '8B' then + + nSideOppoType = 3 + -- se profilo convex verifico in base al raggio + elseif sProfOppoName == 'CV' then + + nSideOppoType = 4 + local dAltProfOppo + local dAltProfOppoTh + local dExtraYOppoTh + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo punto minimo ingombro profilo + dAltProfOppoTh = tsDoubleData.dThickDoor/2 - tsDoubleData.dPlanePrf + -- calcolo errore del probe tastando a spessore completo - extra z + dAltProfOppo = (tsDoubleData.dThickDoor/2) - tMainTabPar.EZPB - tsDoubleData.dPlanePrf + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + dExtraYOppoTh = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppoTh*dAltProfOppoTh)) + -- calcolo errore del probe tastando dallo spessore - quota extra z + dDeltaProfOppo = dExtraYOppo - dExtraYOppoTh + else + -- calcolo punto minimo ingombro profilo + dAltProfOppo = tsDoubleData.dThickDoor/2 - tsDoubleData.dPlanePrf + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = tsDoubleData.dRadiusPrf - dExtraYOppo + end + end + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + EgtSetInfo( Pz, 'Piece Type', tsDoubleData.TypePiece) + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProbeThick', tMainTabPar.PTK) + EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition', DISPMODE) + EgtSetInfo( Pz, 'UseViseWithFrame', bUseVise) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) + EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) + -- scrivo nota flag modalita remove scrap + EgtSetInfo( Pz, 'RemoveScrapMode', tMainTabPar.RSM) + -- scrivo nota altezza riferimento e spessore riferimento + EgtSetInfo( Pz, 'ReferenceHeight', tMainTabPar.AR) + EgtSetInfo( Pz, 'ReferenceTall', tMainTabPar.TR) + -- scrivo posizioni riferimenti + EgtSetInfo( Pz, 'ReferencePos1', tMainTabPar.REF1) + EgtSetInfo( Pz, 'ReferencePos2', tMainTabPar.REF2) + EgtSetInfo( Pz, 'ReferencePos3', tMainTabPar.REF3) + EgtSetInfo( Pz, 'ReferencePos4', tMainTabPar.REF4) + + local vExtraXY + local dExtraX = 0 + dExtraY = 0 + local nCorner = MCH_CR.BL + + if sAssemb == 'framesx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framedx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'frametop' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framebot' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + else + + -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) + + if nProbeMode == 2 then + local btempX = EgtIf( bTopOnRight, bFlip, not bFlip) + bMoveRaw = EgtMoveRawPart( nRaw, Vector3d( EgtIf( bTopOnRight, pMinRecalc:getY(), -pMinRecalc:getY()), EgtIf( btempX, pMinRecalc:getX(), -pMinRecalc:getX()), 0)) + end + end + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + else -- se sono in ribaltamento porta + + if bFrame then + if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto + if bPush then + bTopOnRight = not bTopOnRight + end + elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso + if bPush then + bTopOnRight = not bTopOnRight + end + end + else + -- posizioni opposte + local nSelDisp = 0 + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not bTopOnRightFirst, tsDoubleData.dTopRadius, tsDoubleData.dTopAngle) + end + + bFlip = not bFlipFirst + nNumProbeZ = 0 + + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sAssemb == 'framesx' then + if bPush then + if bTopOnRight then -- se top a destra + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + else + if bTopOnRight then -- se top a destra + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + end + end + elseif sAssemb == 'framedx' then + if bPush then + if bTopOnRight then -- se top a destra + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + end + else + if bTopOnRight then -- se top a destra + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + if tMainTabPar.MJT == 0 then -- se da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + end + elseif sAssemb == 'frametop' then + if tMainTabPar.MJT == 0 then -- da lavorare uno alla volta + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) + nCodeVacDisp = 2 + end + elseif sAssemb == 'framebot' then + if bUseVise then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1fv, tMainTabPar.OR2fv) + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + end + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) + end + + if v == #tPz then -- solo all'ultimo pezzo + -- se porta da traslare setto lo shift da applicare + if bShiftMchng then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + +-- -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto +-- if nProbeMode == 0 and nPostProbeSet >= 3 then +-- DelList = MB.FindEntitiesWithName( tPz, 'NO_ProbeSidePoint') +-- -- ciclo su tutte le entità trovate +-- for j = 1, #DelList do +-- EgtSetName( DelList[j], 'ProbeSidePoint') +-- end +-- DelList = MB.FindEntitiesWithName( tPz, 'ProbeSidePoint') +-- -- ciclo su tutte le entità trovate +-- for j = 1, #DelList do +-- -- se prima non era flippata +-- if bFlip then +-- EgtSetName( DelList[j], 'ProbeSidePoint_keyway') +-- else +-- EgtSetName( DelList[j], 'ProbeSidePoint_secure') +-- end +-- end +-- -- rinomino i rimenenti +-- if bFlip then +-- DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') +-- else +-- DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') +-- end +-- -- mi tengo via il numero di probe sul fianco +-- nNumProbeZ = #DelList +-- -- ciclo su tutte le entità trovate +-- for j = 1, #DelList do +-- EgtSetName( DelList[j], 'ProbeSidePoint') +-- end +-- end + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + nSideType = -1 -- 0 per profili SQ + local nSideOppoType = -1 -- 0 per profili SQ + local sProfName -- nome profilo in battuta + local sProfOppoName -- nome profilo lato opposto alla battuta + local bCalcProf = false + local bCalcProfOppo = false + + -- per i frame non calcolo distanza profilo su finito + if bFrame then + bCalcProf = false + bCalcProfOppo = false + else + + -- se profilo hinge è da lavorare e non è stato lavorato setto il valore della nota + if tsBoolData.bHingeMach and not DGD.MHS then + nHingeMach = 1 + end + -- se profilo lock é da lavorare e non è stato lavorato setto la variabile per la nota + if tsBoolData.bLockMach and not DGD.MLS then + nLockMach = 1 + end + + -- se il profilo hinge è in battuta + if ( not bFlip and bTopOnRight and not tsBoolData.bAtRight) or ( not bFlip and not bTopOnRight and tsBoolData.bAtRight) or + ( bFlip and bTopOnRight and tsBoolData.bAtRight) or ( bFlip and not bTopOnRight and not tsBoolData.bAtRight) then + sProfName = tsStringData.sHingeTrim + sProfOppoName = tsStringData.sLockTrim + tsDoubleData.dRadiusPrf = tsRadiusProf[1] + tsDoubleData.dPlanePrf = tsPlaneProf[1] + bHingeOnRef = true + -- se il profilo hinge non è da lavorare o è già stato lavorato + if not tsBoolData.bHingeMach or DGD.MHS then + bCalcProf = true + end + -- se il profilo lock non è da lavorare o è già stato lavorato + if not tsBoolData.bLockMach or DGD.MLS then + bCalcProfOppo = true + end + else -- altrimenti è il profilo lock in battuta + sProfName = tsStringData.sLockTrim + sProfOppoName = tsStringData.sHingeTrim + tsDoubleData.dRadiusPrf = tsRadiusProf[2] + tsDoubleData.dPlanePrf = tsPlaneProf[2] + bHingeOnRef = false + -- se il profilo lock non è da lavorare o è già stato lavorato + if not tsBoolData.bLockMach or DGD.MLS then + bCalcProf = true + end + -- se il profilo hinge non è da lavorare o è già stato lavorato + if not tsBoolData.bHingeMach or DGD.MHS then + bCalcProfOppo = true + end + end + bTopOnRef = ( bTopOnRight and DISPMODE < 0) or ( not bTopOnRight and DISPMODE > 0) +--[[ + -- se il profilo in battuta non è da lavorare o è già stato lavorato + if ( not tsBoolData.bHingeMach or DGD.MHS) and ( ( not bFlip and bTopOnRight and not tsBoolData.bAtRight) or ( not bFlip and not bTopOnRight and tsBoolData.bAtRight) or + ( bFlip and bTopOnRight and tsBoolData.bAtRight) or ( bFlip and not bTopOnRight and not tsBoolData.bAtRight)) then + sProfName = tsStringData.sHingeTrim + sProfOppoName = tsStringData.sLockTrim + bHingeOnRef = true + bCalcProf = true + elseif ( not tsBoolData.bLockMach or DGD.MLS) and ( ( not bFlip and bTopOnRight and tsBoolData.bAtRight) or ( not bFlip and not bTopOnRight and not tsBoolData.bAtRight) or + ( bFlip and bTopOnRight and not tsBoolData.bAtRight) or ( bFlip and not bTopOnRight and tsBoolData.bAtRight)) then + sProfName = tsStringData.sLockTrim + sProfOppoName = tsStringData.sHingeTrim + bHingeOnRef = false + bCalcProf = true + end +]]-- + end + + -- se devo calcolare eventuale spostamento dato dal profilo in battuta + if bCalcProf then + if sProfName == 'SQ' or sProfName == 'EB' then + nSideType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfName == 'BU' or sProfName == 'BUEB' then + nSideType = 1 + if tsDoubleData.dThickDoor > tMainTabPar.AR then + dExtraY = ( tsDoubleData.dThickDoor - tMainTabPar.AR) * TAN3 + end + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( tsDoubleData.dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso + elseif sProfName == 'BD' or sProfName == 'BDEB' then + nSideType = 2 + dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = (( tsDoubleData.dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( tsDoubleData.dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sProfName == '1B' or sProfName == '2B' or sProfName == '3B' or sProfName == '4B' or + sProfName == '5B' or sProfName == '6B' or sProfName == '7B' or sProfName == '8B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then + dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > tMainTabPar.AR then + dAltcalc = dAltProf - tMainTabPar.AR + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = tsDoubleData.dRadiusPrf - sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sProfName == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 + local dAltcalc = (tMainTabPar.TR/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-((dAltProf-tsDoubleData.dPlanePrf)*(dAltProf-tsDoubleData.dPlanePrf))) + + -- se riferimento è sul max ingombro porta + if ( tsDoubleData.dThickDoor < tMainTabPar.AR) and ( tsDoubleData.dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = tMainTabPar.AR - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore +-- dDeltaProbe = dRadiusPrf - dExtraY +-- dDeltaProf = dRadiusPrf - dMaxInsPrf + dDeltaProbe = tsDoubleData.dRadiusPrf - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + end + + if bCalcProfOppo then + if sProfOppoName == 'SQ' or sProfOppoName == 'EB' then + nSideOppoType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfOppoName == 'BU' or sProfOppoName == 'BUEB' then + nSideOppoType = 1 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra p + dDeltaProfOppo = ((( tsDoubleData.dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso + elseif sProfOppoName == 'BD' or sProfOppoName == 'BDEB' then + nSideOppoType = 2 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = (( tsDoubleData.dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( tsDoubleData.dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + elseif sProfOppoName == '1B' or sProfOppoName == '2B' or sProfOppoName == '3B' or sProfOppoName == '4B' or + sProfOppoName == '5B' or sProfOppoName == '6B' or sProfOppoName == '7B' or sProfOppoName == '8B' then + + nSideOppoType = 3 + -- se profilo convex verifico in base al raggio + elseif sProfOppoName == 'CV' then + + nSideOppoType = 4 + local dAltProfOppo + local dAltProfOppoTh + local dExtraYOppoTh + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo punto minimo ingombro profilo + dAltProfOppoTh = tsDoubleData.dThickDoor/2 - tsDoubleData.dPlanePrf + -- calcolo errore del probe tastando a spessore completo - extra z + dAltProfOppo = (tsDoubleData.dThickDoor/2) - tMainTabPar.EZPB - tsDoubleData.dPlanePrf + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + dExtraYOppoTh = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppoTh*dAltProfOppoTh)) + -- calcolo errore del probe tastando dallo spessore - quota extra z + dDeltaProfOppo = dExtraYOppo - dExtraYOppoTh + else + -- calcolo punto minimo ingombro profilo + dAltProfOppo = tsDoubleData.dThickDoor/2 - tsDoubleData.dPlanePrf + -- calcolo il delta Y + dExtraYOppo = sqrt((tsDoubleData.dRadiusPrf*tsDoubleData.dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = tsDoubleData.dRadiusPrf - dExtraYOppo + end + end + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + -- se sono ancora nella prima fase e non sono state fatte lavorazioni allora setto le note + -- ancora per la prima disposizione + if nNumPhase and nNumPhase == 1 and nNumMach == 0 then + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProbeThick', tMainTabPar.PTK) + EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition', DISPMODE) + EgtSetInfo( Pz, 'UseViseWithFrame', bUseVise) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) + EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) + -- scrivo nota flag modalita remove scrap + EgtSetInfo( Pz, 'RemoveScrapMode', tMainTabPar.RSM) + -- scrivo nota altezza riferimento e spessore riferimento + EgtSetInfo( Pz, 'ReferenceHeight', tMainTabPar.AR) + EgtSetInfo( Pz, 'ReferenceTall', tMainTabPar.TR) + -- scrivo posizioni riferimenti + EgtSetInfo( Pz, 'ReferencePos1', tMainTabPar.REF1) + EgtSetInfo( Pz, 'ReferencePos2', tMainTabPar.REF2) + EgtSetInfo( Pz, 'ReferencePos3', tMainTabPar.REF3) + EgtSetInfo( Pz, 'ReferencePos4', tMainTabPar.REF4) + else + EgtSetInfo( Pz, 'ExtraCalcMoveY_2', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY_2', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ_2', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProbeThick', tMainTabPar.PTK) + EgtSetInfo( Pz, 'DoorProfErrorY_2', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY_2', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition_2', DISPMODE) + EgtSetInfo( Pz, 'UseViseWithFrame_2', bUseVise) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach_2', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf_2', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef_2', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo_2', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach_2', nLockMach) + -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) + EgtSetInfo( Pz, 'NumProbeZ_2', nNumProbeZ) + -- scrivo nota altezza riferimento e spessore riferimento + EgtSetInfo( Pz, 'ReferenceHeight_2', tMainTabPar.AR) + EgtSetInfo( Pz, 'ReferenceTall_2', tMainTabPar.TR) + -- scrivo posizioni riferimenti + EgtSetInfo( Pz, 'ReferencePos1_2', tMainTabPar.REF1) + EgtSetInfo( Pz, 'ReferencePos2_2', tMainTabPar.REF2) + EgtSetInfo( Pz, 'ReferencePos3_2', tMainTabPar.REF3) + EgtSetInfo( Pz, 'ReferencePos4_2', tMainTabPar.REF4) + end + local vExtraXY + local dExtraX = 0 + dExtraY = 0 + local nCorner = MCH_CR.BL + + if sAssemb == 'framesx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framedx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'frametop' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framebot' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, tsDoubleData.dLeftOffs, tsDoubleData.dRightOffs, tsDoubleData.dTopOffs, + tsDoubleData.dBottomOffs, bFlip, tMainTabPar.FTDD) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + else + -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) + end + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + --nTime = EgtStopCounter() + --if not DGD or not DGD.NCGEN then + -- EgtOutBox( string.format( 'tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') + --end + + -- inizializzo il contatore + --EgtStartCounter() + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[676]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + if bFirstStep then + if bShiftMchng then + sNotePhase = 'SHIFT' + else + sNotePhase = 'NORMAL' + end + else + if bShiftMchng then + sNotePhase = 'FLIPSHIFT' + else + sNotePhase = 'FLIP' + end + end + + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'MachineNameFromCurrCamInfo', tMainTabPar.MN) + EgtSetInfo( Pz, 'DoorOnTable_' .. EgtNumToString( nNumPhase, 0) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase_' .. EgtNumToString( nNumPhase, 0) .. '_' .. tMainTabPar.MN, sNotePhase) + -- salvo note per porta ribaltata rispetto al ddf e per disposizione lato top + EgtSetInfo( Pz, 'DispPhase_' .. EgtNumToString( nNumPhase, 0) , EgtIf( bFlip, 'F', 'N')) + EgtSetInfo( Pz, 'DispTopOn_' .. EgtNumToString( nNumPhase, 0) , EgtIf( bTopOnRight, 'R', 'L')) + + if bFlip then -- se porta capovolta + if bTopOnRight then -- se top a destra + -- il lato sinistro appoggia sui riferimenti + OffsYSovr = tsDoubleData.dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, tsDoubleData.dBottomOffs, tsDoubleData.dTopOffs) + else -- se top a sinistra + -- il lato destro appoggia sui riferimenti + OffsYSovr = tsDoubleData.dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, tsDoubleData.dTopOffs, tsDoubleData.dBottomOffs) + end + else -- altrimenti non è capovolta + if bTopOnRight then -- se top a destra + -- il lato destro appoggia sui riferimenti + OffsYSovr = tsDoubleData.dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, tsDoubleData.dBottomOffs, tsDoubleData.dTopOffs) + else -- se top a sinistra + -- il lato sinistro appoggia sui riferimenti + OffsYSovr = tsDoubleData.dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, tsDoubleData.dTopOffs, tsDoubleData.dBottomOffs) + end + end + + -- se frame riassegno il valore del sovramateriale perché viene tenuto a filo della ventosa + if bFrame then + if nCodeVacDisp == 1 then + if bUseVise then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR1fv:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR2fv:getX() - tMainTabPar.OR2:getX())) + else + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR1f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR2f:getX() - tMainTabPar.OR2:getX())) + end + elseif nCodeVacDisp == 2 then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR3f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR4f:getX() - tMainTabPar.OR2:getX())) + elseif nCodeVacDisp == 3 then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR5f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR6f:getX() - tMainTabPar.OR2:getX())) + end + end + + -- Controllo dimensioni pezzo + -- se è un frame + if bFrame then + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( bFrame, tsDoubleData.dLengthDoor, tsDoubleData.dWidthDoor, tsDoubleData.dThickDoor, 0, 0, 0, 0) + else + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( bFrame, tsDoubleData.dLengthDoor, tsDoubleData.dWidthDoor, tsDoubleData.dThickDoor, OffsXSovr, OffsYSovr, vShift:getX(), vShift:getY()) + end + + if bFailDim then + + DGD.ERR = 19 + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + DoorOutLog( DGD.EMC, 0) + EgtOutBox( ' Err=' .. EgtNumToString( DGD.ERR, 0) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + + ----------------------------------------------------------------------------------------------------------------- + -- abilito/disabilito geometrie probe in base alla lavorazione o meno del fianco e dal tipo di profilo di questo + ----------------------------------------------------------------------------------------------------------------- + -- se profilo hinge è da lavorare rinomino i percorsi di probe per non farli + if tsBoolData.bHingeMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore a: spessore probe + extra probe z + elseif not tsBoolData.bHingeMach and ( tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then +-- EgtModifyCurveThickness( ProbeList[j], 0) + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif not tsBoolData.bHingeMach and ( tsStringData.sHingeTrim == '1B' or tsStringData.sHingeTrim == '2B' or tsStringData.sHingeTrim == '3B' or tsStringData.sHingeTrim == '4B' or + tsStringData.sHingeTrim == '5B' or tsStringData.sHingeTrim == '6B' or tsStringData.sHingeTrim == '7B' or tsStringData.sHingeTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -( tsDoubleData.dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not tsBoolData.bHingeMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) +-- EgtModifyCurveThickness( ProbeList[j], 0) + -- se profilo bevel up assegno nota + if tsStringData.sHingeTrim == 'BU' or tsStringData.sHingeTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + -- se profilo lock è da lavorare rinomino i percorsi di probe per non farli + if tsBoolData.bLockMach then + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not tsBoolData.bLockMach and ( tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then +-- EgtModifyCurveThickness( ProbeList[j], 0) + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif not tsBoolData.bLockMach and ( tsStringData.sLockTrim == '1B' or tsStringData.sLockTrim == '2B' or tsStringData.sLockTrim == '3B' or tsStringData.sLockTrim == '4B' or + tsStringData.sLockTrim == '5B' or tsStringData.sLockTrim == '6B' or tsStringData.sLockTrim == '7B' or tsStringData.sLockTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -( tsDoubleData.dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not tsBoolData.bLockMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) +-- EgtModifyCurveThickness( ProbeList[j], 0) + -- se profilo bevel up assegno nota + if tsStringData.sLockTrim == 'BU' or tsStringData.sLockTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + -- se profilo top è da lavorare rinomino i percorsi di probe per non farli + if tsBoolData.bTopMach then + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not tsBoolData.bTopMach and ( tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then +-- EgtModifyCurveThickness( ProbeList[j], 0) + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not tsBoolData.bTopMach and ( tsStringData.sTopTrim == '1B' or tsStringData.sTopTrim == '2B' or tsStringData.sTopTrim == '3B' or tsStringData.sTopTrim == '4B' or + tsStringData.sTopTrim == '5B' or tsStringData.sTopTrim == '6B' or tsStringData.sTopTrim == '7B' or tsStringData.sTopTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -( tsDoubleData.dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not tsBoolData.bTopMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) +-- EgtModifyCurveThickness( ProbeList[j], 0) + -- se profilo bevel up assegno nota + if tsStringData.sTopTrim == 'BU' or tsStringData.sTopTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + -- se profilo bottom è da lavorare oppure non da lavorare ma con profilo bevel up rinomino i percorsi di probe per non farli + if tsBoolData.bBottomMach then + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not tsBoolData.bBottomMach and ( tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then +-- EgtModifyCurveThickness( ProbeList[j], 0) + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not tsBoolData.bBottomMach and ( tsStringData.sBottomTrim == '1B' or tsStringData.sBottomTrim == '2B' or tsStringData.sBottomTrim == '3B' or tsStringData.sBottomTrim == '4B' or + tsStringData.sBottomTrim == '5B' or tsStringData.sBottomTrim == '6B' or tsStringData.sBottomTrim == '7B' or tsStringData.sBottomTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -( tsDoubleData.dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not tsBoolData.bBottomMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) +-- EgtModifyCurveThickness( ProbeList[j], 0) + -- se profilo bevel up assegno nota + if tsStringData.sBottomTrim == 'BU' or tsStringData.sBottomTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + ------------------------------------------- + -- Inserimento riferimenti e ventose/morse + ------------------------------------------- + + if v == 1 then + -- Offset barra riferimenti mobile da riferimenti quando posizione 0 + dMobOffs2 = 0 + dMobOffs1 = dMobOffs2 / 2 -- è in posizione intermedia + -- Lunghezza minima per alzare prima ventosa da bordo sinistro + -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) +-- dDistMinX = 296.8 + 5.5 + 46.7 + -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza + dDistMinX = tMainTabPar.DVL + 92.075 + DIST_MIN_VAC + -- Lunghezza minima per alzare prima ventosa da bordo destro + -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) +-- dDistMaxX = 185.1 + 5.5 + 46.7 + -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza + dDistMaxX = tMainTabPar.DVR + 92.075 + DIST_MIN_VAC + -- Posizione ventose in alto + dVacOn = 1 + -- Interasse ventose lungo la barra + dInterAx = 193.68 + -- setto modaità due barre disabilitato + bUseOnly2Bars = false + + -- Ventose + nTabId = EgtGetTableId( sTab) + nMobId1 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE1') + nMobId2 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE2') + nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') + -- Riferimenti: faccio una ricerca dedicata per via che non si conoscono ancora i nomi esatti + -- dei riferimenti inseriti + if tMainTabPar.CUC == 1 then + tRefArea = FindRefInTable( nTabId, 'REF_') + end + nDispId = EgtGetPhaseDisposition( nNumPhase) + + -- se gruppi richiesti non trovati + if not nMobId1 or not nMobId2 or not nFixId then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[676]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' + break + end + + -- Posizionamento barra mobile + -- fisso + dFixval = EgtGetInfo( nFixId, 'Val', 'd') + -- scrivo il valore della barra fissa + EgtSetInfo( nDispId, 'FIX1', dFixval) + -- mobile 2 + dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') + + if bFrame then -- se è un frame + dNewVal_2 = tMainTabPar.FPB + else + if tsDoubleData.dTopRadius then -- se la porta è ad arco calcolo la disposizione sulla terza barra simmetrica alla prima + if bFirstStep then + dNewVal_2 = b3Solid:getDimX() - dFixval + (2*OffsYSovr) + vShiftVac:getY() - dMobOffs2 -- calcolo la posizione simmetrica +-- dNewVal_2 = b3Solid:getDimX() - dFixval + (2*OffsYSovr) - vShift:getY() + vShiftVac:getY() - dMobOffs2 -- calcolo la posizione simmetrica + end + else + -- calcolo la disposizione sulla terza barra simmetrica alla prima + if bFirstStep then + dNewVal_2 = b3Solid:getDimX() - dFixval + (2*OffsYSovr) + vShiftVac:getY() - dMobOffs2 -- calcolo la posizione simmetrica +-- dNewVal_2 = b3Solid:getDimX() - dFixval + (2*OffsYSovr) - vShift:getY() + vShiftVac:getY() - dMobOffs2 -- calcolo la posizione simmetrica + -- prediligo la conservazione delle ventose sulla terza barra +-- dNewVal_2 = b3Solid:getDimX() - dFixval + OffsYSovr - vShift:getY() + vShiftVac:getY() - dMobOffs2 + end + end + end + + -- controllo che non supera la posizione massima raggiungibile + if dNewVal_2 > tMainTabPar.MPMB then + dNewVal_2 = tMainTabPar.MPMB + end + + -- Se posizione raggiungibile + if ( dNewVal_2 - dFixval + (2*vShift:getY())) >= ( 2 * dMinDistGroup) then + -- mobile 2 + if bFirstStep then + dNewVal_2 = dNewVal_2 + 2 * vShift:getY() + EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) + end + EgtSetInfo( nMobId2, 'Val', dNewVal_2) + EgtSetInfo( nDispId, 'MOB2', dNewVal_2) + -- mobile 1 + if bFirstStep then + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + dNewVal_1 = ( dNewVal_2 + dFixval) / 2 + EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) + end + EgtSetInfo( nMobId1, 'Val', dNewVal_1) + EgtSetInfo( nDispId, 'MOB1', dNewVal_1) + else + -- controllo se con due barre è possibile + if ( dNewVal_2 - dFixval + (2*vShift:getY())) >= dMinDistGroup then + -- mobile 1 + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + -- se proprietà narrow stile attiva, aggiungo al movimento lo shift e la distanza riferimento ventosa +-- if bNarrowStile then + dNewVal_1 = dNewVal_2 + 2 * vShift:getY() +-- else +-- dNewVal_1 = dNewVal_2 +-- end + EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId1, 'Val', dNewVal_1) + EgtSetInfo( nDispId, 'MOB1', dNewVal_1) + -- mobile 2 + dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') + dNewVal_2 = (dNewVal_1 * 2) - dFixval + EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId2, 'Val', dNewVal_2) + EgtSetInfo( nDispId, 'MOB2', dNewVal_2) + bUseOnly2Bars = true + else + -- mobile 2 + EgtSetInfo( nDispId, 'MOB2', dOldVal) + -- mobile 1 + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + EgtSetInfo( nDispId, 'MOB1', dOldVal) + end + end + end + + -- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa + dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( DISPMODE > 0, dDistMinX, dDistMaxX) + -- calcolo positione top porta rispetto allo zero macchina + local nTabRef = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'R1') + local pPiecePos = EgtSP( nTabRef, GDB_ID.ROOT) + Ori + vExtraYDelta + -- se il top porta è opposto al lato dei riferimenti + if (DISPMODE > 0 and bTopOnRight) or ( DISPMODE < 0 and not bTopOnRight) then + pPiecePos = pPiecePos + Vector3d( (b3Solid:getDimY() + OffsXSovr - DIST_MIN_VAC)*DISPMODE,0,0) + else -- se top porta è adiacente al lato dei riferimenti + pPiecePos = pPiecePos + Vector3d( (OffsXSovr + DIST_MIN_VAC)*DISPMODE,0,0) + end + + -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto + StartVacVerify( Ls, bFlip, nProbeMode, tsDoubleData.dThickDoor, bFlipFrame) + + -- ciclo sulle ventose + local nInd = 1 + local bFoundSpecialVac + -- tabelle per gestione conteggi inserimento ventose, gli indici tabella sono le barre (1 fissa, 2 intermedia, 3 mobile) + local tnCountFailed = {} -- tabella conteggio ventose non disposte + tnCountFailed[1] = 0 + tnCountFailed[2] = 0 + tnCountFailed[3] = 0 + local tnIniFailed = {} -- tabella conteggio ventose iniziali non disposte + tnIniFailed[1] = 0 + tnIniFailed[2] = 0 + tnIniFailed[3] = 0 + local tnMiddleFailed = {} -- tabella conteggio ventose intermedie non disposte + tnMiddleFailed[1] = 0 + tnMiddleFailed[2] = 0 + tnMiddleFailed[3] = 0 + local tnEndFailed = {} -- tabella conteggio ventose finali non disposte + tnEndFailed[1] = 0 + tnEndFailed[2] = 0 + tnEndFailed[3] = 0 + local tnMaxIniFailed = {} -- tabella contatore totale ventose iniziali non disposte + tnMaxIniFailed[1] = 0 + tnMaxIniFailed[2] = 0 + tnMaxIniFailed[3] = 0 + local tnMaxMiddleFailed = {}-- tabella contatore totale ventose intermedie non disposte + tnMaxMiddleFailed[1] = 0 + tnMaxMiddleFailed[2] = 0 + tnMaxMiddleFailed[3] = 0 + local tnMaxEndFailed = {} -- tabella contatore totale ventose finali non disposte + tnMaxEndFailed[1] = 0 + tnMaxEndFailed[2] = 0 + tnMaxEndFailed[3] = 0 + + -- tabella gestione ventose, gli indici tabella rappresentano le barre (1 fissa, 2 intermedia, 3 mobile) + local tsBaseDataVac1 = {} -- tabella nomi punti ventosa base + tsBaseDataVac1[1] = { tMainTabPar.P1T, tMainTabPar.V1T1, tMainTabPar.V1T1E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac1[2] = { tMainTabPar.P1T, tMainTabPar.V2T1, tMainTabPar.V2T1E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac1[3] = { tMainTabPar.P1T, tMainTabPar.V3T1, tMainTabPar.V3T1E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + + local tsBaseDataVac2 = {} -- tabella nomi punti ventosa secondo tipo + tsBaseDataVac2[1] = { tMainTabPar.P2T, tMainTabPar.V1T2, tMainTabPar.V1T2E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac2[2] = { tMainTabPar.P2T, tMainTabPar.V2T2, tMainTabPar.V2T2E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac2[3] = { tMainTabPar.P2T, tMainTabPar.V3T2, tMainTabPar.V3T2E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + + local tsBaseDataVac3 = {} -- tabella nomi punti ventosa terzo tipo + tsBaseDataVac3[1] = { tMainTabPar.P3T, tMainTabPar.V1T3, tMainTabPar.V1T3E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac3[2] = { tMainTabPar.P3T, tMainTabPar.V2T3, tMainTabPar.V2T3E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + tsBaseDataVac3[3] = { tMainTabPar.P3T, tMainTabPar.V3T3, tMainTabPar.V3T3E, tMainTabPar.DTG, tMainTabPar.DBG, tMainTabPar.DSG, tMainTabPar.DTGN, tMainTabPar.DBGN, tMainTabPar.DSGN} + + -- tabella gestione morse, gli indici tabella rappresentano le barre (1 fissa, 2 intermedia, 3 mobile) + local tsBaseDataVise1 = {} -- tabella nomi punti ventosa base + tsBaseDataVise1[1] = { tMainTabPar.P1T, tMainTabPar.VSF1, tMainTabPar.DTGV, tMainTabPar.DBGV, tMainTabPar.DSGV} + local tIdViseDisp = {} + + --------------------------------------------------------------------------------------------- + -- tabella delle tabelle dei tipi di ventose gestite, per ora si gestiscono 3 tipi + -- aggiungere nella tabella gli eventuali tipi da aggiungere + local ttBaseDataVac = {} -- tabella globale dei tipi di ventose di tutte le barre + ttBaseDataVac = { tsBaseDataVac1, tsBaseDataVac2, tsBaseDataVac3} + --------------------------------------------------------------------------------------------- + -- tabella delle tabelle dei tipi di morse gestite, per ora si gestiscono 1 tipo + -- aggiungere nella tabella gli eventuali tipi da aggiungere + local ttBaseDataVise = {} -- tabella globale dei tipi di ventose di tutte le barre + ttBaseDataVise = { tsBaseDataVise1} + --------------------------------------------------------------------------------------------- + -- tabella dei riferimenti, nel CurrCamInfo i dati sono ridondanti rispetto all'originale nel file mlde + local tBaseDataRef = {} + tBaseDataRef = { tMainTabPar.REF1, tMainTabPar.REF2, tMainTabPar.REF3, tMainTabPar.REF4} + --------------------------------------------------------------------------------------------- + + local tsBaseNameVac = {} -- tabella nomi ventose tipo unificato normale + tsBaseNameVac[1] = {'','',0} + tsBaseNameVac[2] = {'','',0} + tsBaseNameVac[3] = {'','',0} + --------------------------------------- + local tsNoteRow = {} -- tabella per note da assegnare alle geometrie delle barre + tsNoteRow[1] = '' + tsNoteRow[2] = '' + tsNoteRow[3] = '' + + -- questa tabella deve essere settata in base ai sottopezzi presenti nella cartella della macchina + -- e al disegno della macchina( deve avere nome dei punti, ecc.) + local tnNumVacInsert = {} -- tabella per numero di tipi di ventosa presenti sulle barre + tnNumVacInsert[1] = tMainTabPar.NTVB1 or 1 + tnNumVacInsert[2] = tMainTabPar.NTVB2 or 1 + tnNumVacInsert[3] = tMainTabPar.NTVB3 or 1 + -- se ho un solo tipo di ventose sulla barra carico in questa tabella + local tnTypeSingleVacOnBar = {} + tnTypeSingleVacOnBar[1] = tMainTabPar.TSVB1 + tnTypeSingleVacOnBar[2] = tMainTabPar.TSVB2 + tnTypeSingleVacOnBar[3] = tMainTabPar.TSVB3 + -- tabella che indica il tipo di ventosa corrente + local tnNumKindVac = {} + tnNumKindVac[1] = 1 -- solo valore di inizializzazione + tnNumKindVac[2] = 1 -- solo valore di inizializzazione + tnNumKindVac[3] = 1 -- solo valore di inizializzazione + --------------------------------------- + -- tabella posizionamento ventose + local tPosRowSubPieceRow1 = {} + local tPosRowSubPieceRow2 = {} + local tPosRowSubPieceRow3 = {} + local tdYCommpos = {} -- tabella valori Y con sottopezzi identici + --------------------------------------- + -- settaggio ventosa arco su porta ad arco: + -- annullo nome ventosa se porta ad arco con centro arco non oltre i 2" + -- annullo nome ventosa se c'é proprietà porta + if not tsDoubleData.dTopxDeltapos or ( tsDoubleData.dTopxDeltapos and abs(tsDoubleData.dTopxDeltapos) > 50.8) then + tMainTabPar.AVNM = '' + end + + -- se porta narrowstile forzo ad utilizzare solo le ventose strette sulle barre esterne + if bNarrowStile then + tMainTabPar.FVR = true + end + + while dCalcLen > 0 and nInd <= tMainTabPar.NTVR do + + local nIndVac = EgtIf( DISPMODE > 0, nInd, ( tMainTabPar.NTVR - nInd + 1)) + local sInd = EgtNumToString( nIndVac, 0) + + if nCodeVacDisp <= 1 then + + tPosRowSubPieceRow1[nIndVac] = CalcDispositionSubPieces( 1, nFixId, tMainTabPar.FVR, tsBaseNameVac, EgtIf( bUseVise, ttBaseDataVise, ttBaseDataVac), + sInd, tnNumVacInsert, tnNumKindVac, tdYCommpos, nInd, + tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, + tnMaxEndFailed, tnEndFailed, tMainTabPar.NTVR, ( dCalcLen - dInterAx), bNarrowStile, + tabOri, tnTypeSingleVacOnBar, bFrameOnNarrow, bUseVise, tsDoubleData.dWidthDoor) + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 2 then + + local nIdVac = 2 + if bUseOnly2Bars then + nIdVac = 3 + end + + tPosRowSubPieceRow2[nIndVac] = CalcDispositionSubPieces( nIdVac, nMobId1, tMainTabPar.FVR, tsBaseNameVac, ttBaseDataVac, + sInd, tnNumVacInsert, tnNumKindVac, tdYCommpos, nInd, + tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, + tnMaxEndFailed, tnEndFailed, tMainTabPar.NTVR, ( dCalcLen - dInterAx), bNarrowStile, + tabOri, tnTypeSingleVacOnBar, bFrameOnNarrow) + end + + if ( nCodeVacDisp == 0 or nCodeVacDisp == 3) and not bUseOnly2Bars then + + tPosRowSubPieceRow3[nIndVac] = CalcDispositionSubPieces( 3, nMobId2, tMainTabPar.FVR, tsBaseNameVac, ttBaseDataVac, + sInd, tnNumVacInsert, tnNumKindVac, tdYCommpos, nInd, + tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, + tnMaxEndFailed, tnEndFailed, tMainTabPar.NTVR, ( dCalcLen - dInterAx), bNarrowStile, + tabOri, tnTypeSingleVacOnBar, bFrameOnNarrow) + end + + -- aggiorno la lunghezza di calcolo e l'indice + dCalcLen = dCalcLen - dInterAx + nInd = nInd + 1 + end -- end while + + -- verifico la tabella di disposizione della barra centrale e le opportune verifiche per inserire la ventosa ad arco: + -- se non si utilizzano solo due barre e ho la ventosa ad arco + if not bUseOnly2Bars and tMainTabPar.AVNM and #tMainTabPar.AVNM > 0 then + tPosRowSubPieceRow2, bFoundSpecialVac = InsertSpecialSubPiece( tPosRowSubPieceRow2, tMainTabPar.NTVR, bTopOnRight, tMainTabPar.AVNM, tabOri, + tMainTabPar.ADTG, tMainTabPar.ADBG, tMainTabPar.ADSG, pPiecePos, 2, + tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, DISPMODE) + end + + -- elimino geometrie per verifica + EndVacVerify() + + for l = 1, tMainTabPar.NTVR do + + local nIndVac = EgtIf( DISPMODE > 0, l, ( tMainTabPar.NTVR - l + 1)) + + if nCodeVacDisp <= 1 then -- porta o frame su prima linea vicino a riferimenti + local nIdVise = DispositionSubPieces( 1, nIndVac, tPosRowSubPieceRow1, tMainTabPar.FVR, tsBaseNameVac, + tdYCommpos, EgtIf( bUseVise, ttBaseDataVise, ttBaseDataVac), nIndVac, tabOri, tsNoteRow, + nDispId, nil, nil, nil, nil, + bUseVise, tsDoubleData.dWidthDoor) + if bUseVise and nIdVise then + table.insert( tIdViseDisp, { nIdVise, nIndVac}) + end + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 2 then -- porta o frame su linea intermedia + local nIdVac = 2 + if bUseOnly2Bars then + nIdVac = 3 + end + DispositionSubPieces( nIdVac, nIndVac, tPosRowSubPieceRow2, tMainTabPar.FVR, tsBaseNameVac, + tdYCommpos, ttBaseDataVac, ( nIndVac + 1), tabOri, tsNoteRow, + nDispId, tMainTabPar.AVNM, pPiecePos, Pz, bFoundSpecialVac) + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 3 then -- porta o frame su ultima linea lontana dai riferimenti + local nIdVac = 3 + if bUseOnly2Bars then + nIdVac = 2 + end + + DispositionSubPieces( nIdVac, nIndVac, tPosRowSubPieceRow3, tMainTabPar.FVR, tsBaseNameVac, + tdYCommpos, ttBaseDataVac, nIndVac, tabOri, tsNoteRow, + nDispId) + end + end + + -- dispongo i riferimenti (utilizzati nella disposizione comportano di far correttamente risalire in Z un aggregato + -- se questo viene trovato in collisione mentre sta eseguendo un movimento in rapido da una lavorazione ad un altra) + if DISPMODE < 0 and tMainTabPar.CUC == 1 then + local nMaxDist = max( tBaseDataRef[1][4], tBaseDataRef[2][4], tBaseDataRef[3][4], tBaseDataRef[4][4]) + EgtSetTableAreaOffset( nMaxDist, nMaxDist, nMaxDist, nMaxDist) -- area maggiorata + DispositionReferences( tBaseDataRef[1][1], tBaseDataRef[1][2], tBaseDataRef[1][3]) -- riferimento in testa dx + DispositionReferences( tBaseDataRef[2][1], tBaseDataRef[2][2], tBaseDataRef[2][3]) -- riferimento in basso dx + DispositionReferences( tBaseDataRef[3][1], tBaseDataRef[3][2], tBaseDataRef[3][3]) -- riferimento in basso sx + elseif tMainTabPar.CUC == 1 then + local nMaxDist = max( tBaseDataRef[1][4], tBaseDataRef[2][4], tBaseDataRef[3][4], tBaseDataRef[4][4]) + EgtSetTableAreaOffset( nMaxDist, nMaxDist, nMaxDist, nMaxDist) -- area maggiorata + DispositionReferences( tBaseDataRef[2][1], tBaseDataRef[2][2], tBaseDataRef[2][3]) -- riferimento in basso dx + DispositionReferences( tBaseDataRef[3][1], tBaseDataRef[3][2], tBaseDataRef[3][3]) -- riferimento in basso sx + DispositionReferences( tBaseDataRef[4][1], tBaseDataRef[4][2], tBaseDataRef[4][3]) -- riferimento in testa a sx + end + + --nTime = EgtStopCounter() + --if not DGD or not DGD.NCGEN then + -- EgtOutBox( string.format( 'tempo calcolato sec: %s', (nTime/1000)), 'Timey', 'Timey') + --end + + -- inizializzo il contatore + --EgtStartCounter() + + -- scrivo nota linea di ventose + if #tsNoteRow[1] > 0 then + EgtSetInfo( Pz, 'FixVacRow_Phase_'..EgtNumToString( nNumPhase, 0), tsNoteRow[1]) + end + + if bUseOnly2Bars then + if #tsNoteRow[2] > 0 then + EgtSetInfo( Pz, 'Mob2VacRow_Phase_'..EgtNumToString( nNumPhase, 0), tsNoteRow[2]) + end + if #tsNoteRow[3] > 0 then + EgtSetInfo( Pz, 'Mob1VacRow_Phase_'..EgtNumToString( nNumPhase, 0), tsNoteRow[3]) + end + else + if #tsNoteRow[2] > 0 then + EgtSetInfo( Pz, 'Mob1VacRow_Phase_'..EgtNumToString( nNumPhase, 0), tsNoteRow[2]) + end + if #tsNoteRow[3] > 0 then + EgtSetInfo( Pz, 'Mob2VacRow_Phase_'..EgtNumToString( nNumPhase, 0), tsNoteRow[3]) + end + end + + -- scrivo note con i valori di partenza della prima ventosa in basso a destra + EgtSetInfo( Pz, 'FixValX', tMainTabPar.DVR) + EgtSetInfo( Pz, 'FixValY', dFixval) + EgtSetInfo( Pz, 'UseOnly2Bars', bUseOnly2Bars) + -- scrivo la nota relativa all'attivazione o meno del controllo collisioni + EgtSetInfo( Pz, 'EnableCollisionDetect', tMainTabPar.ECD) + + -- verifico se numero di ventose sufficienti e do errore nel caso contrario + bOk, DGD.EMC = CheckEnoughVacuums( ( nInd - 1), nCodeVacDisp, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, + bUseOnly2Bars, tsDoubleData.dTopRadius, bTopOnRight, bUseVise, + tIdViseDisp) + if DGD.EMC and #DGD.EMC > 0 then -- se ho messaggio di errore lo mando una riga sotto per stamparlo correttamente + DGD.EMC = '\n' .. DGD.EMC + end + if not bOk then break end + + ---------------------- + ---------------------- + -- *** Lavorazioni *** + ---------------------- + ---------------------- + + local bMakeGhost = EgtIf( bFirstStep, true, false) + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + if v == 1 then -- solo il primo pezzo + -- print Machining table + for i = nIndexStartMach, #tLocMach do + DoorOutLog( 'L'..EgtNumToString( i, 0) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + end + end + + -- solo il primo giro aggiusto i profili bevel per essere coerente con la sequenza di tabella. + -- si è inserito il controllo che non sia anche una porta shiftata per non lavorarla in prima fase + -- e poi ri-disporla in una eventuale seconda fase + -- inserisco una modifica al controllo shift ma solo se non dipende dalle property +-- if bFirstStep and ( not bShiftMchng or bSmallShiftedDoor) and nProbeMode ~= 1 then + if bFirstStep and ( ( not bShiftMchng ) or ( bShiftMchng and bNarrowStile) or bSmallShiftedDoor) and nProbeMode ~= 1 then + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf) + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + if v == 1 then -- solo il primo pezzo + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + end + + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + end +-- local bEnBreak = false + bEnBreak = false + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = nIndexStartMach, #tLocMach do + + -- se devo uscire dal ciclo + if bEnBreak then break end + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local sHide = EgtIf( bFirstStep, '', DGD.GHT) + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide) +-- -- solo per il ProbeSidePoint non cerco il percorso _HIDE in seconda fase +-- if tLocMach[i].Name == 'ProbeSidePoint' then +-- EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) +-- else +-- EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide) +-- end + -- Applico le lavorazioni + for j = 1, #EntList do + + local nNewIdEnt + local nLocMach + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' and nProbeMode ~= 1 then + + bLocMach, _, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf, bMakeGhost) + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 12) + end + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 11) + end + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 13) + end + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #tsMachProf[v] > 0 then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if tsBoolData.bAtRight then + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not tsBoolData.bAtRight then + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( tsDoubleData.dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if tsBoolData.bAtRight then + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not tsBoolData.bAtRight then + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( tsDoubleData.dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BU' or + tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( tsDoubleData.dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BU' or + tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + MB.MakeRoughPaths( tsDoubleData.dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + else + bOk = false + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' and nProbeMode ~= 1 then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' and nProbeMode ~= 1 then + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true) + elseif tLocMach[i].Oper == 'AdjResizeCurve' and nProbeMode ~= 1 then + + if bSteelDoor or bAlumDoor then + bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveNew( EntList[j], bMakeGhost, true, bNoVertProf) + else + bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveNew( EntList[j], bMakeGhost, false, bNoVertProf) + end + + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo non dovrebbe assegnare il valore 3 + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + nNumMachSkipResult = nNumMachSkip + 1 + end + + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #tsMachProf[v] > 0 then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se non è contro il riferimento e se devo compensare l'offset del bevel + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + -- se lato sinistro è contro i riferimenti disabilito la lavorazione + if ( tsBoolData.bAtRight and bHingeOnRef) or ( not tsBoolData.bAtRight and not bHingeOnRef) then + EgtSetInfo( nNewIdEnt, 'Mach', 42) + else + if tsBoolData.bAtRight and ( tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BDEB') then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif not tsBoolData.bAtRight and ( tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BDEB') then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + EgtSetInfo( nNewIdEnt, 'OL', dOffsLoc) + end + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + -- se lato destro è contro i riferimenti disabilito la lavorazione + if ( tsBoolData.bAtRight and not bHingeOnRef) or ( not tsBoolData.bAtRight and bHingeOnRef) then + EgtSetInfo( nNewIdEnt, 'Mach', 42) + else + if tsBoolData.bAtRight and ( tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BDEB') then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif not tsBoolData.bAtRight and ( tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BDEB') then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + EgtSetInfo( nNewIdEnt, 'OL', dOffsLoc) + end + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + -- se lato top è contro i riferimenti disabilito la lavorazione + if bTopOnRef then + EgtSetInfo( nNewIdEnt, 'Mach', 42) + else + if tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BU' or + tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + EgtSetInfo( nNewIdEnt, 'OL', dOffsLoc) + end + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + -- se lato bottom è contro i riferimenti disabilito la lavorazione + if not bTopOnRef then + EgtSetInfo( nNewIdEnt, 'Mach', 42) + else + if tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BU' or + tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + EgtSetInfo( nNewIdEnt, 'OL', dOffsLoc) + end + end + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouCurve' or tLocMach[i].Oper == 'AdjPrfThrouCurve' and nProbeMode ~= 1 then + + if tLocMach[i].Oper == 'AdjustThrouCurve' then + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) + else -- altrimenti + if bSkinned or bSteelDoor or bAlumDoor then + bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveNew( EntList[j], bMakeGhost, true, bNoVertProf) + else + bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveNew( EntList[j], bMakeGhost, false, bNoVertProf) + end + end + + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo non dovrebbe assegnare il valore 3 + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + nNumMachSkipResult = nNumMachSkip + 1 + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #tsMachProf[v] > 0 then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if tsBoolData.bAtRight then + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not tsBoolData.bAtRight then + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( tsDoubleData.dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if tsBoolData.bAtRight then + if tsStringData.sLockTrim == 'BD' or tsStringData.sLockTrim == 'BU' or + tsStringData.sLockTrim == 'BDEB' or tsStringData.sLockTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sLockTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not tsBoolData.bAtRight then + if tsStringData.sHingeTrim == 'BD' or tsStringData.sHingeTrim == 'BU' or + tsStringData.sHingeTrim == 'BDEB' or tsStringData.sHingeTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( tsDoubleData.dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if tsStringData.sTopTrim == 'BD' or tsStringData.sTopTrim == 'BU' or + tsStringData.sTopTrim == 'BDEB' or tsStringData.sTopTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + elseif tsStringData.sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = tsDoubleData.dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( tsDoubleData.dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if tsStringData.sBottomTrim == 'BD' or tsStringData.sBottomTrim == 'BU' or + tsStringData.sBottomTrim == 'BDEB' or tsStringData.sBottomTrim == 'BUEB' then + dOffsLoc = tsDoubleData.dThickDoor * TAN3 + end + MB.MakeRoughPaths( tsDoubleData.dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' and nProbeMode ~= 1 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + if bOk then + + local bInsLav = true + local bMachBox + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt, bUseVise) + elseif nMach == 2 then + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + elseif nMach == 3 then -- il metodo AdjustThrouIsle non dovrebbe restituire il 3 + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt, bUseVise) + end + + -- se la lavorazione è applicabile ma è da sotto, verifico l'ingombro della lavorazione + if bInsLav and nMach == 2 and bMachBox and not bMachBox:isEmpty() and tMainTabPar.CUC == 1 then + bInsLav = VerifyRowCollision( tRefArea, bMachBox) + end + -- se utilizza lavorazione da sotto con le morse disabilito la lavorazione + if nMach == 2 and bUseVise then + bInsLav = false + end + -- verifico le collisioni con le morse + if bInsLav and bUseVise and bMachBox and not bMachBox:isEmpty() then + tsNoteRow[1] = VerifyViseCollision( tIdViseDisp, bMachBox, Pz, nNumPhase, DISPMODE, tMainTabPar.NTVR, tsNoteRow[1], 2) + end + -- se la lavorazione non è applicabile + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else + EgtSetInfo( nNewIdEnt, 'Mach', 31) + end + end + elseif tLocMach[i].Oper == 'AdjustProbeMill' and nProbeMode == 0 and nPostProbeSet > 2 then + local sMachRetured + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeMill( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, + bFirstStep, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, tMainTabPar.PTK, + tMainTabPar.EZPB) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + if bOk then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + elseif nMach == 3 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].Mach}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + end + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 13) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + end + + -- se lavorazione presente incremento il numero di lavorazioni da sotto + if sMachRetured then + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andata a buon punto setto nota alla porta + EgtSetInfo( Pz, 'ExistsProbeXY', true) -- presenza del probe in XY + end + else + EgtSetInfo( nNewIdEnt, 'Mach', 31) + end + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillX' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true, nProbeMode) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillY' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true, nProbeMode) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' and nProbeMode ~= 1 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, + bForceHorizontalDir) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + if bOk then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + + -- se lavorazione presente incremento il numero di lavorazioni da sotto + if sMachRetured then + nNumGeomBottom = nNumGeomBottom + 1 + end + end + else + EgtSetInfo( nNewIdEnt, 'Mach', 31) + end + end + elseif tLocMach[i].Oper == 'AdjustVertHole' and nProbeMode ~= 1 then + local nTypeGeom + bLocMach, nNumMachSkipResult, nNewIdEnt, nTypeGeom = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + local bInsLavSec = true + local bMachBox + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt, bUseVise) + -- se lavorazione non è applicabile ma di tipo passante e con la possibilità di lavorazione da sotto + -- provo subito la seconda opzione + if not bInsLav and ( nTypeGeom == 1 or nTypeGeom == 2) and bWorkUnder then + bInsLavSec, _, bMachBox = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + if bInsLavSec and bMachBox and not bMachBox:isEmpty() and tMainTabPar.CUC == 1 then + bInsLavSec = VerifyRowCollision( tRefArea, bMachBox) + end + if bInsLavSec then + nMach = 2 + nLocMach = nMach + EgtSetInfo( nNewIdEnt, 'Mach', 2) + end + end + elseif nMach == 2 then + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + elseif nMach == 3 then -- il metodo AdjustVertHole non dovrebbe restituire il 3 + bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt, bUseVise) + end + + -- se la lavorazione è applicabile ma è da sotto, verifico l'ingombro della lavorazione + if bInsLav and nMach == 2 and bMachBox and not bMachBox:isEmpty() and tMainTabPar.CUC == 1 then + bInsLav = VerifyRowCollision( tRefArea, bMachBox) + end + -- se utilizza lavorazione da sotto con le morse disabilito la lavorazione + if nMach == 2 and bUseVise then + bInsLav = false + end + -- verifico le collisioni con le morse + if bInsLav and bUseVise and bMachBox and not bMachBox:isEmpty() then + tsNoteRow[1] = VerifyViseCollision( tIdViseDisp, bMachBox, Pz, nNumPhase, DISPMODE, tMainTabPar.NTVR, tsNoteRow[1], 2) + end + -- se la lavorazione non è applicabile da entrambe i lati + if not bInsLav and not bInsLavSec then + -- setto la nota per non lavorare la geometria da nessuna parte + EgtSetInfo( nNewIdEnt, 'Mach', 21) + EgtSetInfo( nNewIdEnt, 'Mach2nd', 1) + nLocMach = 21 + -- se la lavorazione non è applicabile da un lato + elseif not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustHole' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost, bForceHorizontalDir) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjPreHoleAndPocket( EntList[j], bMakeGhost, nil, nil, (bExtruded or bSkinned)) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustProbeHole' and nProbeMode == 1 then + local sMachRetured + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, false, bMakeGhost) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo AdjustProbeHole non dovrebbe restituire il 3 + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile setto la nota sul pezzo + if bInsLav then + EgtSetInfo( Pz, 'ExistsProbeZ', true) -- presenza del probe in Z + else -- altrimenti la lavorazione non è applicabile + + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + + -- se lavorazione presente incremento il numero di lavorazioni da sotto + if sMachRetured then + nNumGeomBottom = nNumGeomBottom + 1 + end + end + end + elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' and nProbeMode ~= 1 then + bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustSplitDoor' and nProbeMode ~= 1 then + if not bGetSplitCuts then + tSplitDoorEnt = EntList + table.insert( tSplitDataInf, { tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, nNumMach, bMakeGhost}) + bGetSplitCuts = true + end + elseif tLocMach[i].Oper == 'AdjustConeCleanPaths' and nProbeMode ~= 1 then + bOk, nNewIdEnt = MB.AdjustConeCleanPaths( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustVertAsOnHeads' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustVertAsOnHeads( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + end + else -- se nessuna operazione + if nProbeMode ~= 1 then + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + if bUseVise then + local bInsLav, _, bMachBox = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt, bUseVise) + -- verifico le collisioni con le morse + if bInsLav and bMachBox and not bMachBox:isEmpty() then + tsNoteRow[1] = VerifyViseCollision( tIdViseDisp, bMachBox, Pz, nNumPhase, DISPMODE, tMainTabPar.NTVR, tsNoteRow[1], 2) + end + -- se la lavorazione non è applicabile +-- if not bInsLav then +-- if bFirstStep then +-- -- inserisco in tabella solo se non già presente +-- tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) +-- end +-- -- aumento di 1 il numero di lavorazioni skippate +-- nNumMachSkip = nNumMachSkip + 1 +-- -- ricambio la nota come non lavorabile in questa fase +-- if nMach == 1 then +-- EgtSetInfo( nNewIdEnt, 'Mach', 12) +-- elseif nMach == 2 then +-- EgtSetInfo( nNewIdEnt, 'Mach', 11) +-- else +-- EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) +-- end +-- -- incremento il numero di lavorazioni da sotto +-- nNumGeomBottom = nNumGeomBottom + 1 +-- end + end + end + end + + -- LAVORAZIONI + + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + local bScroll = true + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + -- se prima lavorazione, valida, con chiave Shift abilitata, esco dal giro +--[[ + if ( nMach > 0 and nMach < 10) and + not bShiftMchng and + tLocMach[i].Shift == 1 then + + bShiftMchng = true -- flag per traslazione Y + nIndexStartMach = i -- ripartenza da questa posizione + bScroll = false -- salto l'applicazione delle lavorazioni in seguito + bEnBreak = true -- blocco il for della scansione tabella + -- se fase di ripresa rimetto la nota mach disabilitata + if not bFirstStep then + nMach = nMach + 10 + EgtSetInfo( EntList[j], 'Mach', nMach) + nNumMachSkip = nNumMachSkip + 1 + end + end +--]] + + if not bScroll then + break -- esco dal ciclo for j + else + if nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + local bCalMach = true + -- se non primo passo e nota JoinMach differisce dal mach e dalla lavorazione + if not bFirstStep then + + local sJoinMach = EgtGetInfo( nNewIdEnt, 'JoinMach') + + if sJoinMach and #sJoinMach > 1 then + local tJoinMach = EgtSplitString( sJoinMach) + + if tJoinMach and #tJoinMach == 2 then + local nNumMachRef = tonumber( tJoinMach[1]) + local sMachRefJoin = tJoinMach[2] + if nNumMachRef ~= nMach then + bCalMach = false + elseif nNumMachRef == 1 and sMachRefJoin and tLocMach[i].Mach and tLocMach[i].Mach ~= sMachRefJoin then + bCalMach = false + elseif nNumMachRef == 2 and sMachRefJoin and tLocMach[i].MachUp and tLocMach[i].MachUp ~= sMachRefJoin then + bCalMach = false + elseif nNumMachRef == 3 and sMachRefJoin and tLocMach[i].MachDw and tLocMach[i].MachDw ~= sMachRefJoin then + bCalMach = false + end + end + end + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, + NOT_GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF, bCalMach) + elseif nNewIdEnt then + local sLocMachName + if not nLocMach or nLocMach == 1 then + sLocMachName = tLocMach[i].Mach + elseif nLocMach == 2 then + sLocMachName = tLocMach[i].MachUp + elseif nLocMach == 3 then + sLocMachName = tLocMach[i].MachDw + elseif nLocMach == 21 then -- caso particolare quando falliscono sia la lavorazione top che bottom + if tLocMach[i].Mach then -- se non è nil + sLocMachName = tLocMach[i].Mach + else + sLocMachName = 'no machining' + end + if tLocMach[i].MachUp then -- se non è nil + sLocMachName = sLocMachName .. ' + ' .. tLocMach[i].MachUp + else + sLocMachName = sLocMachName .. ' + ' .. 'no machining' + end + end + DoorOutLog( EgtDoorsMsg[497]..EgtNumToString( nNewIdEnt, 0)..' '.. EgtDoorsMsg[638] ..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( sLocMachName, sLocMachName, '') .. + EgtDoorsMsg[596]..EgtNumToString( nNumPhase, 0), 0) + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end + + -- se utilizzo morse faccio l'ultimo controllo ed eventuale scrematura del numero delle morse + if bUseVise and #tIdViseDisp > 3 then + ReduceViseNumber( tIdViseDisp, 3, Pz, nNumPhase, DISPMODE, tMainTabPar.NTVR, tsNoteRow[1], 2) + elseif bUseVise and #tIdViseDisp < 3 then + local sMess = ' ' .. EgtDoorsMsg[683] + if DGD.EMC and #DGD.EMC > 0 then -- se ho messaggio di errore lo mando una riga sotto per stamparlo correttamente + DGD.EMC = '\n' .. sMess + else + DGD.EMC = sMess + end + bOk = false + break + end + end -- end for per ogni pezzo + + local i = 1 + while i <= #tLocMachOrd and not bEnBreak do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGrp = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) + + if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e gruppo non 0 + + if sProperty == 'MinDist' or sProperty == 'MinDistByPiece' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local nPz + local nTotPz + + if sProperty == 'MinDistByPiece' then + nTotPz = #tPz + else + nTotPz = 1 + end + + for v = 1, nTotPz do + + local nPz + + if sProperty == 'MinDistByPiece' then + nPz = tPz[v] + else + nPz = tPz + end + + local tMachining = {} + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( nPz, tGroup[k].Name..DGD.GHT) + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se è fuori range o non corrispondono le lavorazioni + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, tMachining, tMainTabPar.BPLI, tMainTabPar.PRF) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata + -- tolgo di mezzo le note secondarie + -- for j = 1, #EntList do + -- EgtRemoveInfo( EntList[j], 'Mach2nd') + -- end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + end -- end for + elseif sProperty == 'Layer' then -- lavorazione layer + + for v = 1, #tPz do + + local nPz = tPz[v] + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, nPz, DGD.GHT) + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, + nNumMach, bOk, DGD.GHT, tMainTabPar.MDC, EndLastMach, + tMainTabPar.BPLI, tMainTabPar.PRF) + end + end -- end for + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tGroup[k].Name..DGD.GHT) + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata + -- tolgo di mezzo le note secondarie +-- for j = 1, #EntList do +-- EgtRemoveInfo( EntList[j], 'Mach2nd') +-- end + end + end + elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore + DGD.ERR = -15 + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + if DGD.ERM and #DGD.ERM > 0 then + DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + end + + i = i + 1 + end + + -- se ci sono state lavorazioni accodo la disposizione delle fase + if nNumMach > 0 then + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + else -- altrimenti nessuna lavorazione + + if not bFirstStep then -- se non è il primo giro elimino la fase vuota + + -- se ho più di una fase elimino l'ultima fase + if nNumPhase > 1 then + EgtRemoveLastPhase() + end + + -- setto corrente fase precedente + if nPrevPhase then + EgtSetCurrPhase(nPrevPhase) + nNumPhase = nPrevPhase + end + end + end + + -- se sono al primissimo giro + if not bGenFirstStep then + + -- la lavorazione di traslazione ha priorità sul ribaltamento + -- se trovata traslazione setto il flag per il prossimo giro + if bShiftMchng then + bGenFirstStep = true + if not bFirstStep then -- se sono già in ripresa porta resetto il contatore di lavorazioni saltate + nNumMachSkip = 0 -- resetto per il prossimo giro + end + else + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + -- se già con pezzo non in prima fase ( non shiftato) o pezzo frame, esco + if not bFirstStep or bFrame then + bWork = false + else + bFirstStep = false + end + nNumMachSkip = 0 -- resetto per il prossimo giro + end + end + else -- altrimenti ho già fatto un giro e ho trovato la traslazione + -- se nessuna geometria skippata esco + if nNumMachSkip == 0 then bWork = false end + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + if bFirstStep then -- se ho terminato il giro con eventuale traslazione disabilito la traslazione + -- disativo la traslazione sul giro successvo + bShiftMchng = false + -- disattivo il flag che indica di disporre la porta subito traslata + bSmallShiftedDoor = false + end + bFirstStep = false + end + end + + -- controllo di sicurezza + if nNumCycle > 4 then bWork = false end + + nNumCycle = nNumCycle + 1 + + -- se deve uscire dal ciclo, prima di farlo, eseguo l'eventuale split della porta + if not bWork then + + -- gestione taglio longitudinale split door + -- per ogni pezzo passato + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + -- assegnamento variabili + bFrame = sAssemb and string.find( sAssemb, 'frame') == 1 + + -- se è una porta + if not bFrame then + + local EntList = tSplitDoorEnt + + if #EntList == 1 then + -- acquisisco nota direzione taglio e la confronto con il parametro del currcaminfo + local sDirCut = EgtGetInfo( EntList[1], 'DirectionCut', 's') + if sDirCut and + ( ( sDirCut == 'H' and string.find( tMainTabPar.CDA, 'H')) or + ( sDirCut == 'W' and string.find( tMainTabPar.CDA, 'W'))) then + + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[1], tSplitDataInf[1][7]) + + if bLocMach then + + local bInsLav = false + + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + nLocMach = nMach + if nMach == 1 then + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tSplitDataInf[1][1], tSplitDataInf[1][2], tSplitDataInf[1][3], + tSplitDataInf[1][4], tSplitDataInf[1][5], bOk, tSplitDataInf[1][6], false, + NGEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + end + else + bOk = false + end + end + -- se ho più di un taglio do errore + elseif #EntList > 1 then + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + else + EgtOutBox( EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + else + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[695], 0) + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + end + end + end + end -- end while + + --nTime = EgtStopCounter() + --if not DGD or not DGD.NCGEN then + -- EgtOutBox( string.format( 'tempo calcolato sec: %s', (nTime/1000)), 'Time2', 'Time2') + --end + + -- inizializzo il contatore + --EgtStartCounter() + + -------------------------- + -------------------------- + -- *** Tools Setup *** + -------------------------- + -------------------------- + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + bSetUp = EgtImportSetup() + sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], ' ') .. ' (from Default)' + end + + -- se fallito quello di default o utensili mancanti provo quelli indicati nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + local nContImport = 0 + + -- ciclo tra quelli disponibili + for k = 1, 30 do + + if not bSetUp then + if k == 1 then + sSetup = mCamData[nNumMachFromCam].Setup1 + elseif k == 2 then + sSetup = mCamData[nNumMachFromCam].Setup2 + elseif k == 3 then + sSetup = mCamData[nNumMachFromCam].Setup3 + elseif k == 4 then + sSetup = mCamData[nNumMachFromCam].Setup4 + elseif k == 5 then + sSetup = mCamData[nNumMachFromCam].Setup5 + elseif k == 6 then + sSetup = mCamData[nNumMachFromCam].Setup6 + elseif k == 7 then + sSetup = mCamData[nNumMachFromCam].Setup7 + elseif k == 8 then + sSetup = mCamData[nNumMachFromCam].Setup8 + elseif k == 9 then + sSetup = mCamData[nNumMachFromCam].Setup9 + elseif k == 10 then + sSetup = mCamData[nNumMachFromCam].Setup10 + elseif k == 11 then + sSetup = mCamData[nNumMachFromCam].Setup11 + elseif k == 12 then + sSetup = mCamData[nNumMachFromCam].Setup12 + elseif k == 13 then + sSetup = mCamData[nNumMachFromCam].Setup13 + elseif k == 14 then + sSetup = mCamData[nNumMachFromCam].Setup14 + elseif k == 15 then + sSetup = mCamData[nNumMachFromCam].Setup15 + elseif k == 16 then + sSetup = mCamData[nNumMachFromCam].Setup16 + elseif k == 17 then + sSetup = mCamData[nNumMachFromCam].Setup17 + elseif k == 18 then + sSetup = mCamData[nNumMachFromCam].Setup18 + elseif k == 19 then + sSetup = mCamData[nNumMachFromCam].Setup19 + elseif k == 20 then + sSetup = mCamData[nNumMachFromCam].Setup20 + elseif k == 21 then + sSetup = mCamData[nNumMachFromCam].Setup21 + elseif k == 22 then + sSetup = mCamData[nNumMachFromCam].Setup22 + elseif k == 23 then + sSetup = mCamData[nNumMachFromCam].Setup23 + elseif k == 24 then + sSetup = mCamData[nNumMachFromCam].Setup24 + elseif k == 25 then + sSetup = mCamData[nNumMachFromCam].Setup25 + elseif k == 26 then + sSetup = mCamData[nNumMachFromCam].Setup26 + elseif k == 27 then + sSetup = mCamData[nNumMachFromCam].Setup27 + elseif k == 28 then + sSetup = mCamData[nNumMachFromCam].Setup28 + elseif k == 29 then + sSetup = mCamData[nNumMachFromCam].Setup29 + elseif k == 30 then + sSetup = mCamData[nNumMachFromCam].Setup30 + end + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + if bSetUp then -- se importato il fle da CurrCamInfo + nContImport = nContImport + 1 + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + break + else -- se utensili mancanti prendo la lista e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else -- se non importato carico il messaggio di errore e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + end + end + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + -- se ho importato almeno un attrezzaggio do errore + if ( sDefSetUp and #sDefSetUp > 0) or + nContImport > 0 then + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] + else + DGD.EMC = ' ' .. EgtDoorsMsg[551] + end + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + else -- setup default non definito + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + end + end + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup, 0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation + + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + -- cancello eventuali file immagini + EgtEraseFile( sFileDir..sFileName..sNumGroup..'_TableView'..'.html') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'_TableView'..'.png') + + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) + EgtApplyAllMachinings( false, false) + + local nNumMachErr, sErrMach = EgtGetLastMachMgrError() + local bMachOk = true + + -- Salvo progetto + EgtSaveFile() + + -- controllo collisioni + local bSimOk + + if nNumMachErr == 0 then + + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + DoorOutLog( ' +++ Simulating with collision check >>>', 0) + EgtOutText( 'Start hidden simulation to find collision, It keep some time') + local nErr, sErr + bSimOk, nErr, sErr = EgtSimulate() + if not bSimOk then + if nErr == MCH_SHE.INIT then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[686], sErr) + EgtOutBox( string.format(EgtDoorsMsg[686], sErr), 'Simulation', 'Simulation') + elseif nErr == MCH_SHE.COLLISION then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[687], sErr) + EgtOutBox( string.format(EgtDoorsMsg[687], sErr), 'Collision', 'Collision') + elseif nErr == MCH_SHE.OUTSTROKE then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[688], sErr) + EgtOutBox( string.format(EgtDoorsMsg[688], sErr), 'Outstroke', 'Outstroke') + else + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[689], sErr) + EgtOutBox( string.format(EgtDoorsMsg[689], sErr), 'Simulation', 'Simulation') + end + end + EgtOutText( 'hidden simulation finished') + else + bSimOk = true + end + else + bMachOk = false + DGD.ERR = 36 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[713], sErrMach) + EgtOutBox( string.format(EgtDoorsMsg[713], sErrMach), 'Machining error', 'Machining error') + end + + if bMachOk and bSimOk then + -- Estimation + bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..EgtIf( nProbeMode ~= 1,'.cnc','.prb'), 'EgtCam5 - '..sFilePath) + else + bOk = false + end + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo la disposizione nel log + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- esportazione vista tavola + local bExport + + -- se esportazione vista pezzo in png o esportazione vista tavola tipo html (vista 3d) + if tMainTabPar.ETV >= 1 and tMainTabPar.ETV <= 3 then + + local sIniFilePath + local nPieceToZoom + local dWidthImg, dHeightImg + + -- se esportazione vista tavola tipo png (vista 2d) + if tMainTabPar.ETV == 1 or tMainTabPar.ETV == 3 then + -- ottengo la risoluzione di esportazione + sIniFilePath = EgtGetIniFile() -- percorso del file ini dell'EgtCam5 + dWidthImg = EgtGetStringFromIni( 'Export', 'ImgWidth', '1920', sIniFilePath) + dHeightImg = EgtGetStringFromIni( 'Export', 'ImgHeight', '1080', sIniFilePath) + end + + for v = 1, #tMchId do + -- acquisisco il numero di fase + local nCurrPhase = EgtGetCurrPhase() + -- esco dal machining + EgtResetCurrMachGroup() + -- acquisisco il numero complessivo di tavole e su quale tavola è disposto il pezzo + local nTableUsed = EgtGetInfo( tMchId[v][3], 'TableUsed', 'i') + -- cerco nel GDB_ID.ROOT la macchina e il gruppo di lavoro + local nMachAux = EgtGetNameInGroup( GDB_ID.ROOT, 'MachAux') + if nMachAux and #nMachAux == 1 then + local nIdMachine = EgtGetFirstInGroup( nMachAux[1]) + local sNameInMachAux + while nIdMachine do + sNameInMachAux = EgtGetName(nIdMachine) or '' + -- se trovata macchina + if #sNameInMachAux > 0 and sNameInMachAux == tMchId[v][1] then + break + else + nIdMachine = EgtGetNext( nIdMachine) + end + end + -- se trovato nome macchina + if nIdMachine then + -- rendo visiblie il gruppo + EgtSetStatus( nIdMachine, GDB_ST.ON) + -- lascio abilitata solo la tavole + local nGenGroup = EgtGetNameInGroup( nIdMachine, 'Base') + if nGenGroup and #nGenGroup == 1 then + local nSubGenGroup = EgtGetFirstInGroup( nGenGroup[1]) + while nSubGenGroup do + -- acquisisco il nome del grippo + local sNameSubGenGroup = EgtGetName(nSubGenGroup) + if sNameSubGenGroup then + local sTabName = 'tab' + -- se ho più tavole verifico di abilitare quella utilizzata + if nTableUsed == 1 then + sTabName = 'tab1' + elseif nTableUsed == 2 then + sTabName = 'tab2' + end + -- Se nel nome non è presente la parte tavola la nascondo + if not string.find( string.lower(sNameSubGenGroup), 'tab') then + EgtSetStatus( nSubGenGroup, GDB_ST.OFF) + -- ho una componente tavola + else + -- se ho più tavola + if NUMTABLE > 1 then + -- nascondo la tavola non utilizzata + if not string.find( string.lower(sNameSubGenGroup), sTabName) then + EgtSetStatus( nSubGenGroup, GDB_ST.OFF) + else + -- altrimenti tango traccia della tavola utilizzata per fare lo zoom + nPieceToZoom = nSubGenGroup + end + -- altrimenti una tavola sola + else + -- se ho trovato la tavola + if string.find( string.lower(sNameSubGenGroup), sTabName) then + nPieceToZoom = nSubGenGroup + -- altrimenti se ho trovato la tavola provo con la standard + elseif string.find( string.lower(sNameSubGenGroup), 'tab') then + nPieceToZoom = nSubGenGroup + -- altrimenti nascondo l'oggetto + else + EgtSetStatus( nSubGenGroup, GDB_ST.OFF) + end + end + end + -- se non ha un nome lo nascondo in ogni caso + else + EgtSetStatus( nSubGenGroup, GDB_ST.OFF) + end + nSubGenGroup = EgtGetNext( nSubGenGroup) + end + end + end + end + local nMachBase = EgtGetNameInGroup( GDB_ID.ROOT, 'MachBase') + if nMachBase and #nMachBase == 1 then + local nIdMachGroup = EgtGetFirstInGroup( nMachBase[1]) + local sNameInMachBase + -- ottengo il nome del gruppo + local sMachIdName = EgtGetName(tMchId[v][2]) + while nIdMachGroup do + sNameInMachBase = EgtGetName(nIdMachGroup) or '' + -- se trovato gruppo lavoro + if #sNameInMachBase > 0 and sNameInMachBase == sMachIdName then + break + else + nIdMachGroup = EgtGetNext( nIdMachGroup) + end + end + -- se trovato nome gruppo lavoro + if nIdMachGroup then + -- rendo visiblie il gruppo + EgtSetStatus( nIdMachGroup, GDB_ST.ON) + end + end + local nVMill = EgtGetNameInGroup( GDB_ID.ROOT, 'VMill') + -- nascondo i pezzi + local nPieceId = EgtGetFirstInGroup( GDB_ID.ROOT) + -- se sono presenti i due gruppi + if nMachBase and #nMachBase == 1 and nMachAux and #nMachAux == 1 then + -- ottengo il nome del pezzo + local sPieceNameToDis = EgtGetName(tMchId[v][3]) + while nPieceId do + -- se pezzo esiste ed è diverso dagli altri + if nPieceId ~= nMachBase[1] and nPieceId ~= nMachAux[1] then + -- rendo non visiblie il gruppo + EgtSetStatus( nPieceId, GDB_ST.OFF) + end + nPieceId = EgtGetNext( nPieceId) + end + end + -- se esportazione html + if tMainTabPar.ETV == 2 or tMainTabPar.ETV == 3 then + -- esporto html + local sExport = sFileDir..sFileName..sNumGroup.. '_TableView' ..'.html' + bExport = EgtExportThreeJS( GDB_ID.ROOT, sExport, 393) + end + -- se esportazione vista tavola tipo png (vista 2d) + if tMainTabPar.ETV == 1 or tMainTabPar.ETV == 3 then + if nPieceToZoom then + EgtZoomObject( nPieceToZoom) + else + EgtZoom( SCE_ZM.OUT) + end + local sExport = sFileDir..sFileName..sNumGroup.. '_TableView' ..'.png' + local cColor3d1, cColor3d2 = EgtGetBackground() + if cColor3d1 and cColor3d2 then + bExport = EgtGetImage( SCE_SM.SH, cColor3d1, cColor3d2, dWidthImg, dHeightImg, sExport) + end + end + -- riporto tutto come prima, per prima la macchina nel MachAux + if nMachAux and #nMachAux == 1 then + local nIdMachine = EgtGetFirstInGroup( nMachAux[1]) + -- nascono tutte le macchine + while nIdMachine do + EgtSetStatus( nIdMachine, GDB_ST.OFF) + nIdMachine = EgtGetNext( nIdMachine) + end + end + -- nascono i gruppi nel MachBase + if nMachBase and #nMachBase == 1 then + local nIdMachGroup = EgtGetFirstInGroup( nMachBase[1]) + -- nascono tutti i gruppi di lavoro + while nIdMachGroup do + EgtSetStatus( nIdMachGroup, GDB_ST.OFF) + nIdMachGroup = EgtGetNext( nIdMachGroup) + end + end + -- rendo visibile i pezzi + local nPieceId = EgtGetFirstInGroup( GDB_ID.ROOT) + -- se sono presenti i due/tre gruppi + if nMachBase and #nMachBase == 1 and nMachAux and #nMachAux == 1 then + while nPieceId do + -- se pezzo esiste ed è diverso dagli altri + if nPieceId ~= nMachBase[1] and nPieceId ~= nMachAux[1] then + if nVMill then + if nPieceId ~= nVMill[1] then + -- rendo visiblie il gruppo + EgtSetStatus( nPieceId, GDB_ST.ON) + end + else + -- rendo visiblie il gruppo + EgtSetStatus( nPieceId, GDB_ST.ON) + end + end + nPieceId = EgtGetNext( nPieceId) + end + end + -- rientro nel machining + EgtSetCurrMachGroup( tMchId[v][2]) + EgtSetCurrPhase(nCurrPhase) + end + EgtSaveFile() + end + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + else -- altrimenti errore cn + + -- se le lavorazioni e la simulazione sono corrette ma errore nella generazione + if bMachOk and bSimOk then + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) + end + + -- cancello eventuali file immagini + EgtEraseFile( sFileDir..sFileName..sNumGroup..'_TableView'..'.html') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'_TableView'..'.png') + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- se le lavorazioni sono corrette ma errore nella simulazione o generazione + if bMachOk then + -- se la simulazione è stata corretta ma errore nella generazione + if bSimOk then + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + -- altrimenti errore in simulazione + else + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[690], 0) -- Error on simulation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + EgtOutBox( EgtDoorsMsg[690], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on simulation + end + end + -- altrimenti errore nelle lavorazioni + else + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[714], 0) -- Error on machining generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. EgtNumToString( DGD.ERR, 0), 0) + EgtOutBox( EgtDoorsMsg[714], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining generation + end + end + return false, nNumGroup + end + + --nTime = EgtStopCounter() + --if not DGD or not DGD.NCGEN then + -- EgtOutBox( string.format( 'tempo calcolato sec: %s', (nTime/1000)), 'Time3', 'Time3') + --end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup +end + +return MachiningLoc diff --git a/Machining_4.lua b/Machining_4.lua new file mode 100644 index 0000000..c8db876 --- /dev/null +++ b/Machining_4.lua @@ -0,0 +1,4631 @@ +-- +-- 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 +-- +-- by EgalWare s.r.l. 10/07/2016 +-- Machining generation for Doors program machine Multiax Cxxxx +-- 2017.06.01 V1.011 FM Manage machining optimization +-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece +-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2017.12.07 V1.014 FM Change hinge shuttle assignement with 3 hinges: 60% always on shuttle near door reference, now V1.3 +-- 2017.12.08 V1.015 FM Manage two new probe pointposition , before and after the hinge/pivot to probe always on left of hinge (according to disposition) +-- 2017.12.16 V1.016 FM Change the percentage of shuttle assignement to variable dPercentDoorLength (by Adam L. requests) +-- 2017.12.28 V1.016 FM Set note about hinge side machining +-- 2017.12.28 V1.016 FM Set note about hinge side profile +-- 2017.12.28 V1.016 FM Set note about door shift on Y with hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about door probe error on hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about lock side machining +-- 2018.02.26 V1.0b1 FM Manage door dimension checking +-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces +-- 2018.10.18 V1.0b3 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles +-- 2018.10.23 V1.0b4 FM Manage rough machining +-- 2019.01.14 V1.0b5 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set +-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name) +-- 2019.01.23 V1.0b6 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. +-- 2019.01.24 V1.0b7 FM Extend cases to machine with AdjustHeadChisel operation, +-- use new settings to use with this extended operation: NO_WORK_UPSQUARE, CHISEL_ONLY_HORZNT +-- 2019.03.27 V1.0b8 FM Manage check door/jamb dimension by function CheckPieceDimension +-- 2019.03.27 V1.0b9 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values +-- 2019.03.27 V1.0b9 FM Modify error messages format into CheckPieceDimension +-- 2019.03.27 V1.0c1 FM Manage estimate time +-- 2019.03.29 V1.0c2 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.08 V1.0c3 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines +-- Now it uses 1 line for antisplint blade and 1 line for normal blade +-- 2019.04.08 V1.0c3 FM Manage Blade groove function AdjustBladeVertCurve +-- 2019.04.30 v1.0c4 FM Manage function AdjustASplintWithBlade to manage anti-splint paths when machine groove by blade +-- 2019.04.30 v1.0c4 FM Manage function AdjustHeadOnASplint to manage hinge anti-splint paths when machine groove by blade +-- 2019.05.28 v1.0c5 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings +-- 2019.07.22 V1.0c7 FM Manage better the updoor/underdoor machinings counter that generate flags values +-- 2019.08.27 V1.0c8 FM Manage underneath machining checking (by machining note 'UD_CHECK') to disable vacuums +-- (use new underneath distance by variable dDistInterferUnder) +-- 2019.11.05 V1.0c9 FM Manage setup files +-- 2020.03.19 V1.0d0 FM Fix error on check door dimension into CheckPieceDimension (when door is shifted by Bullnose profile on hinge side) +-- 2021.03.18 V1.0d1 FM Add new variables to CurrCamInfo that was managed inside this (dVacOffsY, dMobOffsY, dLeftDistX, dRightDistX, MaxOverMat, StepOverMat) +-- 2021.04.06 V1.0d1 FM Fix error on rename lock profile with _LK suffix +-- 2021.04.07 V1.0d2 FM Manage new CurrCamInfo parameter (ForceDirMachHinge) to force the hinge machining direction (descending or ascending) +-- 2021.04.20 V1.0d3 FM Manage new CurrCamInfo parameter (MaxPosMobBar) to limit the mobile ba to a max value with wide door +-- 2021.05.03 V2.101 FM Manage simulation in background to verify collisions, if something collide, not generate CNC program +-- 2021.05.04 V2.102 FM Manage new CurrCamInfo parameter (nDisableAutoCncName) to disable the automatic cnc name composed when generate cnc by GENERATE button +-- to have always the same cnc file name +-- 2021.05.21 V2.103 FM Manage new CurrCamInfo parameter (EnableCollisionDetect) to manage the collision detection +-- 2021.10.13 V2.104 FM Add variables from CurrCamInfo for define safeety zone around pods +-- 2021.10.26 V2.104 FM Manage FD Wedge Cup (FDWC) profile +-- 2021.10.28 V2.105 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter +-- 2021.11.23 V2.107 FM Manage option side probing. Expand function number of CurrDoorCustomData DGC.Pms: 3 side probe on all hardware (for NE machines) ; +-- 4: side probe on all hardware except hardware on hinge side (for machines with shuttles) +-- 2022.01.17 V2.108 FM Manage Split door cut by new CurrCamInfo parameter sCutDirectionAdmitted: = 'H' for cut along door Height; +-- = 'W' for cut along door Width +-- 2022.05.03 V2.109 FM use table paremeter tMainTabPar.NVP instead of variable bNoVertProf. This allow to unify Machining_4 and Machinin_8 processor +-- 2022.11.15 V2.112 FM Manage side groove region as throu path and not as blind region +-- 2023.01.20 V2.114 FM Modification to use compiled code +-- 2023.03.07 V2.115 FM Fix error on manage region into StartVacVerify function +-- 2023.03.29 V2.116 FM Fix error on calculate rough paths on Convex profile +-- 2023.03.31 V1.117 FM Manage offsetted path ( by path note) to extra path of Convex profile +-- 2023.04.03 V2.118 FM Manage Scrap piece removing +-- 2023.05.12 V2.119 FM Manage virtual milling option into collision avoid check +-- 2023.05.24 V2.120 FM Manage by new function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides +-- 2023.09.07 V2.121 FM Manage new file .tok (it's a copy of .txt file) to say Dprod when the generation is finished +-- 2023.09.15 V2.122 FM Write shift value note OffSetPhase... +-- 2023.09.16 V2.123 FM Manage invert paths on convex profile when door is dispose bevel up +-- 2023.09.19 V2.124 FM Modify door disposition: if door has top or bottom trimmed side, dispose the door on right reference +-- 2023.12.01 V2.125 FM Manage small planes on Convex profile +-- 2024.01.31 V2.126 FM Manage also door disposition (by SideDoorDefined CurrCamInfo parameter) with lock side on front to be machined by shuttle/s +-- 2024.06.07 V2.127 FM Manage also to mark some geometries to work with shuttles or aggregates ( Five lakes machines) +-- 2024.06.19 V2.128 FM Manage disposition of same door on 2 different machines ( Five lakes machines) and dispose on 2nd table +-- considering the side machinings on 1st machine +-- 2024.06.19 V2.128 FM Manage new DGD.GHT to let with suffix '_HIDE' or '_2HIDE' to manage the machining geometries on different machines (Five lakes machines) +-- 2024.06.21 V2.128 FM Add parameter to AdjustHead to set clockwise paths +-- 2024.08.28 V2.129 FM Manage new DeleteSideProbePathOnSide CurrCamInfo parameter. this parameter must woth with DGC.Pms = 3 and delete the side probe paths +-- on Hinge side or lock side (to be used with machines on line wehre shuttle can be on hinge side or lock side) +-- 2024.08.30 V2.130 FM Manage better the side probe paths and machinings when it use only one machine and when use both machines +-- 2024.09.04 V2.131 FM Manage new dAltRefShort and dTallRefShort CurrCamInfo parameters. This parameter manage the tall reference and thickness reference on short reference type +-- 2024.10.09 V2.132 FM Manage AdjustProbeHole operation to manage Probe on Z +-- 2024.10.15 V2.133 FM Manage new DGC.NPM parameter (NewProbeMean) to indicate new DGD.PROBE meaning +-- 2024.10.15 V2.133 FM Check the real number of machinings and insert this info in the output +-- 2024.11.06 V2.134 FM Manage the % use shuttle from new MainTabPar.PS3H (.PercentUseShtlWith3Hrdw) and .PUSR (.PercentUseShuttleFromRef) +-- If theese paramenters are not present it uses old values inside +-- 2024.11.14 V2.135 FM Manage the flipping geometry into AdjustConeCleanPaths from solid layer than geometry +-- 2025.01.13 V2.136 FM Manage special command found (by variable bSpecialCommandFound) to generate the part program with special command Px +-- 2025.01.17 V2.137 FM Manage parametr from ini file to enable disable the machining with Mtable 'Link' parameter +-- 2025.01.28 V2.138 FM Manage better the error messages printing when .Link parameter is active +-- 2025.02.21 V3.020 DS Corretta assegnazione parametro MaxDoorThick a tMainTabPar.MxDT (invece di sovrascrivere .MnDW) e relativo passaggio a CheckPieceDimension. + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local MachiningLoc = {} + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() +-- Criterio di disposizione porta contro riferimenti, se fisso o guidato dalla disposizione porta +-- 0: in base alla disposizione porta, 1: forzato solo a sinistra; -1: forzato solo a destra +local FORCEDISPMODE = 0 +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) +local NO_WORK_UPSQUARE = false +-- Definizione possibilità di lavorare testa chisel rimanendo solo orizzontale o seguendo il bevel ( per teste non shuttle) +local CHISEL_ONLY_HORZNT = false +-- variabili generazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true +-- Variabile distanza minima tra pezzo finito e ventosa (in X) +local DIST_MIN_VAC_L = 5.5 +local DIST_MIN_VAC_R = 7.5 +local KIND_DISP_MODE = 1 -- 1: fixture, prende i sottopezzi dalla cartella fixture; 0: machine, alza i sottopezzi dal disegno della macchina +-- variabile per applicare sempre la lavorazione degli anti-scheggia fatti con gli shuttle ( >= 4 inserisce solo quelle necessarie, < 4 inserisce tutte) +-- in caso il groove sia fatto con lama +local MAXMACH = 4 +---------------- VARIABILI GLOBALI ----------------------------------------- +-- variabili disposizione porta +local bPush +local bFlip +local bMachUnder -- variabile che indica se sono state inserite lavorazioni da sotto + +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.EMC) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** Add machining combine in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng + +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +local function CheckExtSideMach( tListEnt) + local sEdgeNote + for j = 1, #tListEnt do + if tListEnt[j] then + sEdgeNote = EgtGetInfo( tListEnt[j], 'EdgeDoor') or '' + if sEdgeNote == 'T' then -- se lavorato lato top + DGD.MTS = 1 + elseif sEdgeNote == 'B' then -- se lavorato lato bottom + DGD.MBS = 1 + elseif sEdgeNote == 'H' then -- se lavorato lato hinge + DGD.MHS = 1 + elseif sEdgeNote == 'L' then -- se lavorato lato lock + DGD.MLS = 1 + end + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, + sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, + bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed, nIdMachine) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') + local sKeepBackSet = EgtGetInfo( tEndId[1], 'KeepBackSet') + local sProbeSide = EgtGetInfo( tEndId[1], 'ProbeSide') -- ProbeMachXY + local nActiveStop = EgtGetInfo( tEndId[1], 'ActiveStopMach', 'i') + local nSetMaxElev = EgtGetInfo( tEndId[1], 'SetMaxElev', 'i') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + local sKeepBackSetCode + local sActiveStop + local sSetMaxElev + local sProbeSideCode + + -- determino in base alla disposizione quale codice KeepBackSet dare alla lavorazione + if sKeepBackSet and not bNotGenMachining then + if (bPush and bFlip) or ( not bPush and not bFlip) then -- se lato narrow è in basso (BD) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + end + else -- altrimenti lato narrow è in alto (BU) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + end + end + end + + -- determino in base alla direzione dell'entità quale codice sProbeSide dare alla lavorazione + if sProbeSide and not bNotGenMachining then + sProbeSideCode = 'CPBP' -- CORR_POS_BY_PROBE + end + -- + if nActiveStop and not bNotGenMachining then + sActiveStop = 'ActiveStopMach=1' + end + -- + if nSetMaxElev and not bNotGenMachining then + sSetMaxElev = 'MaxElev=0.0' + end + if nMach == 1 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMach) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + -- assegno nota con Id macchina + if nIdMachine and nIdMachine > 0 then + SetInfoTable( tEndId, 'IdMachine', nIdMachine) + end + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachUp) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + -- assegno nota con Id macchina + if nIdMachine and nIdMachine > 0 then + SetInfoTable( tEndId, 'IdMachine', nIdMachine) + end + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, + bNotGenMachining, sKeepBackSetCode, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + sActiveStop, sSetMaxElev, dOverR) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachDw) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + -- assegno nota con Id macchina + if nIdMachine and nIdMachine > 0 then + SetInfoTable( tEndId, 'IdMachine', nIdMachine) + end + end + end + end + + return bOk, nNumMach, tMachining +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed, + bCheckDirection) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- acquisisco il campo Link se è presente + DGD.LVL = tonumber( tLocTable[i].Link) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if ( tLocTable[i].Oper == 'AdjustHead' or tLocTable[i].Oper == 'AdjustHeadOnASplint') and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j], bCheckDirection) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nNumMachFromTable) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, + nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed, nIdMachine) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed, nIdMachine) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Movimento ventose *** +----------------------------------------------------------------- +local ThroughId, BlindId +----------------------------------------------------------------- +local function StartVacVerify( nIdSolid, bFlipped, dThDoor) + -- regioni passante e cieca non definite + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + -- recupero le regioni sopra e sotto della porta messa in macchina + local UpId, DwId + local DwIdExtraBlind = {} + local sExtraBlindRegName + local DwIdExtraGrvBlind = {} + local sExtraGrvBlindRegName + local dZedToMove + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + sExtraBlindRegName = 'FLAT_UP_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_UP_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = dThDoor + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + sExtraBlindRegName = 'FLAT_DW_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_DW_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = 0 + end + -- creo le regioni complementari + local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT) + local CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) + local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) + local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end + EgtSurfFrSubtract( CompUpId, UpId) + if not EgtExistsObj( CompUpId) then CompUpId = nil end + + local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT) + local CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) + -- faccio una copia per gli altri controlli + local DownRegId = nil + if CompDwId then + DownRegId = EgtCopyGlob( CompDwId, nIdSolid) + EgtInvertSurf( DownRegId) + end + local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) + local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end + EgtSurfFrSubtract( CompDwId, DwId) + if not EgtExistsObj( CompDwId) then CompDwId = nil end + if CompDwId then EgtInvertSurf( CompDwId) end + + -- calcolo le regioni passante e cieca + local ThroughRegId = nil + local BlindRegId = nil + -- se ci sono entrambe le regioni + if CompUpId and CompDwId then + -- per ottenere la regione passante faccio intersezione tra sopra e sotto + EgtSurfFrIntersect( CompUpId, CompDwId) + if EgtExistsObj( CompUpId) then + ThroughRegId = CompUpId + end + -- per ottenere la regione cieca faccio differenza tra sotto e passante + if ThroughRegId then + EgtSurfFrSubtract( CompDwId, ThroughRegId) + if EgtExistsObj( CompDwId) then + BlindRegId = CompDwId + end + else + BlindRegId = CompDwId + end + -- se c'è solo la regione sotto è già quella delle lavorazioni cieche + elseif CompDwId then + BlindRegId = CompDwId + -- se c'è solo la sopra, non interessa e la cancello + elseif CompUpId then + EgtErase( CompUpId) + end + -- sistemazioni finali + if ThroughRegId or #DwIdExtraGrvBlind then + ThroughId = EgtGroup( GDB_ID.ROOT) + EgtSetName( ThroughId, 'THROUGH') + EgtSetColor( ThroughId, RED()) + EgtSetLevel( ThroughId, GDB_LV.TEMP) + local nChunk = 0 + if ThroughRegId then + while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraGrvBlind do + local nIdBl = DwIdExtraGrvBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + EgtErase( ThroughRegId) +-- EgtSetName( ThroughRegId, 'THROUGH') +-- EgtSetColor( ThroughRegId, RED()) +-- EgtSetLevel( ThroughRegId, GDB_LV.TEMP) + end + if BlindRegId or #DwIdExtraBlind > 0 then + BlindId = EgtGroup( GDB_ID.ROOT) + EgtSetName( BlindId, 'BLIND') + EgtSetColor( BlindId, BLUE()) + EgtSetLevel( BlindId, GDB_LV.TEMP) + local nChunk = 0 + if BlindRegId then + while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraBlind do + local nIdBl = DwIdExtraBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, BlindId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + if BlindRegId then + EgtErase( BlindRegId) +-- EgtSetName( BlindRegId, 'BLIND') +-- EgtSetColor( BlindRegId, BLUE()) +-- EgtSetLevel( BlindRegId, GDB_LV.TEMP) + end + end + if DownRegId then + FaceDwId = EgtGroup( GDB_ID.ROOT) + EgtSetName( FaceDwId, 'DWREG') + EgtSetColor( FaceDwId, BLUE()) + EgtSetLevel( FaceDwId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( DownRegId, nChunk, FaceDwId) do + nChunk = nChunk + 1 + end + EgtErase( DownRegId) +-- EgtSetName( DownRegId, 'DWREG') +-- EgtSetColor( DownRegId, GREEN()) +-- EgtSetLevel( DownRegId, GDB_LV.TEMP) + end +end + +----------------------------------------------------------------- +local function ExecVacVerify( ptVac, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, sAngGrooveNote, + nIdSolid, bFlipped, ptVacId) + -- verifica con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferThru then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferBlind then + return false + end + end + nId = EgtGetNext( nId) + end + + -- se ho delle lavorazioni da sotto + if bMachUnder then + local tUnderList = {} + tUnderList = MB.FindGeomWithNote( Pz, 'UnderneathMach', 'b', true, tUnderList) + for i = 1, #tUnderList do + local ptNear = EgtNP( tUnderList[i], ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferUnder then + return false + end + end + end + end + + -- se ho groove su top angolo + if sAngGrooveNote and #sAngGrooveNote > 0 then + local tGrooveOnAng = EgtSplitString( sAngGrooveNote) + if tGrooveOnAng and #tGrooveOnAng > 0 then + for i = 1, #tGrooveOnAng do + -- prendo la prima geometria del layer + local nGrvId = EgtGetFirstInGroup( tGrooveOnAng[i]) + if nGrvId then + local ptNear = EgtNP( nGrvId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + + -- controllo che la ventosa sia al di fuori della regione + local DwId + local bDistBtwRegion + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + else + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + end + + if DwId then + bDistBtwRegion = EgtSurfFrTestExternal( DwId, ptVacId, 0.1) + end + + -- se punto ventosa esterno alla regione e distanza inferiore al limite ... + if bDistBtwRegion and dDist > min( dDistInterferThru, dDistInterferBlind, dDistInterferUnder) then + return false + end + end + end + end + end + end + + -- nessuna interferenza + return true +end + +----------------------------------------------------------------- +local function EndVacVerify() + -- cancello regioni passante e cieca + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + EgtErase( FaceDwId or GDB_ID.NULL) + FaceDwId = nil +end + +----------------------------------------------------------------- +local function MoveVac( nId, dVal) + local dOldVal = EgtGetInfo( nId, 'Val', 'd') + EgtMove( nId, Vector3d( 0, 0, dVal - dOldVal), GDB_RT.GLOB) + EgtSetInfo( nId, 'Val', dVal) +end + +----------------------------------------------------------------- +local function AddMoveShowHideVac( nMode, nGroupId, sNameVac, sNameCol, dVal, sVacName, pPointApp) + + local nVac + local nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameVac) + if nMode == 1 then -- se disposizione fixture + EgtSetAlpha( nId, 20) -- imposto trasparenza poco visibile + -- inserisco la ventosa + nVac = EgtAddFixture( sVacName, pPointApp, 0) + elseif nMode == 0 then -- disposizione machine + EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità + MoveVac( nId, dVal) + -- muovo anche lo stelo + nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameCol) + MoveVac( nId, dVal) + else + EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità + end + return nVac +end + +----------------------------------------------------------------- +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +----------------------------------------------------------------- +local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + local bFailDim = false + local sErrMess = '' + local dLimitToCheck + + dLimitToCheck = dMinDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMinDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMaxDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMinDoorThick + if dThickDoor < dLimitToCheck then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorThick + if dThickDoor > dLimitToCheck then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + return bFailDim +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup, OptimizeMach) + +-- local nTime +-- -- inizializzo il contatore +-- EgtStartCounter() + + -- Setto parametro ottimizzazione lavorazioni macchine in linea + DGD.OML = OptimizeMach + + -- macchina e tabella di default + -- tabella parametri d'uso per variabili CurrcamInfo + tMainTabPar = {} + --macchina e tabella di default + tMainTabPar.MN = 'Multiax-' + + -- Machinings Tables + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- Define door disposition ( on left: 1, on right : -1) + local nDispMode = -1 + -- References on table (respect Zero machine) + -- Y Table + tMainTabPar.OR1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + tMainTabPar.OR2 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftVac = Vector3d(0,0,0) + tMainTabPar.SH1 = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + tMainTabPar.SHL = Vector3d(0,0,0) + -- variabile per posizione media della porta per il cambio navette + local dPosShuttleChange = 40 * GEO.ONE_INCH + -- tabella raggi profili su ogni lato + local tsRadiusProf = {} + local tsPlaneProf = {} + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- variabili pezzo singolo + local nPz + local sAssemb + + -- variabile check dimensioni porta + local bFailDim = false + + -- variabile per comandi speciali nel campo code del ddf + local bSpecialCommandFound + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- se la variabile è una tabella, estrapolo solo la porta + local PzIsTab = type(tPz) == 'table' + if PzIsTab then + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + + -- se non ha nota o nota della prima porta esco + if not sAssemb or ( sAssemb and sAssemb == 'first') then + break + end + end + else + Pz = tPz + sAssemb = tsAssemb + end + +-------------------------------------------------------------------------------- + -- Dati della porta + local sDoorCode = EgtGetInfo( Pz, 'Code') + local dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + local dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + local dThickDoor = EgtGetInfo( Pz, 'T', 'd') + local sSwing = EgtGetInfo( Pz, 'Swing') + MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente + local sSecure = EgtGetInfo( Pz, 'Secure') + local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + local sTopTrim = EgtGetInfo( Pz, 'top_trimming') + local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra + local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) + local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' ) + tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') + tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') + tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') + tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') + tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') + tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') + tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') + local nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 + local nPostProbeSet = EgtGetInfo( Pz, 'PostProbeSet', 'i') or 0 + local nNewProbeMeaning = EgtGetInfo( Pz, 'NewProbeMean', 'i') or 0 + local dNumHingesPivots = EgtGetInfo( Pz, 'NumHingesPivots', 'd') or 0 + local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + + -- Box pezzo + local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + local Aux = EgtGetFirstNameInGroup( Pz, 'AUX') + local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local b3Solid = BBox3d() -- inizializzo il box nullo + b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + + ------------------------------------------------------ + -- se codice porta contiene comandi speciali + -- che non producono la generazione del part program della porta ma dei part program speciali + if sDoorCode then + local sCode = string.lower(sDoorCode) + if sCode == 'p1' or sCode == 'p2' or sCode == 'p3' or sCode == 'p4' or sCode == 'p5' or sCode == 'p6' then + EgtSetInfo( Pz, 'SpecialCmd', sCode) + bSpecialCommandFound = true + end + end + ------------------------------------------------------ + +-------------------------------------------------------------------------------- + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + local TAB + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato + return false + end + local MachinesName = TAB.MMachineData + if not MachinesName then + DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable + return false + end + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + local TABORD + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + + -- imposto i dati macchina secondo le informazioni del file cam + tMainTabPar.MN = mCamData[nNumMachFromCam].MachName + tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 + tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 + tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 + tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck + tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength + tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength + tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth + tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth + tMainTabPar.MxDT = mCamData[nNumMachFromCam].MaxDoorThick + tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick + tMainTabPar.FUS = mCamData[nNumMachFromCam].ForceShuttleUse + tMainTabPar.FDMH = mCamData[nNumMachFromCam].ForceDirMachHinge + tMainTabPar.PS3H = mCamData[nNumMachFromCam].PercentUseShtlWith3Hrdw or 0.6 + tMainTabPar.PUSR = mCamData[nNumMachFromCam].PercentUseShuttleFromRef or 0.4 + tMainTabPar.FDH = mCamData[nNumMachFromCam].ForceDisableHood + tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef + tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef + tMainTabPar.ARS = mCamData[nNumMachFromCam].dAltRefShort or tMainTabPar.AR + tMainTabPar.TRS = mCamData[nNumMachFromCam].dTallRefShort or tMainTabPar.TR + tMainTabPar.VOY = mCamData[nNumMachFromCam].dVacOffsY or 57.5 + tMainTabPar.MOY = mCamData[nNumMachFromCam].dMobOffsY or 201.6 + tMainTabPar.LDX = mCamData[nNumMachFromCam].dLeftDistX or 118.35 + tMainTabPar.RDX = mCamData[nNumMachFromCam].dRightDistX or 170.125 + tMainTabPar.MPMB = mCamData[nNumMachFromCam].MaxPosMobBar or 1155 + tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure + tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat + tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 + tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain + tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining + tMainTabPar.GCDN = mCamData[nNumMachFromCam].GenCncAsDdfName or 0 + tMainTabPar.DACN = mCamData[nNumMachFromCam].DisableAutoCncName or 0 + tMainTabPar.BPLI = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) + tMainTabPar.PRF = mCamData[nNumMachFromCam].PercRedFeed or 0.3 + tMainTabPar.SDF = mCamData[nNumMachFromCam].SideDoorDefined or 1 + FORCEDISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or FORCEDISPMODE -- SideDoorDispose + CHISEL_ONLY_HORZNT = mCamData[nNumMachFromCam].ChiselHorizzontal or CHISEL_ONLY_HORZNT -- new + tMainTabPar.DTG = mCamData[nNumMachFromCam].SafetyDistVacThru or 12 + tMainTabPar.DBG = mCamData[nNumMachFromCam].SafetyDistVacBlind or 45 + tMainTabPar.DUG = mCamData[nNumMachFromCam].SafetyDistVacUnder or 55 + tMainTabPar.ECD = mCamData[nNumMachFromCam].EnableCollisionDetect or 0 -- new + tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels or 0 -- new + tMainTabPar.PTK = mCamData[nNumMachFromCam].dProbeThickness or 0 -- new + tMainTabPar.NVP = mCamData[nNumMachFromCam].ProfBy5AaxisHead == 1 -- new + tMainTabPar.CDA = mCamData[nNumMachFromCam].sCutDirectionAdmitted or '' -- new + tMainTabPar.BDH = mCamData[nNumMachFromCam].BigDoorHeight or 1800.0 -- new + tMainTabPar.RSM = mCamData[nNumMachFromCam].RemoveScrapMode or 0 -- new + tMainTabPar.MSV = mCamData[nNumMachFromCam].MinScrapValue or 0 -- new + tMainTabPar.FDD = mCamData[nNumMachFromCam].ForceDisposByDust or 0 -- new + tMainTabPar.DSPP = mCamData[nNumMachFromCam].DeleteSideProbePathOnSide or 0 -- new + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable + return true + end + + -- setto come generare il nome del file cnc (di default è uguale al nome del parametro interno ad ddf) + if tMainTabPar.GCDN == 0 then + -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi + sFileName = sDoorCode + end + + local MTable = TAB.MTable + local MTableOrd = TABORD.MTable + -- variabile principale per definizione disposizione porta a destra o sinistra + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftedDoor = false + local sDispMode + local sTotDispMode = '' + local sNumGroup = '' + local bWork = true + -- variabili utilizzate dentro al ciclo + local nMchId + local sTab + local tabOri + local Ori + local ColA + local nRaw + local bMoveRaw + local bTopOnRight + -- variabili per disposizione sottopezzi + local dMobOffs + local dVacOffs + local dDistMinX + local dDistMaxX + local dVacOn + local dInterAx + local OffsXSovr = 0 + local OffsYSovr = 0 + local dDistInterferThru + local dDistInterferBlind + local dDistInterferUnder + -- variabile per tool setup + local MSetup + local sSetup + -- variabili calcolo box + local b3SolidOnTab + local pMin + local pMax + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local sMachProf + local bWorkUnder = true + -- variabile per conteggio lavorazioni + local nNumMach + local nNumSkip + local tSecMachTab = {} + -- variabili per fase + local nNumPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + local nNumGeomBottomHole = 0 + local nNumGeomTopHole = 0 + -- variabili per geometrie lato Hinge + local nNumTopGeom = 0 + local nNumBottomGeom = 0 + -- variabile piazzamento porta + local sLight + -- variabile direzione riordino gruppi + local nDirReorderGroups + -- tabella lavorazioni + local tLocMach = {} + local tLocMachOrd = {} + local tSplitDoorEnt = {} + local tSplitDataInf = {} + + local bGetSplitCuts = false + local nNumProbeZ + local nDispFront = 1 + local DelListTwo = {} + + -- per prima cosa verifico se la disposizione é in positivo (disposizione in fronte, standard) + -- o in negativo (disposizione dietro, caso seconda macchina in catena) + + -- se le origini hanno campo Y in negativo indica che la disposizione non é sul fronta ma dietro + -- e disposizione porta con lato lock su shuttle (implica di avere alcune geometrie con suffisso _LK o _HD) + -- e inoltre + if ( tMainTabPar.OR1[2] < 0 and tMainTabPar.OR2[2] < 0) and tMainTabPar.SDF == 4 then + nDispFront = -1 + DGD.GHT = '_2HIDE' + elseif not DGD.GHT then + DGD.GHT = '_HIDE' + end + + -- cancello tutti i percorsi ghost + local DelList = MB.FindEntitiesWithPartName( tPz, DGD.GHT) + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- elimino percorsi eventualmente creati dal Mach + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + + -- se seconda macchina verifico se ho lavorato un profilo lo setto come fatto + if nDispFront < 0 then + -- se lato hinge da lavorare e ho effettivamente lavorato il lato, lo disabilito + if bHingeMach and DGD.MHS and DGD.MHS == 1 then + bHingeMach = false + if bAtRight then + dLeftOffs = 0 + else + dRightOffs = 0 + end + end + -- se lato lock da lavorare e ho effettivamente lavorato il lato, lo disabilito + if bLockMach and DGD.MLS and DGD.MLS == 1 then + bLockMach = false + if bAtRight then + dRightOffs = 0 + else + dLeftOffs = 0 + end + end + -- se lato top da lavorare e ho effettivamente lavorato il lato, lo disabilito + if bTopMach and DGD.MTS and DGD.MTS == 1 then + bTopMach = false + dTopOffs = 0 + end + -- se lato bottom da lavorare e ho effettivamente lavorato il lato, lo disabilito + if bBottomMach and DGD.MBS and DGD.MBS == 1 then + bBottomMach = false + dBottomOffs = 0 + end + end + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( tMainTabPar.MN) + + ------------------------------------------------------------------------------------------------------- + -- per questa macchina è importante differenziare il nome del profilo lato lock rispetto al lato hinge + -- in modo che venga lavorato prima il lato hinge e poi il lock + ------------------------------------------------------------------------------------------------------- + -- Recupero le entità + local nLockProf + -- se serratura è a destra cerco il nome dl profilo corrispondente a quel lato + if bAtRight then + nLockProf = EgtGetFirstNameInGroup( Pz, 'Right') + else + nLockProf = EgtGetFirstNameInGroup( Pz, 'Left') + end + + local EntListHg = MB.FindEntities( nLockProf) + sLockTrim = sLockTrim..'_LK' + + -- rinomino tutte le entità del gruppo + for j = 1, #EntListHg do + local sNameEnt = EgtGetName( EntListHg[j]) + if not string.find( sNameEnt, '_LK') then + sNameEnt = sNameEnt .. '_LK' + end + EgtSetName( EntListHg[j], sNameEnt) + end + + -- faccio tutte le fasi ( probabilmente solo una perché non sono previsti ribaltamenti) + while bWork do + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '1 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + sDispMode = '' + bMachUnder = nil + + nNumGroup = nNumGroup + 1 + + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString( nNumGroup,0) .. '_' .. tMainTabPar.MN) + else + nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '2 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + if nMchId then + + local sLocNumGroup = '' + if nNumGroup > 1 then sLocNumGroup = '_'..EgtNumToString(nNumGroup,0) end + -- provo ad eliminare il file .tok per il prod + EgtEraseFile( sFileDir .. sFileName .. sLocNumGroup .. '.tok') + -- se nome cn non generato automaticamente (cioè dal campo interno al ddf) ma dal nome del file + if tMainTabPar.DACN == 1 then + EgtSetInfo( nMchId, 'NcName', sFileName .. sLocNumGroup .. '.cnc') + end + -- assegno al gruppo di lavoro l'info relativo allo stato del controllo collisione + EgtSetInfo( nMchId, 'EnableCollisionDetect', tMainTabPar.ECD) + -- assegno al gruppo di lavoro la lunghezza minima porta + EgtSetInfo( nMchId, 'LongDoorLimit', tMainTabPar.BDH) + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + EgtSetInfo( nMchId, 'Vm', '1') + end + end + + nNumPhase = EgtGetCurrPhase() + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + dLeftOffs = 0 + dRightOffs = 0 + dTopOffs = 0 + dBottomOffs = 0 + end + + ColA = Color3d( 255, 165, 0, 15) + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, + b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) + + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs, dBottomOffs, 0), nRaw) + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitare inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + tLocMach = MTable + tLocMachOrd = MTableOrd + sMachProf = '' + + -- in base ai valori di sovramateriale sui lati, se tutti sono al di sotto di 3 volte il valore di attivazione della sgrossatura + -- allora disabilito lo scrapmode + if dLeftOffs < tMainTabPar.MSV and dRightOffs < tMainTabPar.MSV and dTopOffs < tMainTabPar.MSV and dBottomOffs < tMainTabPar.MSV then + tMainTabPar.RSM = 0 + end + + -- prendo nota dei profili tipo bevel e bull nose + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + local nUnderGeom + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + local sUpperProfName = string.upper(tLocMach[i].Name) + -- prendo i profili bevel direttamente dalla tabella + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName) then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Test delle lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + nNumGeomBottomHole = nNumGeomBottomHole + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + nNumGeomTopHole = nNumGeomTopHole + 1 + end + end + end + end + end + end + end + + ----------------------- + -- *** Disposizione *** + ----------------------- + + -- controllo se ho profili bullnose sul lato hinge (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sHingeTrim == '1B' or sHingeTrim == '2B') then -- se profilo cerniere è bullnose + bShiftedDoor = true + end + + -- controllo se ho profili bullnose sul lato serratura (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK') then -- se profilo serratura indicato è bullnose + vShiftVac = tMainTabPar.SHL + else + vShiftVac = vNullShift + end + + -- Scelta della tavola + sTab = 'Tab' + EgtSetTable( sTab) + + -- Origine tavola corrente rispetto a Zero macchina + tabOri = EgtGetTableRef( 1) + + -- Rotazione porta in base alla macchina + bMoveRaw = false + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- se non c'è il parametro considero la porta come se avesse bevel down + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or + sSwing == 'LH' or sSwing == 'LHA' or sSwing == 'LHI' then + bPush = true + else + bPush = false + end + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. tostring( nNumPhase) + elseif nNumPhase then + sNumPhase = tostring( nNumPhase) + else + sNumPhase = '0' + end + + local bOkDisp = false + nNumProbeZ = 0 + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure +-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel e da lavorare + if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or + ( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) +-- if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK') and bLockMach and not bOkDisp then + if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB_LK') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sLockTrim == 'BD_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BD_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- a meno che ho il profilo opposto, in questo caso non ribalto la porta, altrimenti devo ribaltare la porta + -- e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') and bPush) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and not bPush and not bOppoBevelProf) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and bPush and bOppoBevelProf) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or + ( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or + ( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo altrimenti do errore + if sSecure and string.upper(sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + sSecure = tMainTabPar.LS + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if sSecure and string.upper(sSecure) == 'UP' then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif sSecure and string.upper(sSecure) == 'DN' then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) quella di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + -- se porta a tirare non la ribalto perché si presta già ad essere bevel down + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + else -- in base alle geometrie trovate ribalto o meno la porta + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + else -- altrimenti vecchio metodo + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + end + end + end + + -- se il lato in fronte è il lato lock + if tMainTabPar.SDF > 1 and tMainTabPar.SDF < 4 then + bTopOnRight = not bTopOnRight + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftedDoor then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + ----------------------------------------------------------------------------------------------- + -- Scelta della disposizione e di conseguenza dell'origine (ora espressa rispetto Zero Tavola) + ----------------------------------------------------------------------------------------------- + + local bLocTopOnRight = bTopOnRight + -- se il lato di riferimento è il bottom, inverto il flag della disposizione lato top + if FORCEDISPMODE == 0 and ( tMainTabPar.SDF == 0 or tMainTabPar.SDF == 2) then + bLocTopOnRight = not bTopOnRight + end + + if FORCEDISPMODE == 0 then -- disposizione segue il top della porta + if bLocTopOnRight then + nDispMode = -1 + else + -- 19.09.2023 richiesta di Mark Hoffman: per problemi di presenza della polvere: se la porta ha lato top e/o bottom lavorate, la disposizione della porta + -- deve essere fatta a destra + if tMainTabPar.FDD > 0 and ( bTopMach or bBottomMach) then + nDispMode = -1 + else + nDispMode = 1 + end + end + else + nDispMode = FORCEDISPMODE + end + + Ori = EgtIf( nDispMode > 0, tMainTabPar.OR1, tMainTabPar.OR2) + + -- se porta da traslare setto lo shift da applicare + if bShiftedDoor then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + + + -- se ho macchine in linea, tolgo il prefisso NO_ ai percorsi side probe + if tMainTabPar.DSPP > 0 then + +-- debug +-- if tMainTabPar.DSPP == 3 then +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) +-- end + + -- recupero entità probe di fianco disabilitati + local ProbeList = MB.FindEntitiesWithName( Pz, 'NO_ProbeSidePoint') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + if bFlip then + EgtSetName( ProbeList[j], 'ProbeSidePoint_secure' ) + else + EgtSetName( ProbeList[j], 'ProbeSidePoint_keyway' ) + end + end + + -- se seconda macchina recupero eventuali entità probe sul lato hinge e lock che sono state disabilitate se il lato è stato lavorato + if nDispFront < 0 then + local sInfoToFind + -- se lato hinge lavorato + if DGD.MHS and DGD.MHS == 1 then + ProbeList = MB.FindEntitiesWithName( Pz, 'NO_Hinge_Probe') + for j = 1, #ProbeList do + sInfoToFind = EgtGetInfo( ProbeList[j], 'OriName', 's') or '' + if #sInfoToFind > 0 then + EgtSetName( ProbeList[j], sInfoToFind) + end + end + end + -- se lato lock lavorato + if DGD.MLS and DGD.MLS == 1 then + ProbeList = MB.FindEntitiesWithName( Pz, 'NO_Shuttle_Probe') + for j = 1, #ProbeList do + sInfoToFind = EgtGetInfo( ProbeList[j], 'OriName', 's') or '' + if #sInfoToFind > 0 then + EgtSetName( ProbeList[j], sInfoToFind) + end + end + end + end + end + + -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto + if nProbeMode == 1 then + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + end + -- cancello tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + -- calcello su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + -- calcello su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimanenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + end + -- mi tengo via il numero di probe in Z + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbePoint') + end + -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto + elseif nProbeMode == 0 and nPostProbeSet >= 3 then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + -- calcello su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + -- calcello su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimanenti cancellando eventualmente quelli indicati dal parametro tMainTabPar.DSPP > 0 + if bFlip then + DelList, DelListTwo = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure', nil, 'SideApplied', tMainTabPar.DSPP) + else + DelList, DelListTwo = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway', nil, 'SideApplied', tMainTabPar.DSPP) + end + -- ciclo su tutte le entità trovate e le cancello + for j = 1, #DelListTwo do + EgtErase( DelListTwo[j] ) + end + -- mi tengo via il numero di probe sul fianco + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbeSidePoint') + end + else -- se non c'è il probe point elimino tutti i percorsi di probe (in Z) + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + end + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local vExtraYDelta + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProbeOppo = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + local dAltReference = EgtIf( bShiftedDoor, tMainTabPar.ARS, tMainTabPar.AR) + local dThickReference = EgtIf( bShiftedDoor, tMainTabPar.TRS, tMainTabPar.TR) + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nTopMach = 0 -- setto default non lavorato + local nBottomMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ or FDWC + local nSideOppoType = -1 -- 0 per profili SQ + local nTopType = -1 -- 0 per profili SQ or FDWC + local nBottomType = -1 -- 0 per profili SQ or FDWC + -- setto suffisso per le note se macchine in linea + local sLineMachineSuffix = '' + + if tMainTabPar.SDF == 4 then + if nDispFront < 0 then + sLineMachineSuffix = '_2' + else + sLineMachineSuffix = '_1' + end + end + + -- verifico profilo in battuta (hinge) + if sHingeTrim == 'SQ' or sHingeTrim == 'EB' or sHingeTrim == 'FDWC' then + nSideType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then + nSideType = 1 + if dThickDoor > dAltReference then + dExtraY = ( dThickDoor - dAltReference) * TAN3 + end + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up uso il riferimento in basso + elseif sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then + nSideType = 2 + dExtraY = ( dAltReference - dThickReference) * TAN3 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = (( dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sHingeTrim == '1B' or sHingeTrim == '2B' or + sHingeTrim == '3B' or sHingeTrim == '4B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( dAltReference - dThickReference) then + dAltcalc = dAltReference - dThickReference - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > dAltReference then + dAltcalc = dAltProf - dAltReference + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = tsRadiusProf[1] - sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sHingeTrim == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = (dThickReference/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-((dAltProf-tsPlaneProf[1])*(dAltProf-tsPlaneProf[1]))) + + -- se riferimento è sul max ingombro porta + if ( dThickDoor < dAltReference) and ( dThickDoor > ( dAltReference - dThickReference)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( dAltReference - (dThickReference/2)) then + dAltcalc = dAltReference - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( dAltReference - (dThickReference/2)) then + dAltcalc = dAltProf - dAltReference + dThickReference + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = tsRadiusProf[1] - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + + -- verifico profilo opposto alla battuta (lock) + if sLockTrim == 'SQ_LK' or sLockTrim == 'EB_LK' then + nSideOppoType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK' then + nSideOppoType = 1 + if dThickDoor > dAltReference then + dExtraYOppo = ( dThickDoor - dAltReference) * TAN3 + end + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + dDeltaProbeOppo = dDeltaProfOppo - dExtraYOppo + -- dato che viene compensato il dDeltaProbeOppo nella tastatura. il dDeltaProf risulta essere uguale a dExtraY +-- dDeltaProfOppo = dExtraYOppo + -- se disposizione bevel up uso il riferimento in basso + elseif sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then + nSideOppoType = 2 + dExtraYOppo = ( dAltReference - dThickReference) * TAN3 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = (( dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + dDeltaProbeOppo = dDeltaProfOppo - dExtraYOppo + -- dato che viene compensato il dDeltaProbeOppo nella tastatura. il dDeltaProf risulta essere uguale a dExtraY +-- dDeltaProfOppo = dExtraYOppo + -- se profilo bull nose verifico in base al raggio + elseif sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or + sLockTrim == '3B_LK' or sLockTrim == '4B_LK' then + + nSideOppoType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( dAltReference - dThickReference) then + dAltcalc = dAltReference - dThickReference - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > dAltReference then + dAltcalc = dAltProf - dAltReference + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraYOppo = tsRadiusProf[2] - sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbeOppo = -dExtraYOppo + -- dato che viene compensato il dDeltaProbeOppo nella tastatura. il dDeltaProf risulta essere uguale a dExtraY +-- dDeltaProfOppo = dExtraYOppo + -- se profilo convex verifico in base al raggio + elseif sLockTrim == 'CV_LK' then + + nSideOppoType = 4 + local dAltProfOppo + local dAltProfOppoTh + local dExtraYOppoTh + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo punto minimo ingombro profilo + dAltProfOppoTh = dThickDoor/2 - tsPlaneProf[2] + -- calcolo errore del probe tastando a spessore completo - extra z + dAltProfOppo = (dThickDoor/2) - tMainTabPar.EZPB - tsPlaneProf[2] + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) + dExtraYOppoTh = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppoTh*dAltProfOppoTh)) + -- calcolo errore del probe tastando dallo spessore - quota extra z + dDeltaProfOppo = dExtraYOppo - dExtraYOppoTh + else + -- calcolo punto minimo ingombro profilo + dAltProfOppo = dThickDoor/2 - tsPlaneProf[2] + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = tsRadiusProf[2] - dExtraYOppo + end + end + + -- verifico profilo top + if sTopTrim == 'SQ' or sTopTrim == 'EB' or sTopTrim == 'FDWC' then + nTopType = 0 + -- se disposizione bevel down + elseif sTopTrim == 'BD' or sTopTrim == 'BDEB' then + nTopType = 1 + -- se disposizione bevel up uso il riferimento in basso + elseif sTopTrim == 'BU' or sTopTrim == 'BUEB' then + nTopType = 2 + -- se profilo bull nose verifico in base al raggio + elseif sTopTrim == '1B' or sTopTrim == '2B' or + sTopTrim == '3B' or sTopTrim == '4B' then + nTopType = 3 + -- se profilo convex verifico in base al raggio + elseif sTopTrim == 'CV' then + nTopType = 4 + end + + -- verifico profilo top + if sBottomTrim == 'SQ' or sBottomTrim == 'EB' or sBottomTrim == 'FDWC' then + nBottomType = 0 + -- se disposizione bevel down + elseif sBottomTrim == 'BD' or sBottomTrim == 'BDEB' then + nBottomType = 1 + -- se disposizione bevel up uso il riferimento in basso + elseif sBottomTrim == 'BU' or sBottomTrim == 'BUEB' then + nBottomType = 2 + -- se profilo bull nose verifico in base al raggio + elseif sBottomTrim == '1B' or sBottomTrim == '2B' or + sBottomTrim == '3B' or sBottomTrim == '4B' then + nBottomType = 3 + -- se profilo convex verifico in base al raggio + elseif sBottomTrim == 'CV' then + nBottomType = 4 + end + + -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota + if bHingeMach then + dExtraY = 0 + nHingeMach = 1 + dDeltaProbe = 0 + dDeltaProf = 0 + end + -- se profilo lock da lavorare setto la variabile per la nota + if bLockMach then + dExtraYOppo = 0 + nLockMach = 1 + dDeltaProbeOppo = 0 + dDeltaProfOppo = 0 + end + -- se profilo Top da lavorare setto la variabile per la nota + if bTopMach then + nTopMach = 1 + end + -- se profilo Bottom da lavorare setto la variabile per la nota + if bBottomMach then + nBottomMach = 1 + end + + vExtraYDelta = Vector3d(0, EgtIf( nDispFront > 0, -dExtraY, dExtraYOppo),0) + -- scrivo le note + EgtSetInfo( Pz, 'ExtraCalcMoveY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dExtraY, dExtraYOppo)) + EgtSetInfo( Pz, 'ExtraCalcOppoMoveY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dExtraYOppo, dExtraY)) + EgtSetInfo( Pz, 'DoorProbeErrorY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dDeltaProbe, dDeltaProbeOppo)) + EgtSetInfo( Pz, 'DoorProbeOppoErrorY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dDeltaProbeOppo, dDeltaProbe)) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ'..sLineMachineSuffix, tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProbeThick'..sLineMachineSuffix, tMainTabPar.PTK) + EgtSetInfo( Pz, 'DoorProfErrorY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dDeltaProf, dDeltaProfOppo)) + EgtSetInfo( Pz, 'DoorProfOppoErrorY'..sLineMachineSuffix, EgtIf( nDispFront > 0, dDeltaProfOppo, dDeltaProf)) + EgtSetInfo( Pz, 'SideDisposition'..sLineMachineSuffix, nDispMode) + EgtSetInfo( Pz, 'EdgeDisposition'..sLineMachineSuffix, nDispFront) + -- scrivo nota disabilitazione cuffia + EgtSetInfo( Pz, 'ForceDisableHood', tMainTabPar.FDH) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef'..sLineMachineSuffix, EgtIf( nDispFront > 0, nSideType, nSideOppoType)) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo'..sLineMachineSuffix, EgtIf( nDispFront > 0, nSideOppoType, nSideType)) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach'..sLineMachineSuffix, nHingeMach) + -- scrivo nota tipo profilo lato hinge + EgtSetInfo( Pz, 'SideHingeProf'..sLineMachineSuffix, nSideType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach'..sLineMachineSuffix, nLockMach) + -- scrivo nota tipo profilo lato hinge + EgtSetInfo( Pz, 'SideLockProf'..sLineMachineSuffix, nSideOppoType) + -- scrivo nota lavorazione lato top + EgtSetInfo( Pz, 'SideTopMach'..sLineMachineSuffix, nTopMach) + -- scrivo nota tipo profilo lato top + EgtSetInfo( Pz, 'SideTopProf'..sLineMachineSuffix, nTopType) + -- scrivo nota lavorazione lato bottom + EgtSetInfo( Pz, 'SideBottomMach'..sLineMachineSuffix, nBottomMach) + -- scrivo nota tipo profilo lato bottom + EgtSetInfo( Pz, 'SideBottomProf'..sLineMachineSuffix, nBottomType) + -- scrivo la nota relativa al controllo collisioni + EgtSetInfo( Pz, 'EnableCollisionDetect', tMainTabPar.ECD) + -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) + EgtSetInfo( Pz, 'NumProbeZ'..sLineMachineSuffix, nNumProbeZ) + -- assegno al gruppo di lavoro la lunghezza minima porta + EgtSetInfo( Pz, 'LongDoorLimit'..sLineMachineSuffix, tMainTabPar.BDH) + -- scrivo nota flag modalita remove scrap + EgtSetInfo( Pz, 'RemoveScrapMode'..sLineMachineSuffix, tMainTabPar.RSM) + + -- sommo il delta spostamento + Ori = Ori + vExtraYDelta + + local nLeftCode, nRightCode = MCH_CR.BL, MCH_CR.BR + if nDispFront < 0 then + nLeftCode, nRightCode = MCH_CR.TL, MCH_CR.TR + end + + -- Muovo porta con l'angolo indicato dal tipo di disposizione nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, EgtIf( nDispMode > 0, nLeftCode, nRightCode)) + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + EgtSetInfo( Pz, 'MachineNameFromCurrCamInfo'..sLineMachineSuffix, tMainTabPar.MN) + if bShiftedDoor then + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'DoorOnTable' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'SHIFT') + -- se porta disposta con lato lock contro riferimenti stampo lo shift del lato lock + if ( tMainTabPar.SDF > 1 and tMainTabPar.SDF < 4) or nDispFront < 0 then + EgtSetInfo( Pz, 'OffSetPhase' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) + -- altrimenti porta disposta con lato hinge contro riferimenti stampo lo shift del lato hinge + else + EgtSetInfo( Pz, 'OffSetPhase' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShift) + end + else + -- salvo una nota con le info della disposizione normale + EgtSetInfo( Pz, 'DoorOnTable' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'NORMAL') + EgtSetInfo( Pz, 'OffSetPhase' .. sLineMachineSuffix .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) + end + + if bFlip then -- se porta capovolta + if bTopOnRight then -- se top a destra + -- se prima macchina, il lato sinistro è quello riferito, se seconda macchina è quello destro + OffsYSovr = EgtIf( nDispFront > 0, dLeftOffs, dRightOffs) + OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- se prima macchina, il lato destro è quello riferito, se seconda macchina è quello sinistro + OffsYSovr = EgtIf( nDispFront > 0, dRightOffs, dLeftOffs) + OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) + end + else -- altrimenti non è capovolta + if bTopOnRight then -- se top a destra + -- se prima macchina, il lato destro è quello riferito, se seconda macchina è quello sinistro + OffsYSovr = EgtIf( nDispFront > 0, dRightOffs, dLeftOffs) + OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- se prima macchina, il lato sinistro è quello riferito, se seconda macchina è quello destro + OffsYSovr = EgtIf( nDispFront > 0, dLeftOffs, dRightOffs) + OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) + end + end + + -- Controllo dimensioni pezzo + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + vShift:getX(), vShift:getY(), tMainTabPar.MnDL, tMainTabPar.MxDL, tMainTabPar.MnDW, + tMainTabPar.MxDW, tMainTabPar.MnDT, tMainTabPar.MxDT) + + if bFailDim then + + DGD.ERR = 19 + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( DGD.EMC, 0) + EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + + ------------------------------------------------------------------------------------------------------------- + -- abilito/disabilito geometrie probe in base alla lavorazione del lato hinge e alla disposizione sulla tavola + ------------------------------------------------------------------------------------------------------------- + if bHingeMach then -- se profilo hinge è da lavorare rinomino nome entita + + -- Recupero le entità probe + local ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Hinge_Probe') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Hinge_Probe_POS') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Hinge_Probe_NEG') + end + + -- Recupero le entità pivot + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Pivot_Probe') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Pivot_Probe_POS') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Pivot_Probe_NEG') + end + + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- profilo hinge non lavorato + else + -- il probe deve essere sempre quello a sinistra rispetto al piazzamento + -- considerando lo swing perché le cerniere a seconda di questo vengono ruotate e il probe _POS e _NEG risultano + -- scambiati rispetto al top della porta + local sProbeHingeToFind = '' + local sProbeHingeDis = '' + local sProbePivotToFind = '' + local sProbePivotDis = '' + + if nDispMode > 0 then -- se disposizione a sinistra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + else + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + end + sProbePivotToFind = 'Pivot_Probe_NEG' + sProbePivotDis = 'NO_Pivot_Probe_NEG' + else -- disposizione a destra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + else + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + end + sProbePivotToFind = 'Pivot_Probe_POS' + sProbePivotDis = 'NO_Pivot_Probe_POS' + end + local ProbeList = MB.FindEntitiesWithName( Pz, sProbeHingeToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbeHingeDis) + end + ProbeList = MB.FindEntitiesWithName( Pz, sProbePivotToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbePivotDis) + end + -- se non da lavorare e profilo bevel dn cambio lo spessore a: spessore probe + extra probe z + if sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif sHingeTrim == '1B' or sHingeTrim == '2B' or sHingeTrim == '3B' or sHingeTrim == '4B' or + sHingeTrim == '5B' or sHingeTrim == '6B' or sHingeTrim == '7B' or sHingeTrim == '8B' then + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + else + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + end + + if bLockMach then -- se profilo lock è da lavorare rinomino nome entita + + -- Recupero le entità probe + local ProbeList = MB.FindEntitiesWithName( Pz, 'Shuttle_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Shuttle_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Shuttle_Probe') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Shuttle_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Shuttle_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Shuttle_Probe_POS') + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Shuttle_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Shuttle_Probe' ) + EgtSetInfo( ProbeList[j], 'OriName', 'Shuttle_Probe_NEG') + end + + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- profilo lock non lavorato + else + + -- il probe deve essere sempre quello a sinistra rispetto al piazzamento + -- considerando lo swing perché le cerniere a seconda di questo vengono ruotate e il probe _POS e _NEG risultano + -- scambiati rispetto al top della porta + local sProbeLockToFind = '' + local sProbeLockDis = '' + + if nDispMode > 0 then -- se disposizione a sinistra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeLockToFind = 'Shuttle_Probe_NEG' + sProbeLockDis = 'NO_Shuttle_Probe_NEG' + else + sProbeLockToFind = 'Shuttle_Probe_POS' + sProbeLockDis = 'NO_Shuttle_Probe_POS' + end + else -- disposizione a destra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeLockToFind = 'Shuttle_Probe_POS' + sProbeLockDis = 'NO_Shuttle_Probe_POS' + else + sProbeLockToFind = 'Shuttle_Probe_NEG' + sProbeLockDis = 'NO_Shuttle_Probe_NEG' + end + end + local ProbeList = MB.FindEntitiesWithName( Pz, sProbeLockToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbeLockDis) + end + -- se profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + if sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK' then + + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK' or + sLockTrim == '5B_LK' or sLockTrim == '6B_LK' or sLockTrim == '7B_LK' or sLockTrim == '8B_LK' then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + else + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + end + + if bTopMach then -- se profilo top è da lavorare rinomino nome entita + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not bTopMach and ( sTopTrim == 'BD' or sTopTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not bTopMach and ( sTopTrim == '1B' or sTopTrim == '2B' or sTopTrim == '3B' or sTopTrim == '4B' or + sTopTrim == '5B' or sTopTrim == '6B' or sTopTrim == '7B' or sTopTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not bTopMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sTopTrim == 'BU' or sTopTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + if bBottomMach then -- se profilo top è da lavorare rinomino nome entita + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not bBottomMach and ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not bBottomMach and ( sBottomTrim == '1B' or sBottomTrim == '2B' or sBottomTrim == '3B' or sBottomTrim == '4B' or + sBottomTrim == '5B' or sBottomTrim == '6B' or sBottomTrim == '7B' or sBottomTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not bBottomMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sBottomTrim == 'BU' or sBottomTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + -- *** Lavorazioni *** + -- setto variabili in funzione della disposizione porta + local bMakeGhost = true + -- se esiste la forzatura sulla direzione lavorazione cerniere + if tMainTabPar.FDMH and abs( tMainTabPar.FDMH) == 1 then + nDirReorderGroups = tMainTabPar.FDMH + -- altrimenti come in precedenza, in base alla disposizione lato top porta + else + nDirReorderGroups = nDispMode + end + local dPercentDoorLength + --------------------------------------------------------------------------------------------------------------------------- + -- 06/05/2021 in base al seguente avvenimento: porta lunga 3025 con 4 cerniere, 2 per ogni shuttle, e con una groove che + -- sborda sul lato cerniere. Alla chiamata della DANGER_L (nel Processo4) lo shuttle 1 a sinistra chiede di parcheggiare + -- nella posizione calcolata (L88) nel P5INIT che è a pacco con lo shuttle 2 nella parte destra della porta. L'arbitro non + -- da il consenso al parcheggio perchè la posizione è ancora occupata dallo shuttle 2 che sta lavorando e quindi manda + -- in parcheggio lo shuttle 1 fuori (tutto a sinistra) ma che, data la lunghezza elevata della porta, quando il gruppo 4 + -- andando a lavorare la groove vicino al lato hinge, rischia di collidere con lo shuttle 1. + -- Quindi per ovviare al problema è stato stabilito, in accordo con Carlo Viviani, di controllare per prima + -- la dimensione della porta, e se la lunghezza porta è maggiore del valore stabilito nella macro P5INIT nella variabile + -- L116 (ad oggi al valore 1800mm) allora la percentuale di distribuzione cerniere passa a 45% (su questa macchina) dalla + -- parte dove la porta è riferita (cioè 45% da sinistra se porta disposta a sinistra, 45% da destra se porta riferita a destra), + -- in questo modo lo shuttle più vicino al riferimento porta lavora meno dello shuttle opposto così, se viene chiamato + -- un danger sul lato opposto al riferimento ci sono più probabilità che lo shuttle vicino al riferimento abbia già finito + -- e la richiesta di parcheggio interno per lo shuttle opposto trova lo spazio disponibile. + --------------------------------------------------------------------------------------------------------------------------- + if dLengthDoor >= tMainTabPar.BDH then + dPercentDoorLength = 0.45 -- 45% sempre dalla parte dove è riferita -- EgtIf( nDispMode > 0, 0.52, 0.48) + else + ------------------------------------------------------------------------------------------------------------------------------------------ + -- V1.4 Gestione percentuali portata nel CurrCamInfo dai nuovi parametri .PS3H (.PercentUseShtlWith3Hrdw) e .PUSR (.PercentUseShuttleFromRef) se presenti + ------------------------------------------------------------------------------------------------------------------------------------------ + -- quanto viene dopo è stato cambiato + -- Su richiesta del cliente (Adam Linch) in data 06/12/2017 la ripartizione delle tre cerniere è la seguente: + -- 2 cerniere allo shuttle corrispondente al lato di riferimento porta. V1.3 + -- quanto viene dopo è stato cambiato + -- assegno una percentuale di 0.6 sempre verso lo shuttle di sinistra (Viviani 30/01/2017) + -- se disposta a sinistra assegno 0.6 da sinistra, se disposta a destra assegno 0.4 da destra, il risultato è quindi + -- sempre 0.6 da sinistra + -- ma con 3 cerniere o 3 pivot, inverto la percentuale, cioè sempre 0.4 da sinistra V1.2 + -- V1.1 + --local dPercentDoorLength = EgtIf( nDispMode > 0, 0.6, 0.4) -- V1.1 + -- V1.2 + --local dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.4, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) -- V1.2 + -- V1.3 + -- dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.6, 0.4), EgtIf( dNumHingesPivots == 3, 0.6, 0.4)) -- V1.3 + + -- V1.4 + if tMainTabPar.PS3H <= GEO.EPS_SMALL or tMainTabPar.PS3H >= (1-GEO.EPS_SMALL) then + tMainTabPar.PS3H = 0.6 + end + if tMainTabPar.PUSR <= GEO.EPS_SMALL or tMainTabPar.PUSR >= (1-GEO.EPS_SMALL) then + tMainTabPar.PUSR = 0.4 + end + -- V1.4 + dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 , tMainTabPar.PS3H, tMainTabPar.PUSR), EgtIf( dNumHingesPivots == 3, tMainTabPar.PS3H, tMainTabPar.PUSR)) + end + + -- Se uso shuttle forzato su uno dei due shuttle cambio la percentuale + if tMainTabPar.FUS then + if tMainTabPar.FUS == 1 then + dPercentDoorLength = EgtIf( nDispMode > 0, 1, 0) + elseif tMainTabPar.FUS == 2 then + dPercentDoorLength = EgtIf( nDispMode > 0, 0, 1) + else + tMainTabPar.FUS = 0 + end + else + tMainTabPar.FUS = 0 + end + + -- scrivo la nota + EgtSetInfo( Pz, 'ForceShuttle'..sLineMachineSuffix, tMainTabPar.FUS) + -- calcolo una direzione locale perchè se ha segno opposto e la porta è disposta sul lato opposto, viene fatto un errore nel calcolo della posizione di scambio + local nLocalDirReorderGroup = EgtIf( nDirReorderGroups == nDispMode, nDirReorderGroups, -nDirReorderGroups) + + -- quanto segue nella sottostante spiegazione è stato cambiato, vedi sopra + ---- determino la posizione del cambio shuttle utilizzando un coefficente di 0.4 verso destra se il posizionamento è a destra + ---- e un coefficente di 0.6 verso destra se il posizionamento è a sinistra, in modo + ---- da favorire lo shuttle che è dalla parte del riferimento ( a destra con assegnazione nMach a 2 e a sinistra con assegnazione nMach a 3) + dPosShuttleChange = EgtIf( nDispMode > 0, tMainTabPar.OR1:getX(), tMainTabPar.OR2:getX()) + ( dLengthDoor * dPercentDoorLength * nLocalDirReorderGroup) + ( OffsXSovr * nLocalDirReorderGroup) + tabOri:getX() + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + local tOrderGrp = {} + + -- print Machining table + -- solo il primo giro: aggiusto i profili bevel per essere coerente con la sequenza di tabella + -- riordino i gruppi geometrici che hanno l'operazione AdjustHead o AdjustHeadOnASplint in ordine di X decrescente + for i = 1, #tLocMach do + + -- print Machining table + DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper then + if tLocMach[i].Oper == 'AdjustBevel' then + local sNewName + _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP) + elseif tLocMach[i].Oper == 'AdjustHead' or tLocMach[i].Oper == 'AdjustHeadOnASplint' then + -- nDirReorderGroups = -1 = ordine decrescente ( da dx a sx <--); nDirReorderGroups = 1 ordine crescente ( da sx a dx -->) + MB.ReorderGroup( EntList[j], tOrderGrp, nDirReorderGroups) + -- Nuova ma non va bene + -- MB.ReorderGroup( EntList[j], tOrderGrp, EgtIf( nDispMode > 0 , - nDirReorderGroups, nDirReorderGroups)) -- sempre decrescente; + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + nValAppo = nNumGeomBottomHole + nNumGeomBottomHole = nNumGeomTopHole + nNumGeomTopHole = nValAppo + end + -- resetto la variabile globale del campo Link della Mtable + DGD.LVL = nil + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = 1, #tLocMach do + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + + local bAdjustHead = false + local nNewIdEnt + + -- acquisisco il campo Link se è presente + DGD.LVL = tonumber( tLocMach[i].Link) + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' then + + local sNewName + bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP, bMakeGhost) + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' then + + local bInvertOnZPos = false + + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if string.lower( sEdge) == 'left' then + if bAtRight then + if sHingeTrim == 'CV' then + bInvertOnZPos = true + end + elseif not bAtRight then + if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + bInvertOnZPos = true + end + end + elseif string.lower( sEdge) == 'right' then + if bAtRight then + if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + bInvertOnZPos = true + end + elseif not bAtRight then + if sHingeTrim == 'CV' then + bInvertOnZPos = true + end + end + elseif string.lower( sEdge) == 'top' then + if sTopTrim == 'CV' then + bInvertOnZPos = true + end + elseif string.lower( sEdge) == 'bottom' then + if sBottomTrim == 'CV' then + bInvertOnZPos = true + end + end + + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true, bInvertOnZPos) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- se link non esiste o non ha valore negativo allora stampo il messaggio + if not DGD.LVL or DGD.LVL >= 0 then + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + else -- se è andata a buon punto vedo di sottrarle ai contatori degli skip + if nMach == 1 then + if nNumGeomTop > 0 then + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottom > 0 then + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustProbeMill' and nProbeMode == 0 and nPostProbeSet > 2 then + local sMachRetured + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeMill( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, + bFirstStep, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, tMainTabPar.PTK, + tMainTabPar.EZPB) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + if bOk then + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + elseif nMach == 3 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 13) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + end + -- se link non esiste o non ha valore negativo allora stampo il messaggio + if not DGD.LVL or DGD.LVL >= 0 then + -- se nome lavorazione non nullo, incremento i contatori + if sMachRetured then + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + else -- se è andata a buon punto setto nota alla porta + EgtSetInfo( Pz, 'ExistsProbeXY'..sLineMachineSuffix, true) -- presenza del probe in XY + end + else + EgtSetInfo( nNewIdEnt, 'Mach', 31) + end + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillX' then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true, 0) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillY' then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true, 0) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' then + bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBevelChisel' then + bLocMach,_, nNewIdEnt = MB.AdjustBevelChisel( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, CHISEL_ONLY_HORZNT) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadChisel' then + bLocMach, nNewIdEnt, nNumMachSkipResult = MB.AdjustHeadChisel( EntList[j], bMakeGhost, CHISEL_ONLY_HORZNT, nNumMachSkip, NO_WORK_UPSQUARE, NO_WORK_UNDERSQUARE) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- se link non esiste o non ha valore negativo allora stampo il messaggio + if not DGD.LVL or DGD.LVL >= 0 then + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + else -- se è andato a buon fine, verifico di sottrarlo alle variabili skip + if nMach == 1 then + if nNumGeomTopHole > 0 then + nNumGeomTopHole = nNumGeomTopHole - 1 + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottomHole > 0 then + nNumGeomBottomHole = nNumGeomBottomHole - 1 + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustHole' then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and not ( nProbeMode == 1 and nNewProbeMeaning == 0) then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustProbeHole' and nProbeMode == 1 then + local sMachRetured + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, + bFirstStep, false, bMakeGhost) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + if nMach == 11 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 12 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 13 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw}) + end + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo AdjustProbeHole non dovrebbe restituire il 3 + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile setto la nota sul pezzo + if bInsLav then + EgtSetInfo( Pz, 'ExistsProbeZ', true) -- presenza del probe in Z + else -- altrimenti la lavorazione non è applicabile + + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp}) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach}) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw}) + end + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + + -- se link non esiste o non ha valore negativo allora stampo il messaggio + if not DGD.LVL or DGD.LVL >= 0 then + -- se lavorazione presente incremento il numero di lavorazioni da sotto + if sMachRetured then + nNumGeomBottom = nNumGeomBottom + 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustHead' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHead( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadOnASplint' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHeadOnASplint( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nil, + nDispMode, bFlip, MAXMACH) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then + bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustASplintWithBlade' then + bOk, nNewIdEnt = MB.AdjustASplintWithBlade( EntList[j], bMakeGhost, nDispMode, bFlip) + elseif tLocMach[i].Oper == 'AdjustSplitDoor' and not ( nProbeMode == 1 and nNewProbeMeaning == 0) then + if not bGetSplitCuts then + tSplitDoorEnt = EntList + table.insert( tSplitDataInf, { tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, nNumMach, bMakeGhost}) + bGetSplitCuts = true + end + elseif tLocMach[i].Oper == 'AdjustConeCleanPaths' and not ( nProbeMode == 1 and nNewProbeMeaning == 0) then + bOk, nNewIdEnt = MB.AdjustConeCleanPaths( EntList[j], bMakeGhost, nil, Ls) + elseif tLocMach[i].Oper == 'AdjustVertAsOnHeads' and not ( nProbeMode == 1 and nNewProbeMeaning == 0) then + bLocMach, nNewIdEnt = MB.AdjustVertAsOnHeads( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + end + else -- se nessuna operazione + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + end + + -- LAVORAZIONI + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + if bAdjustHead and nMach > 0 and nMach < 4 then -- se navette + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = FindAndCalcGroupMachining( EntList[j], nNewIdEnt, tLocMach, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, tMainTabPar.BPLI, tMainTabPar.PRF, + (nDispFront < 0)) + elseif nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, + NOT_GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF, nNumMachFromTable) + else + if not bAdjustHead then + -- se link non esiste o non ha valore negativo allora stampo il messaggio + if not DGD.LVL or DGD.LVL >= 0 then + local nTempMach = nMach + local sMachName = '' + if nTempMach >= 10 then + nTempMach = nTempMach - 10 + end + + if nTempMach == 3 then + sMachName = tLocMach[i].MachDw + elseif nTempMach == 2 then + sMachName = tLocMach[i].MachUp + elseif nTempMach == 1 then + sMachName = tLocMach[i].Mach + end + + DoorOutLog( EgtDoorsMsg[497]..tostring( EgtIf( nNewIdEnt, nNewIdEnt, EntList[j]))..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. + sMachName .. EgtDoorsMsg[596]..tostring( nNumPhase), -1) + -- se lavorazione compresa nella Mtable + if nTempMach > 0 and nTempMach < 4 then + DGD.ERM = DGD.ERM .. EgtIf( #DGD.ERM > 0, '\n', '') .. EgtDoorsMsg[497]..tostring( EgtIf( nNewIdEnt, nNewIdEnt, EntList[j]))..' '.. + tLocMach[i].Name.. EgtDoorsMsg[595].. sMachName .. EgtDoorsMsg[596]..tostring( nNumPhase)..'\n' + end + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end + end + + local i = 1 + while i <= #tLocMachOrd do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGrp = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) + + if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0 + + if sProperty == 'MinDist' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local tMachining = {} + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..DGD.GHT) + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se lavorazione esiste e corrisponde e numero lavorazione è = 1 + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, tMachining, tMainTabPar.BPLI, tMainTabPar.PRF, nNumMachFromTable) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + elseif sProperty == 'Shuttle' then -- lavorazione con shuttle + + -- per ogni layer padre nella lista fatta con il reordergroup + for k = 1, #tOrderGrp do + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( tOrderGrp[k][1], true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, tOrderGrp[k][1], tGroup, nMach, nNumGrp, + nNumMach, bOk, DGD.GHT, tMainTabPar.MDC, EndLastMach, + tMainTabPar.BPLI, tMainTabPar.PRF, nNumMachFromTable) + end + elseif sProperty == 'Layer' then -- lavorazione layer + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, DGD.GHT) + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, + nNumMach, bOk, DGD.GHT, tMainTabPar.MDC, EndLastMach, + tMainTabPar.BPLI, tMainTabPar.PRF, nNumMachFromTable) + end + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..DGD.GHT) + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF, nNumMachFromTable) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + end + elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore + DGD.ERR = -15 + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + if DGD.ERM and #DGD.ERM > 0 then + DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + end + + i = i + 1 + end + + -------------------------------------------------------------------------------------------------------- + -- elimino eventuali lavorazioni di side probe che non hanno lavorazioni nel layer a cui appartiene + -------------------------------------------------------------------------------------------------------- + + -- se ho cancellazione percorsi probe side ( che indica gestione macchine in linea) + if tMainTabPar.DSPP > 0 then + + local PrevMch = EgtGetPhaseDisposition( nNumPhase) + local nOperId = EgtGetNextOperation( PrevMch) + + while nOperId do + + local bDeletedMach = false + -- solo sulle contornature + if EgtGetOperationType( nOperId) == MCH_OY.MILLING then + -- prendo la geometria della lavorazione + EgtSetCurrMachining( nOperId) + local Geo = EgtGetMachiningGeometry() + -- se restituisce una tabella coerente + if type(Geo) == 'table' and type(Geo[1]) == 'table' and Geo[1][1] and Geo[1][1] > 0 then + nPath = Geo[1][1] + -- prendo il nome della geometria + local sNameGeom = EgtGetName( nPath) + -- se è una side probe + if string.find( sNameGeom, 'ProbeSidePoint' .. DGD.GHT) then + -- acquisisco l'id del layer + local nLayerId = EgtGetParent( nPath) + -- cerco nel layer tutte le entità che sono state lavorate e che dalle note risultano lavorate con la macchina corrente + local Ent = EgtGetFirstInGroup( nLayerId) + local bFound = false + while Ent and not bFound do + if Ent ~= nPath then + local nProbeSideFlag = EgtGetInfo( Ent, 'ProbeSide', 'i') or 0 + local nMachineId = EgtGetInfo( Ent, 'IdMachine', 'i') or 0 + local sNameEnt = EgtGetName( Ent) + -- verifico se hanno entrambe le note che indicano la lavorazione presente + if nProbeSideFlag == 1 and nMachineId == nNumMachFromTable then + -- flag indice presenza lavorazione, non cancella la lavorazione di side probe + bFound = true + end + end + Ent = EgtGetNext( Ent) + end + -- se non ho trovato lavorazioni elimino la side probe machining + if not bFound then + local nMachToDel = nOperId + nOperId = EgtGetNextOperation( nOperId) + EgtRemoveOperation( nMachToDel) + bDeletedMach = true + end + end + end + end + if not bDeletedMach then + -- Passo alla operazione successiva + nOperId = EgtGetNextOperation( nOperId) + end + end + + -- riparto per le lavorazioni di probe in Z + nOperId = EgtGetNextOperation( PrevMch) + + while nOperId do + + local bDeletedMach = false + -- solo sulle contornature + if EgtGetOperationType( nOperId) == MCH_OY.DRILLING then + -- prendo la geometria della lavorazione + EgtSetCurrMachining( nOperId) + local Geo = EgtGetMachiningGeometry() + -- se restituisce una tabella coerente + if type(Geo) == 'table' and type(Geo[1]) == 'table' and Geo[1][1] and Geo[1][1] > 0 then + nPath = Geo[1][1] + -- prendo il nome della geometria + local sNameGeom = EgtGetName( nPath) + -- se è una probe in Z + if string.find( sNameGeom, 'ProbePoint' .. DGD.GHT) then + -- acquisisco l'id del layer + local nLayerId = EgtGetParent( nPath) + -- cerco nel layer tutte le entità che sono state lavorate e che dalle note risultano lavorate con la macchina corrente + local Ent = EgtGetFirstInGroup( nLayerId) + local bFound = false + while Ent and not bFound do + if Ent ~= nPath then + local sProbeFlag = EgtGetInfo( Ent, 'KeepBackSet', 's') or '' + local nMachineId = EgtGetInfo( Ent, 'IdMachine', 'i') or 0 + local sNameEnt = EgtGetName( Ent) + -- verifico se hanno entrambe le note che indicano la lavorazione presente + if #sProbeFlag >= 1 and nMachineId == nNumMachFromTable then + -- flag indice presenza lavorazione, non cancella la lavorazione di side probe + bFound = true + end + end + Ent = EgtGetNext( Ent) + end + -- se non ho trovato lavorazioni elimino la side probe machining + if not bFound then + local nMachToDel = nOperId + nOperId = EgtGetNextOperation( nOperId) + EgtRemoveOperation( nMachToDel) + bDeletedMach = true + end + end + end + end + if not bDeletedMach then + -- Passo alla operazione successiva + nOperId = EgtGetNextOperation( nOperId) + end + end + end + + ---------------------------------------- + -- Inserimento riferimenti e ventose + ---------------------------------------- + + -- Offset ventose da bordo pezzo in Y + dVacOffs = tMainTabPar.VOY + -- Offset barra riferimenti mobile da riferimenti quando posizione 0 + dMobOffs = tMainTabPar.MOY + dVacOffs + -- Lunghezza minima per alzare prima ventosa da bordo sinistro + dDistMinX = tMainTabPar.LDX + 40 + DIST_MIN_VAC_L -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Lunghezza minima per alzare prima ventosa da bordo destro + dDistMaxX = tMainTabPar.RDX + 40 + DIST_MIN_VAC_R -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Posizione ventose in alto + dVacOn = 110 + -- Interasse ventose + dInterAx = 232 + -- distanza interferenza con cave passanti + dDistInterferThru = 42 + tMainTabPar.DTG -- modificato da 20 a 12 il 26/10/2017 su richiesta di Mark + dDistInterferBlind = 42 + tMainTabPar.DBG + dDistInterferUnder = 42 + tMainTabPar.DUG + + -- Ventose + local nTabId = EgtGetTableId( 'Tab') + local nMobId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE') + local nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') + local nDispId = EgtGetPhaseDisposition( nNumPhase) + -- se gruppi richiesti non trovati + if not nMobId or not nFixId then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' + break + end + -- Posizionamento barra mobile + local dOldVal = EgtGetInfo( nMobId, 'Val', 'd') + -- calcolo nuova posizione con: larghezza finita porta ( uso getDimX perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento in basso - distanza ventose - offset barra + local dNewVal = b3Solid:getDimX() + OffsYSovr + vShift:getY() + vShiftVac:getY() - dVacOffs - dMobOffs + -- controllo che la posizione non supera la posizione massima raggiungibile dalla barra mobile + if dNewVal > tMainTabPar.MPMB then + dNewVal = tMainTabPar.MPMB + end + if nDispFront > 0 then + EgtMove( nMobId, Vector3d( 0, dNewVal - dOldVal, 0), GDB_RT.GLOB) + else + EgtMove( nMobId, Vector3d( 0, dOldVal - dNewVal, 0), GDB_RT.GLOB) + end + EgtSetInfo( nMobId, 'Val', dNewVal) + EgtSetInfo( nDispId, 'MOB', dNewVal) + -- posizionamento barra mobile e fissa in X + -- disposizione a sinistra + if nDispMode > 0 then + dOldVal = EgtGetInfo( nFixId, 'ValXL', 'd') + dNewVal = tMainTabPar.LDX + if dOldVal and dNewVal then + EgtMove( nFixId, Vector3d( dNewVal - dOldVal, 0, 0), GDB_RT.GLOB) + EgtMove( nMobId, Vector3d( dNewVal - dOldVal, 0, 0), GDB_RT.GLOB) + EgtSetInfo( nFixId, 'ValXL', dNewVal) + EgtSetInfo( nDispId, 'MOBL', dNewVal) + end + -- disposizione a destra + else + dOldVal = EgtGetInfo( nFixId, 'ValXR', 'd') + dNewVal = tMainTabPar.RDX + if dOldVal and dNewVal then + EgtMove( nFixId, Vector3d( dOldVal - dNewVal, 0, 0), GDB_RT.GLOB) + EgtMove( nMobId, Vector3d( dOldVal - dNewVal, 0, 0), GDB_RT.GLOB) + EgtSetInfo( nFixId, 'ValXR', dNewVal) + EgtSetInfo( nDispId, 'MOBR', dNewVal) + end + end + + -- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa + local dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( nDispMode > 0, dDistMinX, dDistMaxX) + + -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto + StartVacVerify( Ls, bFlip, dThickDoor) + + -- verifico se presente groove applicato a top su angolo + local sAngGrooveNote = EgtGetInfo( Pz, 'GrooveOnAngle', 's') + + -- ciclo sulle ventose + local nInd = 1 + local nIndVac + local nNumTotVacRow = 13 + local nCountFailed = 0 + local nIniFailed = 0 + local nMiddleFailed = 0 + local nEndFailed = 0 + local nMaxIniFailed = 0 + local nMaxMiddleFailed = 0 + local nMaxEndFailed = 0 + + while dCalcLen > 0 and nInd <= nNumTotVacRow do + + nIndVac = EgtIf( nDispMode > 0, nInd, ( nNumTotVacRow - nInd + 1)) + + local sInd = tostring( nIndVac) + + -- eseguo verifica + local nCenFixId = EgtGetFirstNameInGroup( nFixId, 'CEN'..sInd) + local pPntFix = EgtSP( nCenFixId, GDB_ID.ROOT) + local bCanUpFix = ExecVacVerify( pPntFix, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), + Ls, bFlip, nCenFixId) + local nCenMobId = EgtGetFirstNameInGroup( nMobId, 'CEN'..sInd) + local pPntMob = EgtSP( nCenMobId, GDB_ID.ROOT) + local bCanUpMob = ExecVacVerify( pPntMob, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), + Ls, bFlip, nCenMobId) + -- eventuale movimento + if bCanUpFix and bCanUpMob then + + local nIdFix = AddMoveShowHideVac( KIND_DISP_MODE, nFixId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, 'VAC_D80', ( pPntFix - tabOri)) + local nIdMov = AddMoveShowHideVac( KIND_DISP_MODE, nMobId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, 'VAC_D80', ( pPntMob - tabOri)) + + -- salvo lo stato e info modalità disposizione + EgtSetInfo( nDispId, 'VAC'..sInd, dVacOn) + EgtSetInfo( nDispId, 'KIND_DISP_MODE'..sInd, KIND_DISP_MODE) +-- EgtSetInfo( nDispId, 'FIXIDS'..sInd, nIdFix) +-- EgtSetInfo( nDispId, 'MOBIDS'..sInd, nIdMov) + EgtSetInfo( nDispId, 'FIXPOS'..sInd, ( pPntFix - tabOri)) + EgtSetInfo( nDispId, 'MOBPOS'..sInd, ( pPntMob - tabOri)) + -- interrompo le serie negative + if nInd > 1 then + nCountFailed = 0 + if nMaxIniFailed < nIniFailed then + nMaxIniFailed = nIniFailed + end + if nMaxMiddleFailed < nMiddleFailed then + nMaxMiddleFailed = nMiddleFailed + end + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nIniFailed = 0 + nMiddleFailed = 0 + nEndFailed = 0 + end + else + EgtRemoveInfo( nDispId, 'VAC'..sInd) + EgtRemoveInfo( nDispId, 'KIND_DISP_MODE'..sInd) + AddMoveShowHideVac( 2, nFixId, 'VAC'..sInd) -- rendo visibile ventosa + AddMoveShowHideVac( 2, nMobId, 'VAC'..sInd) -- rendo visibile ventosa + + nCountFailed = nCountFailed + 1 + if nInd == 1 then -- setto solo il fallimento iniziale + nIniFailed = nCountFailed + elseif nInd == nNumTotVacRow or ( dCalcLen - dInterAx) <= 0 then -- setto solo quello finale e annullo il medio + nEndFailed = nCountFailed + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nMiddleFailed = 0 + else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati + if nIniFailed > 0 then + nIniFailed = nCountFailed + elseif nEndFailed > 0 then + nEndFailed = nCountFailed - 1 + else + nMiddleFailed = nCountFailed + end + end + end + -- aggiorno la lunghezza di calcolo e l'indice + dCalcLen = dCalcLen - dInterAx + nInd = nInd + 1 + end + -- elimino geometrie per verifica + EndVacVerify() + + -- riassegno la quantità di file che effettivamente potrebbero essere alzate + nInd = nInd - 1 + + -- casi di scarse ventose + if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then -- tutte le ventose basse + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + elseif nInd > 0 and nMaxIniFailed / nInd > 0.35 then -- ventose iniziali ( parte destra) + local nNumMsg = EgtIf( nDispMode > 0, 532, 534) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then -- ventose intermedie + DGD.EMC = ' ' .. EgtDoorsMsg[533] + bOk = false + break + elseif nInd > 0 and nMaxEndFailed / nInd > 0.35 then -- ventose finale ( parte sinistra) + local nNumMsg = EgtIf( nDispMode > 0, 534, 532) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then -- somma di vari intervalli + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + end + + ------------------------------------------------- + -- gestione messaggi LIGHT: red, yellow, green + ------------------------------------------------- + + -- se ho geometrie da entrambe le parti la luce è red + if nNumGeomBottom > 0 and nNumGeomTop > 0 then + sLight = 'RED' + -- se non ho geometrie la luce è green + elseif nNumGeomBottom == 0 and nNumGeomTop == 0 then + sLight = 'GREEN' + -- se una delle due ha delle geometrie + else + -- in caso di geometrie tutte sotto luce yellow + if nNumGeomBottom > 0 then + sLight = 'YELLOW' + -- in caso di geometrie tutte sopra luce green + elseif nNumGeomTop > 0 then + sLight = 'GREEN' + end + end + + -- *** Tools Setup *** + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + local bSetUp = EgtImportSetup() + local tListError + local sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + end + + -- se fallito quello di default o utensili mancanti provo quello indicato nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + local nContImport = 0 + + -- ciclo tra quelli disponibili + for k = 1, 8 do + + if not bSetUp then + if k == 1 then + sSetup = mCamData[nNumMachFromCam].Setup1 + elseif k == 2 then + sSetup = mCamData[nNumMachFromCam].Setup2 + elseif k == 3 then + sSetup = mCamData[nNumMachFromCam].Setup3 + elseif k == 4 then + sSetup = mCamData[nNumMachFromCam].Setup4 + elseif k == 5 then + sSetup = mCamData[nNumMachFromCam].Setup5 + elseif k == 6 then + sSetup = mCamData[nNumMachFromCam].Setup6 + elseif k == 7 then + sSetup = mCamData[nNumMachFromCam].Setup7 + elseif k == 8 then + sSetup = mCamData[nNumMachFromCam].Setup8 + end + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + if bSetUp then -- se importato il fle da CurrCamInfo + nContImport = nContImport + 1 + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + break + else -- se utensili mancanti prendo la lista e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else -- se non importato carico il messaggio di errore e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + end + end + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + if ( sDefSetUp and #sDefSetUp > 0) or + nContImport > 0 then + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] + else + DGD.EMC = ' ' .. EgtDoorsMsg[551] + end + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + break + else -- setup default non definito + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + else -- ha importato il file da CurrCamInfo + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- se utensili mancanti + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', 1) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + DGD.EMC = DGD.EMC .. sListTool + bOk = false + break + end + end + end + + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + -- per interrompere il giro forzatamente ( perché nessun ribaltamento) setto bWork + bWork = false + end + + nNumCycle = nNumCycle + 1 + + -- se deve uscire dal ciclo, prima di farlo, eseguo l'eventuale split della porta + if not bWork then + + -- gestione taglio longitudinale split door + -- assegnamento variabili + + -- se è una porta e nessuna lavorazione da sotto + if not sAssemb and nNumGeomBottom == 0 then + + local EntList = tSplitDoorEnt + + if #EntList == 1 then + -- acquisisco nota direzione taglio e la confronto con il parametro del currcaminfo + local sDirCut = EgtGetInfo( EntList[1], 'DirectionCut', 's') + if sDirCut and + ( ( sDirCut == 'H' and string.find( tMainTabPar.CDA, 'H')) or + ( sDirCut == 'W' and string.find( tMainTabPar.CDA, 'W'))) then + + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[1], tSplitDataInf[1][7]) + + if bLocMach then + + local bInsLav = false + + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + nLocMach = nMach + if nMach == 1 then + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tSplitDataInf[1][1], tSplitDataInf[1][2], tSplitDataInf[1][3], + tSplitDataInf[1][4], tSplitDataInf[1][5], bOk, tSplitDataInf[1][6], false, + NGEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + end + else + bOk = false + end + end + -- se ho più di un taglio do errore + elseif #EntList > 1 then + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + else + EgtOutBox( EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + else + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[695], 0) + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + end + end + end -- end while + + local nNoMach + -- se ho una luce faccio una ulteriore verifica sul numero delle lavorazioni + if sLight then + + local PrevMch = EgtGetPhaseDisposition( nNumPhase) + local nOperId = EgtGetNextOperation( PrevMch) + + -- se non ho lavorazioni, nemmeno codici speciali, setto luce purple e flag nessuna lavorazione + if not nOperId and not bSpecialCommandFound then + sLight = 'PURPLE' + nNoMach = 1 + else + nNoMach = 0 + end + end + +--bOk = false -- per forzare l'errore + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString( nNumGroup,0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) + EgtApplyAllMachinings( false, false) + + -- Salvo progetto + EgtSaveFile() + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '3 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + -- controllo collisioni + local bSimOk + + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + DoorOutLog( ' +++ Simulating with collision check >>>', 0) + EgtOutText( 'Start hidden simulation to find collision, It keep some time') + local nErr, sErr + -- se non ho lavorazioni non simulo + if nNoMach == 1 then + bSimOk = true + else + bSimOk, nErr, sErr = EgtSimulate() + if not bSimOk then + if nErr == MCH_SHE.INIT then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[686], sErr) + EgtOutBox( string.format(EgtDoorsMsg[686], sErr), 'Simulation', 'Simulation') + elseif nErr == MCH_SHE.COLLISION then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[687], sErr) + EgtOutBox( string.format(EgtDoorsMsg[687], sErr), 'Collision', 'Collision') + elseif nErr == MCH_SHE.OUTSTROKE then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[688], sErr) + EgtOutBox( string.format(EgtDoorsMsg[688], sErr), 'Outstroke', 'Outstroke') + else + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[689], sErr) + EgtOutBox( string.format(EgtDoorsMsg[689], sErr), 'Simulation', 'Simulation') + end + end + EgtOutText( 'hidden simulation finished') + end + else + bSimOk = true + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '4 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + if bSimOk then + -- se non ho lavorazioni non generao nulla + if nNoMach ~= 1 then + -- Estimation + bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath) + end + else + bOk = false + -- luce di caricamento porta + if sLight then + DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM + end + end + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + + -- luce di caricamento porta + if sLight then + DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM + end + + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + -- se non ho lavorazioni non generao nulla + if nNoMach ~= 1 then + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + -- copio il file txt con nuova estensione .tok + EgtCopyFile( sFileDir..sFileName..sNumGroup..'.txt', sFileDir..sFileName..sNumGroup..'.tok') + end + else + + -- se la simulazione è stata corretta ma errore nella generazione + if bSimOk then + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) + end + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- se la simulazione è stata corretta ma errore nella generazione + if bSimOk then + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + else + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori + end + end + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[690], 0) -- Error on simulation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( EgtDoorsMsg[690], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on simulation + end + end + return false, nNumGroup + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '5 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup, nNoMach +end + +return MachiningLoc diff --git a/Machining_5.lua b/Machining_5.lua new file mode 100644 index 0000000..ca26dc5 --- /dev/null +++ b/Machining_5.lua @@ -0,0 +1,4441 @@ +-- +-- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT +-- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT +-- EEEE GGGG GGGG TTTT +-- EEEE GGGG TTTT +-- EEEEEEE GGGG GGGGGGG TTTT +-- EEEEEEE GGGG GGGGGGG TTTT +-- EEEE GGGG GGGG TTTT +-- EEEE GGGG GGGG TTTT +-- EEEEEEEEEE GGGGGGGGGG TTTT +-- EEEEEEEEEE GGGGGG TTTT +-- +-- by EgalTech s.r.l. 2017/03/29 +-- Machining generation for Doors program machine CMS PK +-- 2017/06/05 V1.011 DS Fix main cycle at 10 times +-- 2017/06/13 V1.012 FM Manage machining optimization +-- 2017/06/13 V1.012 FM Fix bug on calculate box and row piece +-- 2017/06/30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017/11/17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2018/02/26 V1.0b1 FM Manage piece dimension checking +-- 2018/03/01 V1.0b2 FM use a table tMainTabPar instead of many variables ( more than 200 variables) +-- 2018/03/22 V1.0b3 FM Manage checking effective lock/hinge side machining and adjust the second disposition. Before not recognize if +-- lock/hinge side was machined or not in 1st phase +-- 2018/03/23 V1.0b4 FM Manage parameter for probe extra Z position and adjust probe error values +-- 2018/03/23 V1.0b4 FM Fix problem on second phase disposition by side path notes +-- 2018/05/04 V1.0b5 FM Fix write 2nd phase disposition notes when first phase is empty and substitute by second phase +-- 2018/05/09 V1.0b6 FM Fix error message on vacuums disposition +-- 2018/05/09 V1.0b6 FM Calculate the solid box without extra surfaces +-- 2018/06/18 V1.0b7 FM Manage door in probe mode and rebuilded +-- 2018/06/22 V1.0b8 FM Manage second phase on rebuilded door and fix some bugs +-- 2018/06/26 V1.0b9 FM Manage to use 2 bars with small width door +-- 2018/06/27 V1.0c1 FM write note about number of probez geometries and if generate one of their machinings +-- 2018/07/16 V1.0c2 FM Manage manual pin disposition on table bar disposition +-- 2018/07/17 V1.0c3 FM Manage vacuum disposition: in case it uses only 2 bars use the vacuum for 3rd bar on 2nd bar +-- 2018/07/24 V1.0d1 FM Read Properties (start managing properties) +-- 2018/08/22 V1.0d2 FM Fix error on calculare roughing on bevel side profiles + +local MachiningLoc = {} + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +-- Librerie particolari +local sBaseDir = EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() +-- Definizione disposizione pezzi ( a sinistra : 1, a destra : -1) +local DISPMODE = -1 +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) +local NO_WORK_UPSQUARE = true +-- variabili genarazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true +-- Variabile distanza minima tra pezzo finito e ventosa (in X) +local DIST_MIN_VAC = 5.5 +-- variabili disposizione porta +local bPush +local bFlip + +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. DGD.EMC) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** calculate door disposition by parameters *** +----------------------------------------------------------------- +local function CalcTopPosition( nTopSideDriveDisp, bAtRight) + local bTopOnRight + + if nTopSideDriveDisp and nTopSideDriveDisp == 1 then + bTopOnRight = true + elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then + bTopOnRight = false + else + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + + return bTopOnRight +end + +----------------------------------------------------------------- +-- *** Add Machining in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng +end + +----------------------------------------------------------------- +-- *** Vacuums disposition *** +----------------------------------------------------------------- +local ThroughId, BlindId +----------------------------------------------------------------- +-- Function to correct Manual position axis linearity +function GetCorrectedIndexedAxis( dMobVal) + local PTableCorr = {{1, 366.210}, + {2, 388.210}, + {3, 416.210}, + {4, 439.710}, + {5, 467.210}, + {6, 491.210}, + {7, 516.210}, + {8, 541.210}, + {9, 567.210}, + {10, 594.210}, + {11, 617.210}, + {12, 644.210}, + {13, 668.710}, + {14, 692.710}, + {15, 718.710}, + {16, 743.710}, + {17, 769.710}, + {18, 795.710}, + {19, 821.210}, + {20, 844.710}, + {21, 871.210}, + {22, 896.210}, + {23, 922.210}, + {24, 948.210}, + {25, 972.710}, + {26, 998.210}, + {27, 1023.210}, + {28, 1047.710}, + {29, 1072.210}, + {30, 1097.710}, + {31, 1122.210}, + {32, 1147.210}} + + -- Verifico che il valore passato sia raggiungibile + if #PTableCorr < 2 or dMobVal < PTableCorr[1][2] or dMobVal > PTableCorr[#PTableCorr][2] then return end + -- Cerco l'intervallo della tabella in cui cade il valore + local nI = 1 + while nI <= #PTableCorr and dMobVal > PTableCorr[nI][2] do + nI = nI + 1 + end + -- calcolo la posizione del foro più vicina + local dIndexBar + local dNewVal + if ( PTableCorr[nI][2] - dMobVal) >= ( dMobVal - PTableCorr[nI - 1][2]) then -- se misura più vicina la foro inferiore + dNewVal = PTableCorr[nI - 1][2] + dIndexBar = nI - 1 + else + dNewVal = PTableCorr[nI][2] + dIndexBar = nI + end + + return dNewVal, dIndexBar +end + +----------------------------------------------------------------- +local function StartVacVerify( nIdSolid, bFlipped, nProbeMode) + -- regioni passante e cieca non definite + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + -- recupero le regioni sopra e sotto della porta messa in macchina + local UpId, DwId + local UpId2, DwId2 + -- se porta ribaltata + if bFlipped then + if nProbeMode == 2 then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie a contatto con le ventose + DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) + -- superficie sopra + UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + end + else + if nProbeMode == 2 then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie a contatto con le ventose + DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) + -- superficie sopra + UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + end + end + -- creo le regioni complementari + local CompUpId + if nProbeMode == 2 then + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nCurveId = EgtExtractSurfFrChunkLoops( UpId2, 0, nRecId) -- prendo il contorno della regione piena + CompUpId = EgtSurfFlatRegion( nIdSolid, nCurveId) -- creo regione rettangolare piena + else + local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.STANDARD) + CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) -- creo regione rettangolare piena + end + + local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) + local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end + EgtSurfFrSubtract( CompUpId, UpId) + if not EgtExistsObj( CompUpId) then CompUpId = nil end + + local CompDwId + if nProbeMode == 2 then + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nCurveId = EgtExtractSurfFrChunkLoops( DwId2, 0, nRecId) + CompDwId = EgtSurfFlatRegion( nIdSolid, nCurveId) + else + local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.STANDARD) + CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) + end + local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) + local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end + EgtSurfFrSubtract( CompDwId, DwId) + if not EgtExistsObj( CompDwId) then CompDwId = nil end + if CompDwId then EgtInvertSurf( CompDwId) end + -- calcolo le regioni passante e cieca + local ThroughRegId = nil + local BlindRegId = nil + -- se ci sono entrambe le regioni + if CompUpId and CompDwId then + -- per ottenere la regione passante faccio intersezione tra sopra e sotto + EgtSurfFrIntersect( CompUpId, CompDwId) + if EgtExistsObj( CompUpId) then + ThroughRegId = CompUpId + end + -- per ottenere la regione cieca faccio differenza tra sotto e passante + if ThroughRegId then + EgtSurfFrSubtract( CompDwId, ThroughRegId) + if EgtExistsObj( CompDwId) then + BlindRegId = CompDwId + end + else + BlindRegId = CompDwId + end + -- se c'è solo la regione sotto è già quella delle lavorazioni cieche + elseif CompDwId then + BlindRegId = CompDwId + -- se c'è solo la sopra, non interessa e la cancello + elseif CompUpId then + EgtErase( CompUpId) + end + -- sistemazioni finali + if ThroughRegId then + ThroughId = EgtGroup( GDB_ID.ROOT) + EgtSetName( ThroughId, 'THROUGH') + EgtSetColor( ThroughId, RED()) + EgtSetLevel( ThroughId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + EgtErase( ThroughRegId) + --EgtSetName( ThroughRegId, 'THROUGH') + --EgtSetColor( ThroughRegId, RED()) + --EgtSetLevel( ThroughRegId, GDB_LV.TEMP) + end + if BlindRegId then + BlindId = EgtGroup( GDB_ID.ROOT) + EgtSetName( BlindId, 'BLIND') + EgtSetColor( BlindId, BLUE()) + EgtSetLevel( BlindId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do + nChunk = nChunk + 1 + end + EgtErase( BlindRegId) + --EgtSetName( BlindRegId, 'BLIND') + --EgtSetColor( BlindRegId, BLUE()) + --EgtSetLevel( BlindRegId, GDB_LV.TEMP) + end +end + +----------------------------------------------------------------- +local function ExecVacVerify( ptVac, dDistVac) + -- verifica con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistVac + 15 then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistVac + 45 then + return false + end + end + nId = EgtGetNext( nId) + end + -- nessuna interferenza + return true +end + +----------------------------------------------------------------- +local function EndVacVerify() + -- cancello regioni passante e cieca + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil +end + +-------------------------------------------------------------------------------- +-- * Abilitazione/disabilitazione geometrie * +local function ShowHideGeom( nGroupId, sName, dVal) + local nId = EgtGetFirstNameInGroup( nGroupId, sName) + if nId then + local dOldVal = EgtGetInfo( nId, 'Val', 'd') or 0.1 + if dVal ~= dOldVal then + if dVal > 0.5 then + EgtSetStatus( nId, GDB_ST.ON) + else + EgtSetStatus( nId, GDB_ST.OFF) + end + EgtSetInfo( nId, 'Val', dVal) + end + end +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +local function CheckExtSideMach( tListEnt) + local sEdgeNote + for j = 1, #tListEnt do + if tListEnt[j] then + sEdgeNote = EgtGetInfo( tListEnt[j], 'EdgeDoor') or '' + if sEdgeNote == 'T' then -- se lavorato lato top + DGD.MTS = 1 + elseif sEdgeNote == 'B' then -- se lavorato lato bottom + DGD.MBS = 1 + elseif sEdgeNote == 'H' then -- se lavorato lato hinge + DGD.MHS = 1 + elseif sEdgeNote == 'L' then -- se lavorato lato lock + DGD.MLS = 1 + end + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, bNotGenMachining, tMachining ) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local sKeepBackSet = EgtGetInfo( tEndId[1], 'KeepBackSet') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + local sKeepBackSetCode + + -- determino in base alla disposizione quale codice KeepBackSet dare alla lavorazione + if sKeepBackSet and not bNotGenMachining then + if (bPush and bFlip) or ( not bPush and not bFlip) then -- se lato narrow è in basso (BD) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + end + else -- altrimenti lato narrow è in alto (BU) + if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio + sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) + elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per non correggere Z + sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) + end + end + end + + if nMach == 1 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMach) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachUp) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachDw) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- verifico se lavorati lati esterni porta + CheckExtSideMach(tEndId) + end + end + end + + return bOk, nNumMach, tMachining + +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, nNumGroup, nNumMach, bOk ) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if tLocTable[i].Oper == 'AdjustHead' and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j]) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, bNotGenMachining) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach ) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, GEN_MACH) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** calc disposition references *** +----------------------------------------------------------------- +local function CalcDispositionRef( bLeftPiece, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + + local dExtraX, dExtraY, nCorner + + if DISPMODE > 0 then -- se disposizione a sinistra della tavola + if bTopOnRight then -- se top a destra + dExtraX = -dBottomOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.BL + dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) + else + nCorner = MCH_CR.TL + dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) + end + else -- se top a sinistra + dExtraX = -dTopOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.TL + dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) + else + nCorner = MCH_CR.BL + dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) + end + end + else -- altrimenti disposizione a destra della tavola + if bTopOnRight then -- se top a destra + dExtraX = dTopOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.BR + dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) + else + nCorner = MCH_CR.TR + dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) + end + else -- se top a sinistra + dExtraX = dBottomOffs + if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then + nCorner = MCH_CR.TR + dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) + else + nCorner = MCH_CR.BR + dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) + end + end + end + + return dExtraX, dExtraY, nCorner +end + +----------------------------------------------------------------- +-- *** calc disposition subpieces *** +----------------------------------------------------------------- +local function CalcDispositionSubPieces( nNumB, nRowId, bFixSameVac, tsBaseNameVac, tsBaseNamePnt, + sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, + tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, + nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, + tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, dLenCalc) + + local ptPos -- punto posizioni ventose + local tbCanUp = {} -- tabella punti controlli barra, gli indici tabella sono i punti di controllo per ogni ventosa + local tPosSubPiece = {} + local tPosRowSubPieceRow = {} + + local nCenterId + + if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then + tbCanUp[1] = false -- giusto per far fallire il controllo successivo + else + -- controllo la ventosa normale + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_1') + tbCanUp[1] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt1[nNumB]) -- 41.275 + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_2') + ptPos = EgtSP( nCenterId, GDB_ID.ROOT) + tbCanUp[2] = ExecVacVerify( ptPos, tdBaseRadiusPnt1[nNumB]) + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_3') + tbCanUp[3] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt1[nNumB]) + end + + -- se fallisce provo con quella piccola + if not ( tbCanUp[1] and tbCanUp[2] and tbCanUp[3]) and tnNumVacInsert[nNumB] == 2 then + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_1') + tbCanUp[1] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt2[nNumB]) -- 31.750 + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_2') + ptPos = EgtSP( nCenterId, GDB_ID.ROOT) + tbCanUp[2] = ExecVacVerify( ptPos, tdBaseRadiusPnt2[nNumB]) + nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_3') + tbCanUp[3] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt2[nNumB]) + + -- se anadata a buon fine e la configurazione disposizione è per mantenere uniformi le ventose + if tbCanUp[1] and tbCanUp[2] and tbCanUp[3] then + tnNumKindVac[nNumB] = 2 + if bFixSameVac and string.len( tsBaseNameVac[nNumB]) == 0 then + tsBaseNameVac[nNumB] = tsBaseNameVac_2[nNumB] + tsBaseNameVacSld[nNumB] = tsBaseNameVacSld_2[nNumB] + tdYCommpos[nNumB] = ptPos:getY() + end + end + else -- già la prima è andata bene + if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then + tnNumKindVac[nNumB] = 2 + else + tnNumKindVac[nNumB] = 1 + end + end + + -- eventuale abilitazione parte fissa + if tbCanUp[1] and tbCanUp[2] and tbCanUp[3] then -- se sottopezzo da inserire + + local nCodVac + + -- se righe con ventose uniformi + if ( bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0) or tnNumKindVac[nNumB] == 2 then + nCodVac = 2 + elseif tnNumKindVac[nNumB] == 1 then + nCodVac = 1 + end + + -- inserisco la ventosa sul fisso + tPosSubPiece[1] = ptPos + tPosSubPiece[2] = nCodVac + tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} + + -- interrompo le serie negative + if nInd > 1 then + tnCountFailed[nNumB] = 0 + if tnMaxIniFailed[nNumB] < tnIniFailed[nNumB] then + tnMaxIniFailed[nNumB] = tnIniFailed[nNumB] + end + if tnMaxMiddleFailed[nNumB] < tnMiddleFailed[nNumB] then + tnMaxMiddleFailed[nNumB] = tnMiddleFailed[nNumB] + end + if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then + tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] + end + tnIniFailed[nNumB] = 0 + tnMiddleFailed[nNumB] = 0 + tnEndFailed[nNumB] = 0 + end + else -- sottopezzo non inserito + tPosSubPiece[1] = '' + tPosSubPiece[2] = 0 + tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} + + tnCountFailed[nNumB] = tnCountFailed[nNumB] + 1 + if nInd == 1 then -- setto solo il fallimento iniziale + tnIniFailed[nNumB] = tnCountFailed[nNumB] + elseif nInd == nNumTotVacRow or dLenCalc <= 0 then -- setto solo quello finale e annullo il medio + tnEndFailed[nNumB] = tnCountFailed[nNumB] + if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then + tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] + end + tnMiddleFailed[nNumB] = 0 + else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati + if tnIniFailed[nNumB] > 0 then + tnIniFailed[nNumB] = tnCountFailed[nNumB] + elseif tnEndFailed[nNumB] > 0 then + tnEndFailed[nNumB] = tnCountFailed[nNumB] - 1 + else + tnMiddleFailed[nNumB] = tnCountFailed[nNumB] + end + end + end + + return tPosRowSubPieceRow +end + +----------------------------------------------------------------- +-- *** disposition subpieces *** +----------------------------------------------------------------- +local function DispositionSubPieces( nNumB, nIndVac, tPosRowSubPieceRow, bFixSameVac, tsBaseNameVac, + tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, + tsBaseNameVacSld_2, nIndOri, tabOri, tsNoteRow, nDispId) + + local tnCodVac = tPosRowSubPieceRow[nIndVac] + local sCodVac + local sNameV, sNameVSld + + if tnCodVac then -- se codice presente + if tnCodVac[2] == 0 then + sCodVac = '0_' + else + if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then -- se fissa sulla seconda + sNameV = tsBaseNameVac[nNumB] + sNameVSld = tsBaseNameVacSld[nNumB] + sCodVac = '2_' + tnCodVac[1] = Point3d{ tnCodVac[1]:getX(), tdYCommpos[nNumB], tnCodVac[1]:getZ()} + elseif tnCodVac[2] == 1 then + sNameV = tsBaseNameVac_1[nNumB] + sNameVSld = tsBaseNameVacSld_1[nNumB] + sCodVac = '1_' + elseif tnCodVac[2] == 2 then + sNameV = tsBaseNameVac_2[nNumB] + sNameVSld = tsBaseNameVacSld_2[nNumB] + sCodVac = '2_' + end + + -- inserisco la ventosa sul fisso + local sNameVac = EgtIf( fmod( nIndOri, 2) == 1, sNameVSld, sNameV) + local nFixVac = EgtAddFixture( sNameVac, ( tnCodVac[1] - tabOri), 0) + EgtSetInfo( nDispId, 'POS'..tostring( nNumB)..'_'..tostring( nIndVac), ( tnCodVac[1] - tabOri)) + EgtSetInfo( nDispId, 'MOD'..tostring( nNumB)..'_'..tostring( nIndVac), sNameVac) + EgtSetInfo( nDispId, 'COD'..tostring( nNumB)..'_'..tostring( nIndVac), sCodVac) + end + tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. sCodVac, sCodVac .. tsNoteRow[nNumB]) + else + tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. '0_', '0_' .. tsNoteRow[nNumB]) + EgtRemoveInfo( nDispId, 'POS'..tostring( nNumB)..'_'..tostring( nIndVac)) + EgtRemoveInfo( nDispId, 'MOD'..tostring( nNumB)..'_'..tostring( nIndVac)) + EgtRemoveInfo( nDispId, 'COD'..tostring( nNumB)..'_'..tostring( nIndVac)) + end +end + +local function CheckEnoughVacuums( nInd, nIdVac, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, bUseOnly2Bars) + + local bOk = true + local sMess = '' + + if nIdVac == 0 then -- se codice per porta + + if bUseOnly2Bars then -- in caso di due barre, inferiore e media + if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or + ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd)) then -- tutte le ventose basse + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[1] / nInd > 0.25) and + ( tnMaxIniFailed[2] / nInd > 0.25) then -- ventose iniziali ( parte sinistra) + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and + ( tnMaxMiddleFailed[2] / nInd > 0.45) then -- ventose centrali + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[1] / nInd > 0.25) and + ( tnMaxEndFailed[2] / nInd > 0.25) then -- ventose finali ( parte destra) + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and + (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) then -- somma di vari intervalli + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + else + -- casi di scarse ventose: solo per le file esterne, quella centrale non la considero perchè è capitato che + -- la porta rimaneva su solo per la fila centrale + if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or + -- ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd) or + ( tnMaxIniFailed[3] == nInd or tnMaxMiddleFailed[3] == nInd or tnMaxEndFailed[3] == nInd)) then -- tutte le ventose basse + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[1] / nInd > 0.25) and + -- ( tnMaxIniFailed[2] / nInd > 0.25) and + ( tnMaxIniFailed[3] / nInd > 0.25) then -- ventose iniziali ( parte sinistra) + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and + -- ( tnMaxMiddleFailed[2] / nInd > 0.45) and + ( tnMaxMiddleFailed[3] / nInd > 0.45) then -- ventose centrali + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[1] / nInd > 0.25) and + -- ( tnMaxEndFailed[2] / nInd > 0.25) and + ( tnMaxEndFailed[3] / nInd > 0.25) then -- ventose finali ( parte destra) + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and + -- (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) and + (( tnMaxIniFailed[3] + tnMaxMiddleFailed[3] + tnMaxEndFailed[3]) >= nInd/2) then -- somma di vari intervalli + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + end + else -- altrimenti frame + -- casi di scarse ventose: solo per la fila 1 + if nInd > 0 and ( tnMaxIniFailed[nIdVac] == nInd or tnMaxMiddleFailed[nIdVac] == nInd or tnMaxEndFailed[nIdVac] == nInd) then + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + elseif nInd > 0 and ( tnMaxIniFailed[nIdVac] / nInd > 0.25) then + local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif nInd > 0 and ( tnMaxMiddleFailed[nIdVac] / nInd > 0.45) then + sMess = ' ' .. EgtDoorsMsg[533] + bOk = false + elseif nInd > 0 and ( tnMaxEndFailed[nIdVac] / nInd > 0.25) then + local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) + sMess = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + elseif (( tnMaxIniFailed[nIdVac] + tnMaxMiddleFailed[nIdVac] + tnMaxEndFailed[nIdVac]) >= nInd/2) then + sMess = ' ' .. EgtDoorsMsg[531] + bOk = false + end + end + + return bOk, sMess +end + +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.STANDARD) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) + + -- macchina e tabella di default + -- tabella parametri d'uso per variabili CurrcamInfo + tMainTabPar = {} + -- Machine name + tMainTabPar.MN = 'Multiax-' -- id 1 + + -- Machinings Table + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- References on table (respect Zero machine) + -- Y Table + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftVac = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- elimino percorsi eventualmente creati dal Mach + -- cancello i percorsi ghost e tutti i percorsi di sgrossatura + local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + +-------------------------------------------------------------------------------- + -- Dati del pezzo (porta, frame) + local tsProperties = {} + local sCode, sSwing, sSecure, sHingeTrim, sLockTrim, sTopTrim, sBottomTrim + local dWidthDoor, dLengthDoor, dThickDoor, dRadiusPrf, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs + local bHingeMach, bLockMach, bTopMach, bBottomMach, bAtRight, bSwingDriveDisp + local nProbeMode + + -- Box pezzo + local Ls + local Aux + local b3Part, b3Solid + local tb3Part = {} + local tb3Solid = {} + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi +-- sFileName = sCode + local sErrFile = sFileDir .. sFileName .. '.txt' + +-------------------------------------------------------------------------------- + -- variabili CAM + local TAB + local MachinesName + -- *** settaggi CAM *** -- Mtable 2 + local TABORD + +-------------------------------------------------------------------------------- + -- variabili sottopezzi + local nTabId, nMobId1, nMobId2, nFixId, nDispId + local dFixval, dOldVal, dNewVal_2, dNewVal_1, dCalcLen, nIndexPin + +-------------------------------------------------------------------------------- + -- assegnazione variabili CurrCamInfo + + -- imposto i dati macchina secondo le informazioni del file cam + tMainTabPar.MN = mCamData[nNumMachFromCam].MachName -- id 1 MachName + tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength -- id 2 dMaxDoorLength + tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength -- id 3 dMinDoorLength + tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth -- id 4 dMaxDoorWidth + tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth -- id 5 dMinDoorWidth + tMainTabPar.MxDT = mCamData[nNumMachFromCam].MaxDoorThick -- id 6 dMaxDoorThick + tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick -- id 7 dMinDoorThick + tMainTabPar.MxJL = mCamData[nNumMachFromCam].MaxJambLength -- id 8 dMaxJambLength + tMainTabPar.MnJL = mCamData[nNumMachFromCam].MinJambLength -- id 9 dMinJambLength + tMainTabPar.MxJW = mCamData[nNumMachFromCam].MaxJambWidth -- id 10 dMaxJambWidth + tMainTabPar.MnJW = mCamData[nNumMachFromCam].MinJambWidth -- id 11 dMinJambWidth + tMainTabPar.MxJT = mCamData[nNumMachFromCam].MaxJambThick -- id 12 dMaxJambThick + tMainTabPar.MnJT = mCamData[nNumMachFromCam].MinJambThick -- id 13 dMinJambThick + tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef -- id 14 dAltRef + tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef -- id 15 dTallRef + tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure -- id 16 sLocSecure + tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat -- id 17 dMaxOverMat + tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 -- id 18 dStepOverMat + tMainTabPar.TDD = mCamData[nNumMachFromCam].TopSideDriveDisp -- id 19 nTopSideDriveDisp + tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain -- id 20 dMaxDistToChain + tMainTabPar.FPB = mCamData[nNumMachFromCam].FramePosBar -- id 21 dPosBarForJamb + tMainTabPar.FVR = mCamData[nNumMachFromCam].nFixSameVacOnRaw == 1 -- id 22 bFixSameVac + tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining -- id 23 dExtraThruDepth + tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 -- id 24 Ori1 + tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 -- id 25 Ori2 + tMainTabPar.OR1f = mCamData[nNumMachFromCam].Ori1f -- id 26 Ori1f + tMainTabPar.OR2f = mCamData[nNumMachFromCam].Ori2f -- id 27 Ori2f + tMainTabPar.OR3f = mCamData[nNumMachFromCam].Ori3f -- id 28 Ori3f + tMainTabPar.OR4f = mCamData[nNumMachFromCam].Ori4f -- id 29 Ori4f + tMainTabPar.OR5f = mCamData[nNumMachFromCam].Ori5f -- id 30 Ori5f + tMainTabPar.OR6f = mCamData[nNumMachFromCam].Ori6f -- id 31 Ori6f + tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 -- id 32 vShiftAct + tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck -- id 33 vShiftLockSide not used + tMainTabPar.DVL = mCamData[nNumMachFromCam].dDistanceVacLeft -- id 34 new + tMainTabPar.DVR = mCamData[nNumMachFromCam].dDistanceVacRight -- id 35 new + tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels -- id 36 new + tMainTabPar.P2P1 = mCamData[nNumMachFromCam].sProperty_1 -- id 37 name property 1 (skinned) + tMainTabPar.P2P2 = mCamData[nNumMachFromCam].sProperty_2 -- id 38 name property 2 (extruded) + DISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or DISPMODE -- SideDoorDispose + +-------------------------------------------------------------------------------- + + local MTable, MTableOrd + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftMchng = false + local bSmallShiftedDoor = false + local sDispMode + local sNotePhase + local sTotDispMode = '' + local sNumGroup = '' + local bGenFirstStep = false + local nIndexStartMach = 1 + local bWork = true + local sIdList = '' + -- variabili utilizzate dentro al ciclo + local nMchId + local sTab + local tabOri + local Ori + local ColA + local nRaw + local tnRaw = {} + local bMoveRaw + local bTopOnRight + local bFrame + -- variabili per disposizione sottopezzi + local dMobOffs1 + local dMobOffs2 +-- local dVacOffs -- ridondante + local dDistMinX + local dDistMaxX + local dVacOn + local dInterAx + local dMinDistGroup + local bUseOnly2Bars + local OffsXSovr = 0 + local OffsYSovr = 0 + -- variabile per tool setup + local bSetUp + local MSetup + local sSetup + local tListError + local sListTool + -- variabili calcolo box + local b3SolidPiece = {} + local b3SolidPiece2 = {} + local b3SolidOnTab + local pMin + local pMinRecalc + local pMax + local dOffsX = 0 + local dOffsY = 0 + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local tsMachProf = {} + local bNoVertProf = true + local bWorkUnder = true + -- variabile per conteggio lavorazioni + local nNumMach = 0 + local nNumSkip + local tSecMachTab = {} + local tSecMachTabOrd = {} + -- variabili per fase + local nNumPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + local pDistToMove + local dAngleToAlign = 0 + -- variabile proprietà speciale + local nNumProperties = 0 + + -- tabella lavorazioni + local tLocMach = {} + local tLocMachOrd = {} + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( tMainTabPar.MN) + + -- raccolgo gli id dei pezzi + for v = 1, #tPz do + sIdList = sIdList .. '_' .. EgtNumToString(tPz[v],0) + end + local bEnBreak = false + + -- faccio tutte le fasi + while bWork do + + -- per ogni pezzo passato + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + -- assegnamento variabili + bFrame = sAssemb and string.find( sAssemb, 'frame') == 1 + Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + Aux = EgtGetFirstNameInGroup( Pz, 'AUX') + sCode = EgtGetInfo( Pz, 'Code') + dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + dThickDoor = EgtGetInfo( Pz, 'T', 'd') + sSwing = EgtGetInfo( Pz, 'Swing') + sSecure = EgtGetInfo( Pz, 'Secure') + tsProperties = EgtSplitString( EgtGetInfo( Pz, 'Properties') or '') + sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + sTopTrim = EgtGetInfo( Pz, 'top_trimming') + sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + bAtRight = ( sSwing:sub(1,1) == 'L') -- flag settato a vero se serratura a destra + bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) + dRadiusPrf = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 + dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + + if bFirstStep and not bShiftMchng then + + -- determino se la porta ha speciali proprietà + if MB.FindProperties ( tsProperties, tMainTabPar.P2P1) then + nNumProperties = 1 -- per skinned + elseif MB.FindProperties ( tsProperties, tMainTabPar.P2P2) then + nNumProperties = 2 -- per extruded + -- se sono in modalità lavorazione porta ricostruita, + -- riassegno la probemode per far elaborare la porta in modalità normale + if nProbeMode == 2 then + nProbeMode = 0 + end + end + + -- ottengo la tabella corrente del primo pezzo + MachiningsTable = EgtGetInfo( tPz[1], 'MTable') + -- Box pezzo + table.insert( tb3Part, v, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) + + local b3fx = BBox3d() -- inizializzo il box nullo + b3fx = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + + table.insert( tb3Solid, v, b3fx) +-- table.insert( tb3Solid, v, EgtGetBBoxGlob( Ls, GDB_BB.STANDARD)) + end + + -- assegno i box del pezzo + b3Part = tb3Part[v] + b3Solid = tb3Solid[v] + + if v == 1 then -- solo il primo pezzo + + if bFirstStep and not bShiftMchng then + + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DGD.ERR = 26 + local sErrMess = string.format(EgtDoorsMsg[597], MachiningsTable) + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DGD.ERR = 27 + local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + else + DGD.ERR = 28 + local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + MachinesName = TAB.MMachineData + if not MachinesName then + DGD.ERR = 29 + local sErrMess = string.format(EgtDoorsMsg[491], '') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- Errore! Nome macchina: non presente in MTable + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DGD.ERR = 30 + local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + else + DGD.ERR = 31 + local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable + return true + end + + -- se dimensioni porta incompatibili per collisione con aggregato attrezzato sulla tavola + if ( dLengthDoor > (97.5*25.4) and dWidthDoor > (42.9*25.4)) or (dLengthDoor > (118*25.4) and dWidthDoor > (22.5*25.4)) then + DGD.ERR = 35 + local sErrMess = "Error! Door length and width exceded and there is a risk of collision by 5axis head with table aggregate" + DGD.EMC = DGD.EMC .. '\n' .. sErrMess + WriteErrFile( sFileDir..sFileName..'.txt') + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( sErrMess, 0) -- errore + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + return false + end + + MTable = TAB.MTable + MTableOrd = TABORD.MTable + end + end + + -- se è un frame + if bFrame then + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + local bFailDim = false + local sErrMess = '' + if dLengthDoor < tMainTabPar.MnJL then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[623], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MnJL)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dLengthDoor > tMainTabPar.MxJL then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[623], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MxJL)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dWidthDoor < tMainTabPar.MnJW then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[623], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MnJW)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dWidthDoor > tMainTabPar.MxJW then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[623], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MxJW)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dThickDoor < tMainTabPar.MnJT then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[623], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MnJT)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dThickDoor > tMainTabPar.MxJT then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[623], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MxJT)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + + if bFailDim then + + DGD.ERR = 19 + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( DGD.EMC, 0) + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + else -- è una porta + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + local bFailDim = false + local sErrMess = '' + if dLengthDoor < tMainTabPar.MnDL then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MnDL)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dLengthDoor > tMainTabPar.MxDL then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MxDL)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dWidthDoor < tMainTabPar.MnDW then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MnDW)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dWidthDoor > tMainTabPar.MxDW then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MxDW)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dThickDoor < tMainTabPar.MnDT then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MnDT)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + if dThickDoor > tMainTabPar.MxDT then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MxDT)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = sErrMess + end + end + + if bFailDim then + + DGD.ERR = 19 + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( DGD.EMC, 0) + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + end + + sDispMode = '' + + if bFirstStep and not bShiftMchng then + + if v == 1 then nNumGroup = nNumGroup + 1 end + + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) + else + -- creo gruppo lavooro + if v == 1 then + nMchId = EgtAddMachGroup( 'Ids'.. sIdList ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) + end + end + nNumPhase = EgtGetCurrPhase() + else + + if v == 1 then + + -- se nessuna lavorazione riutilizzo la vecchia fase + if nNumMach == 0 then + + -- elimino i vecchi grezzi + for t = 1, #tnRaw do + EgtRemoveRawPart( tnRaw[t]) -- elimino il grezzo + end + + -- elimino la disposizione dei sottopezzi + local nNumFix = EgtGetFirstFixture() + while nNumFix do + EgtRemoveFixture( nNumFix) + nNumFix = EgtGetFirstFixture() + end + else + nNumPhase = EgtAddPhase() -- creo nuova fase + end + end + + -- rendo corrente la fase + if nNumPhase then + EgtSetCurrPhase(nNumPhase) + end + end + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + if bFirstStep and not bShiftMchng then + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + dLeftOffs = 0 + dRightOffs = 0 + dTopOffs = 0 + dBottomOffs = 0 + end + else -- fase successiva ribaltata o spostata + + -- i profili con lavorazione disabilitata li posso mettere subito a zero + if ( not bLockMach and bAtRight) or ( not bHingeMach and not bAtRight) then -- lavorazione lato destro disabilitata + dRightOffs = 0 + end + + if ( not bLockMach and not bAtRight) or ( not bHingeMach and bAtRight) then -- lavorazione lato sinistro disabilitata + dLeftOffs = 0 + end + + if not bTopMach then -- lavorazione lato top disabilitata + dTopOffs = 0 + end + + if not bBottomMach then -- lavorazione lato top disabilitata + dBottomOffs = 0 + end + + -- azzero i sovramateriali dei profili che sono stati lavorati + if tsMachProf and string.len( tsMachProf[v]) > 0 then + + local sListProf = EgtSplitString( tsMachProf[v], ',') + for m = 1, #sListProf do + if string.lower( sListProf[m]) == 'left' then + dLeftOffs = 0 + elseif string.lower( sListProf[m]) == 'right' then + dRightOffs = 0 + elseif string.lower( sListProf[m]) == 'top' then + dTopOffs = 0 + elseif string.lower( sListProf[m]) == 'bottom' then + dBottomOffs = 0 + end + end + end + end + + -- se sono in ribaltamento e in rebuild della porta devo ruotare la porta + -- con il lato opposto parallelo a Y (prima della disposizione) + if not bFirstStep and nProbeMode == 2 then + + local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') + local nSideToAlign + local sSideToAlign + local nSideToAlignMid + local sSideToAlignMid + local nSideToAlignTop + local sSideToAlignTop + local bInvert + + if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then + sSideToAlign = 'Right' + sSideToAlignMid = 'RightMid' + sSideToAlignTop = 'RightTop' + bInvert = false + else + sSideToAlign = 'Left' + sSideToAlignMid = 'LeftMid' + sSideToAlignTop = 'LeftTop' + bInvert = true + end + + nSideToAlign = EgtGetFirstNameInGroup( nRecId, sSideToAlign) + nSideToAlignMid = EgtGetFirstNameInGroup( nRecId, sSideToAlignMid) + nSideToAlignTop = EgtGetFirstNameInGroup( nRecId, sSideToAlignTop) + + local vVectorToAlign + + if nSideToAlign then + if bInvert then + vVectorToAlign = EgtSV( nSideToAlign) + dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) - 180 + else + vVectorToAlign = EgtSV( nSideToAlign) + dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) + end + + -- allineo il pezzo prendendo il riferimento del lato opposto al lato riferito nella prima fase + EgtRotate( Pz , ORIG(), Z_AX(), dAngleToAlign ) + + -- muovo la porta nelle origini + if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then -- lato allineato right + if bAtRight then -- se serratura a destra + if sLockTrim == 'BD' or sLockTrim == 'BU' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) + end + else + if sHingeTrim == 'BD' or sHingeTrim == 'BU' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) + end + end + else -- lato allineato left + if bAtRight then -- se serratura a destra + if sHingeTrim == 'BD' or sHingeTrim == 'BU' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) + end + else + if sLockTrim == 'BD' or sLockTrim == 'BU' then -- se profilo bevel + if bPush then -- se porta a spingere prendo come riferimento lato bottom + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato top + pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) + end + elseif sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) + pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) + else -- prendo riferimento da lato medio + pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) + end + end + end + + -- muovo il pezzo sull'origine + EgtMove( Pz, ORIG() - Point3d( pDistToMove:getX(), pDistToMove:getY(), 0), GDB_RT.GLOB) + + -- ricalcolo il box del solido + b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + -- ricalcolo il box del pezzo + b3Part = EgtGetBBoxGlob( Pz, GDB_BB.STANDARD) + end +-- bEnBreak = true +-- bWork = false +-- break + end + + if bFirstStep then + table.insert( b3SolidPiece, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) + else + table.insert( b3SolidPiece2, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) + end + + if b3SolidPiece[v] and b3SolidPiece2[v] and nProbeMode ~= 2 then + dOffsX = b3SolidPiece2[v]:getMin():getX() - b3SolidPiece[v]:getMin():getX() + dOffsY = b3SolidPiece2[v]:getMin():getY() - b3SolidPiece[v]:getMin():getY() + else + dOffsX = 0 + dOffsY = 0 + end + + ColA = Color3d( 255, 165, 0, 25) + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, + b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) + table.insert( tnRaw, v, nRaw) + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs + dOffsX, dBottomOffs + dOffsY, 0), nRaw) + + if not bFirstStep and nProbeMode == 2 then + -- contromovimento e controrotazione del pezzo per riportarlo nelle condizioni originarie + EgtResetCurrMachGroup() + EgtMove( Pz, Point3d( pDistToMove:getX(), pDistToMove:getY(), 0) - ORIG(), GDB_RT.GLOB) + EgtRotate( Pz , ORIG(), Z_AX(), -dAngleToAlign ) + EgtSetCurrMachGroup() + EgtSetCurrPhase(nNumPhase) + end + +-- if nProbeMode == 2 then + if bFirstStep and nProbeMode == 2 then + local dtempX = EgtIf( abs(b3Solid:getMin():getX()) < abs(b3Solid:getMax():getX()), b3Solid:getMin():getX(), b3Solid:getMax():getX()) + local dtempY = EgtIf( abs(b3Solid:getMin():getY()) < abs(b3Solid:getMax():getY()), b3Solid:getMin():getY(), b3Solid:getMax():getY()) + pMinRecalc = Point3d( dtempX, dtempY, 0) + else + pMinRecalc = Point3d( 0, 0, 0) + end + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitae inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + if v == 1 then -- solo il primo pezzo + + if bFirstStep then + tLocMach = MTable + tLocMachOrd = MTableOrd + if not bShiftMchng then + nIndexStartMach = 1 + end + else + tLocMach = tSecMachTab + tLocMachOrd = MTableOrd + if not bShiftMchng then + nIndexStartMach = 1 + end + end + end + + if bFirstStep and not bShiftMchng then + tsMachProf[v] = '' + end + + if v == #tPz then -- solo all'ultimo pezzo + + -- solo il primo giro, prendo nota dei profili tipo bevel + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + if bFirstStep and not bShiftMchng then + + local nUnderGeom + local tGeomThruUp = {} + local tGeomThruDw = {} + local tGeomBlindUp = {} + local tGeomBlindDw = {} + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + -- prendo i profili bevel direttamente dalla tabella + local sUpperProfName = string.upper(tLocMach[i].Name) + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName) then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) + + -- se è una porta + if not bFrame then + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata .. + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + tLocMach[i].Shift and tLocMach[i].Shift > 0 then + bSmallShiftedDoor = true + end + end + -- Test delle lavorazioni + for j = 1, #EntList do + local nTypeGeom = 0 + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom, nTypeGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + if nTypeGeom == 1 then -- se passante up + table.insert( tGeomThruUp, EntList[j]) + elseif nTypeGeom == 2 then -- se passante dw + table.insert( tGeomThruDw, EntList[j]) + elseif nTypeGeom == 3 then -- se cieca up + table.insert( tGeomBlindUp, EntList[j]) + elseif nTypeGeom == 4 then -- se cieca dw + table.insert( tGeomBlindDw, EntList[j]) + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom, nTypeGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + if nTypeGeom == 1 then -- se passante up + table.insert( tGeomThruUp, EntList[j]) + elseif nTypeGeom == 2 then -- se passante dw + table.insert( tGeomThruDw, EntList[j]) + elseif nTypeGeom == 3 then -- se cieca up + table.insert( tGeomBlindUp, EntList[j]) + elseif nTypeGeom == 4 then -- se cieca dw + table.insert( tGeomBlindDw, EntList[j]) + end + elseif tLocMach[i].Oper == 'AdjustBevel' then + table.insert( tGeomThruUp, EntList[j]) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + table.insert( tGeomThruUp, EntList[j]) + elseif tLocMach[i].Oper == 'AdjPrfThrouCurve' then + table.insert( tGeomThruUp, EntList[j]) + end + end + end + end + end + -- in base al tipo e al numero geometrie, vedo se invertire une sola geometria + if #tGeomThruUp == 1 and #tGeomBlindUp == 0 and #tGeomBlindDw > 1 then -- se condizione per invertire l'unica geometria UP + MB.InvertGeom(tGeomThruUp[1]) + end + if #tGeomThruDw == 1 and #tGeomBlindDw == 0 and #tGeomBlindUp > 1 then -- se condizione per invertire l'unica geometria UP + MB.InvertGeom(tGeomThruDw[1]) + end + elseif not bFirstStep and not bShiftMchng then -- se porta ribaltata + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) + + -- se è una porta + if not bFrame then + -- se flag non ancora settato e trovata geometria e l'associazione è shiftata + -- setto il flag di disposizione iniziale Traslata + if not bSmallShiftedDoor and #EntList > 0 and + tLocMach[i].Shift and tLocMach[i].Shift > 0 then + bSmallShiftedDoor = true + end + end + end + end + end + end + + -- se porta da disposrre subito traslata setto i flag + if bSmallShiftedDoor then + bShiftMchng = true -- porta traslata + bGenFirstStep = true -- flag per saltare il primo giro + end + end + + + ----------------------- + -- *** Disposizione *** + ----------------------- + + if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or + sSwing == 'LH' or sSwing == 'LHI' or sSwing == 'LHA' then + bPush = true + else + bPush = false + end + + if v == 1 then -- solo il primo pezzo + + -- Scelta della tavola + sTab = 'Tab' + EgtSetTable( sTab) + + -- Origine tavola corrente rispetto a Zero macchina + tabOri = EgtGetTableRef( 1) + end + + -- Rotazione porta in base alla macchina + bMoveRaw = false + local nCodeVacDisp = 0 + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- se non c'è il parametro considero la porta come se avesse bevel down + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. tostring( nNumPhase) + elseif nNumPhase then + sNumPhase = tostring( nNumPhase) + else + sNumPhase = '0' + end + + if bFirstStep then + + local bOkDisp = false + + if bFrame then + bOkDisp = true + bFlip = false + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not bAtRight) + if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto + if bPush then + bTopOnRight = not bTopOnRight + end + elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso + if bPush then + bTopOnRight = not bTopOnRight + end + end + else + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure + if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if sHingeTrim == 'BD' and bPush and + string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BD' and not bPush and + string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and not bPush and + string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and bPush and + string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( sHingeTrim == 'BD' and bPush) or ( sHingeTrim == 'BU' and not bPush) then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) + if ( sLockTrim == 'BD' or sLockTrim == 'BU') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sLockTrim == 'BD' and bPush and + string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sLockTrim == 'BD' and not bPush and + string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BU' and not bPush and + string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sLockTrim == 'BU' and bPush and + string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( sLockTrim == 'BD' and bPush) or ( sLockTrim == 'BU' and not bPush) then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore + if sSecure and string.upper(sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + sSecure = tMainTabPar.LS + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if sSecure and string.upper(sSecure) == 'UP' then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif sSecure and string.upper(sSecure) == 'DN' then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) qualla di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + -- se porta a tirare non la ribalto perchè si presta già ad essere bevel down + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + else -- in base alle geometrie trovate ribalto o meno la porta + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + else -- altrimenti vecchio metodo + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + end + end + end + +--[[ metodo precedente: lato hinge sempre davanti e lato top decide se sempre destra o sinistra + + -- setto il lato top dove va a finire + bTopOnRight = CalcTopPosition( tMainTabPar.TDD, bAtRight) + + -- in base alla posizione del top calcolo se ribaltare la porta per avere il lato cerniere sul davanti + if (bTopOnRight and bAtRight) or ( not bTopOnRight and not bAtRight) then -- se top a destra + bFlip = true + else + bFlip = false + end + end +]]-- + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sAssemb == 'framesx' then + if bPush then + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + end + end + elseif sAssemb == 'framedx' then + if bPush then + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + end + else + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + elseif sAssemb == 'frametop' then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) + nCodeVacDisp = 2 + elseif sAssemb == 'framebot' then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) + end + + if v == #tPz then -- solo all'ultimo pezzo + -- se porta da traslare setto lo shift da applicare + if bShiftMchng then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + local nNumProbeZ + -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto + if nProbeMode == 1 and nNumProperties == 0 then + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimenenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + end + -- mi tengo via il numero di probe in Z + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbePoint') + end + else -- se non c'è il probe point o c'è una proprietà, elimino tutti i percorsi di probe (in Z) + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + end + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local vExtraYDelta + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ + local nSideOppoType = -1 -- 0 per profili SQ + local sProfName + local sProfOppoName -- nome profilo lato opposto alla battuta + local bHingeOnRef + local bCalcProf = false + local bCalcProfOppo = false + + -- per i frame non calcolo distanza profilo su finito + if bFrame then + bCalcProf = false + bCalcProfOppo = false + else + + -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota + if bHingeMach then + nHingeMach = 1 + end + -- se profilo lock da lavorare setto la variabile per la nota + if bLockMach then + nLockMach = 1 + end + + -- se il profilo hinge è in battuta + if ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or + ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight) then + sProfName = sHingeTrim + sProfOppoName = sLockTrim + bHingeOnRef = true + -- se il profilo hinge non è da lavorare o è una skinned + if not bHingeMach or nNumProperties == 1 then + bCalcProf = true + end + -- se il profilo lock non è da lavorare o è una skinned + if not bLockMach or nNumProperties == 1 then + bCalcProfOppo = true + end + else -- altrimenti è il profilo lock in battuta + sProfName = sLockTrim + sProfOppoName = sHingeTrim + bHingeOnRef = false + -- se il profilo lock non è da lavorare o è una skinned + if not bLockMach or nNumProperties == 1 then + bCalcProf = true + end + -- se il profilo hinge non è da lavorare o è una skinned + if not bHingeMach or nNumProperties == 1 then + bCalcProfOppo = true + end + end + + if nProbeMode == 2 then + bCalcProf = false + bCalcProfOppo = false + end + end + + -- se devo calcolare eventuale spostamento dato dal profilo in battuta + if bCalcProf then + if sProfName == 'SQ' then + nSideType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sProfName == 'BD' then + nSideType = 1 + if dThickDoor > tMainTabPar.AR then + dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 + end + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up uso il riferimento in basso + elseif sProfName == 'BU' then + nSideType = 2 + dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sProfName == '1B' or sProfName == '2B' or + sProfName == '3B' or sProfName == '4B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then + dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > tMainTabPar.AR then + dAltcalc = dAltProf - tMainTabPar.AR + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sProfName == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = (tMainTabPar.TR/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProf*dAltProf)) + + -- se riferimento è sul max ingombro porta + if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = tMainTabPar.AR - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = dRadiusPrf - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + end + + if bCalcProfOppo then + if sProfOppoName == 'SQ' then + nSideOppoType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfOppoName == 'BD' then + nSideOppoType = 1 + -- calcolo errore del probe tastando a metà spessore - il parametro z extra p + dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + -- se disposizione bevel up uso il riferimento in basso + elseif sProfOppoName == 'BU' then + nSideOppoType = 2 + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + -- se profilo bull nose verifico in base al raggio + elseif sProfOppoName == '1B' or sProfOppoName == '2B' or + sProfOppoName == '3B' or sProfOppoName == '4B' then + + nSideOppoType = 3 + -- se profilo convex verifico in base al raggio + elseif sProfOppoName == 'CV' then + + nSideOppoType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProfOppo = dThickDoor/2 + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = dRadiusPrf - dExtraYOppo + end + end + + -- in base alle proprietà della porta inserisco delle note relative al tipo di personalizzazione richiesta + -- se porta con proprietà extruded + if nNumProperties == 2 then + + local dOverMatOnHead = 0 + + -- in base alla disposizione della porta recupero il sovramateriale del lato di testa contro i riferimenti + if ( DISPMODE > 0 and bTopOnRight) or ( DISPMODE < 0 and not bTopOnRight) then -- se porta disposta a sinistra + dOverMatOnHead = dBottomOffs + else + dOverMatOnHead = dTopOffs + end + + -- scrivo le note relative alla proprietà della porta e le altre note + EgtSetInfo( Pz, 'PropertiesApplied', tMainTabPar.P2P2) + EgtSetInfo( Pz, 'OverMatOnHeadRef', dOverMatOnHead) + EgtSetInfo( Pz, 'FinalDoorLength', dLengthDoor) + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition', DISPMODE) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + -- scrivo nota con numero geometrie di ProbeZ + EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) + + local vExtraXY + local dExtraX = 0 + dExtraY = 0 + local nCorner = MCH_CR.BL + + if sAssemb == 'framesx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framedx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'frametop' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framebot' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + else + + -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) + + if nProbeMode == 2 then + local btempX = EgtIf( bTopOnRight, bFlip, not bFlip) + bMoveRaw = EgtMoveRawPart( nRaw, Vector3d( EgtIf( bTopOnRight, pMinRecalc:getY(), -pMinRecalc:getY()), EgtIf( btempX, pMinRecalc:getX(), -pMinRecalc:getX()), 0)) + end + end + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + else -- se sono in ribaltamento porta + + if bFrame then + if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto + if bPush then + bTopOnRight = not bTopOnRight + end + elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso + if bPush then + bTopOnRight = not bTopOnRight + end + end + else + -- posizioni opposte + bTopOnRight = not bTopOnRightFirst + end + + bFlip = not bFlipFirst + + -- Scelta dell'origine (ora espressa rispetto Zero Tavola) + if sAssemb == 'framesx' then + if bPush then + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + else + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + end + end + elseif sAssemb == 'framedx' then + if bPush then + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + else + Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + end + else + if bTopOnRight then -- se top a destra + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) + nCodeVacDisp = 3 + end + end + elseif sAssemb == 'frametop' then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) + nCodeVacDisp = 2 + elseif sAssemb == 'framebot' then + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) + nCodeVacDisp = 1 + else + Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) + end + + if v == #tPz then -- solo all'ultimo pezzo + -- se porta da traslare setto lo shift da applicare + if bShiftMchng then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftMchng then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end +-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local vExtraYDelta + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ + local nSideOppoType = -1 -- 0 per profili SQ + local sProfName -- nome profilo in battuta + local sProfOppoName -- nome profilo lato opposto alla battuta + local bHingeOnRef + local bCalcProf = false + local bCalcProfOppo = false + + -- per i frame non calcolo distanza profilo su finito + if bFrame then + bCalcProf = false + bCalcProfOppo = false + else + + -- se profilo hinge è da lavorare e non è stato lavorato setto il valore della nota + if bHingeMach and not DGD.MHS then + nHingeMach = 1 + end + -- se profilo lock é da lavorare e non è stato lavorato setto la variabile per la nota + if bLockMach and not DGD.MLS then + nLockMach = 1 + end + + -- se il profilo hinge è in battuta + if ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or + ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight) then + sProfName = sHingeTrim + sProfOppoName = sLockTrim + bHingeOnRef = true + -- se il profilo hinge non è da lavorare o è già stato lavorato + if not bHingeMach or DGD.MHS then + bCalcProf = true + end + -- se il profilo lock non è da lavorare o è già stato lavorato + if not bLockMach or DGD.MLS then + bCalcProfOppo = true + end + else -- altrimenti è il profilo lock in battuta + sProfName = sLockTrim + sProfOppoName = sHingeTrim + bHingeOnRef = false + -- se il profilo lock non è da lavorare o è già stato lavorato + if not bLockMach or DGD.MLS then + bCalcProf = true + end + -- se il profilo hinge non è da lavorare o è già stato lavorato + if not bHingeMach or DGD.MHS then + bCalcProfOppo = true + end + end +--[[ + -- se il profilo in battuta non è da lavorare o è già stato lavorato + if ( not bHingeMach or DGD.MHS) and ( ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or + ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight)) then + sProfName = sHingeTrim + sProfOppoName = sLockTrim + bHingeOnRef = true + bCalcProf = true + elseif ( not bLockMach or DGD.MLS) and ( ( not bFlip and bTopOnRight and bAtRight) or ( not bFlip and not bTopOnRight and not bAtRight) or + ( bFlip and bTopOnRight and not bAtRight) or ( bFlip and not bTopOnRight and bAtRight)) then + sProfName = sLockTrim + sProfOppoName = sHingeTrim + bHingeOnRef = false + bCalcProf = true + end +]]-- + end + + -- se devo calcolare eventuale spostamento dato dal profilo in battuta + if bCalcProf then + if sProfName == 'SQ' then + nSideType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfName == 'BU' then + nSideType = 1 + if dThickDoor > tMainTabPar.AR then + dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 + end + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso + elseif sProfName == 'BD' then + nSideType = 2 + dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sProfName == '1B' or sProfName == '2B' or + sProfName == '3B' or sProfName == '4B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then + dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > tMainTabPar.AR then + dAltcalc = dAltProf - tMainTabPar.AR + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sProfName == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = (tMainTabPar.TR/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProf*dAltProf)) + + -- se riferimento è sul max ingombro porta + if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = tMainTabPar.AR - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore +-- dDeltaProbe = dRadiusPrf - dExtraY +-- dDeltaProf = dRadiusPrf - dMaxInsPrf + dDeltaProbe = dRadiusPrf - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + end + + if bCalcProfOppo then + if sProfOppoName == 'SQ' then + nSideOppoType = 0 + -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto + elseif sProfOppoName == 'BU' then + nSideOppoType = 1 + -- calcolo errore del probe tastando a metà spessore - il parametro z extra p + dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso + elseif sProfOppoName == 'BD' then + nSideOppoType = 2 + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + elseif sProfOppoName == '1B' or sProfOppoName == '2B' or + sProfOppoName == '3B' or sProfOppoName == '4B' then + + nSideOppoType = 3 + -- se profilo convex verifico in base al raggio + elseif sProfOppoName == 'CV' then + + nSideOppoType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProfOppo = dThickDoor/2 + -- calcolo il delta Y + dExtraYOppo = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = dRadiusPrf - dExtraYOppo + end + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + -- se sono ancora nella prima fase e non sono state fatte lavorazioni allora setto le note + -- ancora per la prima disposizione + if nNumPhase and nNumPhase == 1 and nNumMach == 0 then + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition', DISPMODE) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + else + EgtSetInfo( Pz, 'ExtraCalcMoveY_2', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY_2', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ_2', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProfErrorY_2', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY_2', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition_2', DISPMODE) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach_2', nHingeMach) + -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) + EgtSetInfo( Pz, 'SideHingeProf_2', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef_2', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo_2', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach_2', nLockMach) + end + local vExtraXY + local dExtraX = 0 + dExtraY = 0 + local nCorner = MCH_CR.BL + + if sAssemb == 'framesx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framedx' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'frametop' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + elseif sAssemb == 'framebot' then + dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) + vExtraXY = Vector3d( dExtraX, dExtraY, 0) + -- Muovo frame nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) + else + -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) + end + end + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[528]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + if bFirstStep then + if bShiftMchng then + sNotePhase = 'SHIFT' + else + sNotePhase = 'NORMAL' + end + else + if bShiftMchng then + sNotePhase = 'FLIPSHIFT' + else + sNotePhase = 'FLIP' + end + end + + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'DoorOnTable_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sNotePhase) + -- salvo note per porta ribaltata rispetto al ddf e per disposizione lato top + EgtSetInfo( Pz, 'DispPhase_' .. tostring(nNumPhase) , EgtIf( bFlip, 'F', 'N')) + EgtSetInfo( Pz, 'DispTopOn_' .. tostring(nNumPhase) , EgtIf( bTopOnRight, 'R', 'L')) + + if bFlip then -- se porta capovolta + if bTopOnRight then -- se top a destra + -- il lato sinistro appoggia sui riferimenti + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato destro appoggia sui riferimenti + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) + end + else -- altrimenti non è capovolta + if bTopOnRight then -- se top a destra + -- il lato destro appoggia sui riferimenti + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato sinistro appoggia sui riferimenti + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) + end + end + + -- se frame riassegno il valore del sovramateriale perchè viene tenuto a filo della ventosa + if bFrame then + if nCodeVacDisp == 1 then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR1f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR2f:getX() - tMainTabPar.OR2:getX())) + elseif nCodeVacDisp == 2 then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR3f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR4f:getX() - tMainTabPar.OR2:getX())) + elseif nCodeVacDisp == 3 then + OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR5f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR6f:getX() - tMainTabPar.OR2:getX())) + end + end + + ---------------------------------------- + -- Inserimento riferimenti e ventose + ---------------------------------------- + + if v == 1 then + -- Offset ventose da bordo pezzo in Y +-- dVacOffs = 65.0 -- utilizzo il valore della nota perchè è ridondante + -- Offset barra riferimenti mobile da riferimenti quando posizione 0 + dMobOffs2 = 0 + dMobOffs1 = dMobOffs2 / 2 -- è in posizione intermedia + -- Lunghezza minima per alzare prima ventosa da bordo sinistro + -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) +-- dDistMinX = 296.8 + 5.5 + 46.7 + -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza + dDistMinX = tMainTabPar.DVL + 92.075 + DIST_MIN_VAC + -- Lunghezza minima per alzare prima ventosa da bordo destro + -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) +-- dDistMaxX = 185.1 + 5.5 + 46.7 + -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza + dDistMaxX = tMainTabPar.DVR + 92.075 + DIST_MIN_VAC + -- Posizione ventose in alto + dVacOn = 1 + -- Interasse ventose + dInterAx = 193.68 + -- Interasse minimo gruppi ventose + dMinDistGroup = 139.5 + -- setto modaità due barre disabilitato + bUseOnly2Bars = false + + -- Ventose + nTabId = EgtGetTableId( 'Tab') + nMobId1 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE1') + nMobId2 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE2') + nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') + nDispId = EgtGetPhaseDisposition( nNumPhase) + + -- se gruppi richiesti non trovati + if not nMobId1 or not nMobId2 or not nFixId then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' + break + end + + -- Posizionamento barra mobile + -- fisso + dFixval = EgtGetInfo( nFixId, 'Val', 'd') + -- mobile 2 + dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') + local dNewVal + + if bFrame then -- se è un frame + dNewVal_2 = tMainTabPar.FPB + dNewVal = dNewVal_2 + nIndexPin = 11 + else + dNewVal = b3Solid:getDimX() - dFixval + OffsYSovr + vShift:getY() + vShiftVac:getY() - dMobOffs2 + -- aggiusto la posizione per i valori fissi del regolatore manuale + dNewVal_2, nIndexPin = GetCorrectedIndexedAxis( dNewVal) + end + + -- Se posizione raggiungibile + if dNewVal_2 and ( dNewVal_2 - dFixval) >= ( 2 * dMinDistGroup) then + -- mobile 2 + EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId2, 'Val', dNewVal_2) + EgtSetInfo( nDispId, 'MOB2', dNewVal_2) + EgtSetInfo( nDispId, 'PINPOS', nIndexPin) + -- mobile 1 + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + dNewVal_1 = ( dNewVal_2 + dFixval) / 2 + EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId1, 'Val', dNewVal_1) + EgtSetInfo( nDispId, 'MOB1', dNewVal_1) + else + -- controllo se con due barre è possibile + if ( dNewVal - dFixval) >= dMinDistGroup then + -- mobile 1 +-- dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + dNewVal_1 = dNewVal +-- EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) +-- EgtSetInfo( nMobId1, 'Val', dNewVal_1) +-- EgtSetInfo( nDispId, 'MOB1', dNewVal_1) + -- mobile 2 + dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') + dNewVal_2 = (dNewVal_1 * 2) - dFixval + -- ri-aggiusto la posizione per i valori fissi del regolatore manuale + dNewVal_2, nIndexPin = GetCorrectedIndexedAxis( dNewVal_2) + + if not dNewVal_2 then + -- verifico se numero di ventose sufficienti e do errore nel caso contrario + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[633] + if not bOk then break end + end + + EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId2, 'Val', dNewVal_2) + EgtSetInfo( nDispId, 'MOB2', dNewVal_2) + EgtSetInfo( nDispId, 'PINPOS', nIndexPin) + -- ricalcolo la posizione della barra intermedia mobile 1 + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + dNewVal_1 = ( dNewVal_2 + dFixval) / 2 + EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId1, 'Val', dNewVal_1) + EgtSetInfo( nDispId, 'MOB1', dNewVal_1) + bUseOnly2Bars = true + else + -- mobile 2 + EgtSetInfo( nDispId, 'MOB2', dOldVal) + -- mobile 1 + dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') + EgtSetInfo( nDispId, 'MOB1', dOldVal) + EgtSetInfo( nDispId, 'PINPOS', 0) + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[633] + if not bOk then break end + end + end + end + + -- Elevazione ventose con: altezza porta ( uso getDimY perchè presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa + dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( DISPMODE > 0, dDistMinX, dDistMaxX) + + -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto + StartVacVerify( Ls, bFlip, nProbeMode) + + -- ciclo sulle ventose + local nInd = 1 + local nNumTotVacRow = 15 + -- tabelle per gestione conteggi inserimento ventose, gli indici tabella sono le barre (1 fissa, 2 intermedia, 3 mobile) + local tnCountFailed = {} -- tabella conteggio ventose non disposte + tnCountFailed[1] = 0 + tnCountFailed[2] = 0 + tnCountFailed[3] = 0 + local tnIniFailed = {} -- tabella conteggio ventose iniziali non disposte + tnIniFailed[1] = 0 + tnIniFailed[2] = 0 + tnIniFailed[3] = 0 + local tnMiddleFailed = {} -- tabella conteggio ventose intermedie non disposte + tnMiddleFailed[1] = 0 + tnMiddleFailed[2] = 0 + tnMiddleFailed[3] = 0 + local tnEndFailed = {} -- tabella conteggio ventose finali non disposte + tnEndFailed[1] = 0 + tnEndFailed[2] = 0 + tnEndFailed[3] = 0 + local tnMaxIniFailed = {} -- tabella contatore totale ventose iniziali non disposte + tnMaxIniFailed[1] = 0 + tnMaxIniFailed[2] = 0 + tnMaxIniFailed[3] = 0 + local tnMaxMiddleFailed = {}-- tabella contatore totale ventose intermedie non disposte + tnMaxMiddleFailed[1] = 0 + tnMaxMiddleFailed[2] = 0 + tnMaxMiddleFailed[3] = 0 + local tnMaxEndFailed = {} -- tabella contatore totale ventose finali non disposte + tnMaxEndFailed[1] = 0 + tnMaxEndFailed[2] = 0 + tnMaxEndFailed[3] = 0 + -- tabelle gestione ventose, gli indici tabella rappresentano le barre (1 fissa, 2 intermedia, 3 mobile) + local tsBaseNamePnt = {} -- tabella nomi punti ventosa base + tsBaseNamePnt[1] = 'CEN1V' + tsBaseNamePnt[2] = 'CEN1V' + tsBaseNamePnt[3] = 'CEN1V' + local tdBaseRadiusPnt1 = {} -- tabella con valori raggio interferenza da punti controllo ventosa primo tipo + tdBaseRadiusPnt1[1] = 41.275 + tdBaseRadiusPnt1[2] = 51.275 + tdBaseRadiusPnt1[3] = 41.275 + local tsBaseNameVac_1 = {} -- tabella nomi ventose primo tipo normale + tsBaseNameVac_1[1] = 'VAC2_FIX' + tsBaseNameVac_1[2] = 'VAC_MOB1' + tsBaseNameVac_1[3] = 'VAC2_MOB2' + local tsBaseNameVacSld_1 = {} -- tabella nomi ventose primo tipo con disegno dispositivo alzapezzo + tsBaseNameVacSld_1[1] = 'VAC2_FIX_SLD' + tsBaseNameVacSld_1[2] = 'VAC_MOB1_SLD' + tsBaseNameVacSld_1[3] = 'VAC2_MOB2_SLD' + local tsBaseNamePnt2 = {} -- tabella nomi punti ventosa secondo tipo + tsBaseNamePnt2[1] = 'CEN2V' + tsBaseNamePnt2[2] = 'CEN2V' + tsBaseNamePnt2[3] = 'CEN2V' + local tdBaseRadiusPnt2 = {} -- tabella con valori raggio interferenza da punti controllo ventosa secondo tipo + tdBaseRadiusPnt2[1] = 31.750 + tdBaseRadiusPnt2[2] = 51.275 -- non usata attualmente sulla batta centrale + tdBaseRadiusPnt2[3] = 31.750 + local tsBaseNameVac_2 = {} -- tabella nomi ventose secondo tipo normale + tsBaseNameVac_2[1] = 'VAC_FIX_2' + tsBaseNameVac_2[2] = 'VAC_MOB1_2' -- non usata attualmente sulla batta centrale + tsBaseNameVac_2[3] = 'VAC_MOB2_2' + local tsBaseNameVacSld_2 = {} -- tabella nomi ventose secondo tipo con disegno dispositivo alzapezzo + tsBaseNameVacSld_2[1] = 'VAC_FIX_SLD_2' + tsBaseNameVacSld_2[2] = 'VAC_MOB1_SLD_2' + tsBaseNameVacSld_2[3] = 'VAC_MOB2_SLD_2' + local tsBaseNameVac = {} -- tabella nomi ventose tipo unificato normale + tsBaseNameVac[1] = '' + tsBaseNameVac[2] = '' + tsBaseNameVac[3] = '' + local tsBaseNameVacSld = {} -- tabella nomi ventose unificato con disegno dispositivo alzapezzo + tsBaseNameVacSld[1] = '' + tsBaseNameVacSld[2] = '' + tsBaseNameVacSld[3] = '' + --------------------------------------- + local tsNoteRow = {} -- tabella per note da assegnare alle geometrie delle barre + tsNoteRow[1] = '' + tsNoteRow[2] = '' + tsNoteRow[3] = '' + -- questa tabella deve essere settata in base ai sottopezzi presenti nella cartella della macchina + -- e al disegno della macchina: deve avere i punti con i nomi geometria indicati da tsBaseNamePnt, tsBaseNamePnt2, ecc. + local tnNumVacInsert = {} -- tabella per numero di tipi di ventosa presenti sulle barre + tnNumVacInsert[1] = 1 + tnNumVacInsert[2] = 1 + tnNumVacInsert[3] = 1 + local tnNumKindVac = {} -- tabella che indica il tipo di ventosa corrente + tnNumKindVac[1] = 1 + tnNumKindVac[2] = 1 + tnNumKindVac[3] = 1 + --------------------------------------- + -- tabella posizionamento ventose + local tPosRowSubPieceRow1 = {} + local tPosRowSubPieceRow2 = {} + local tPosRowSubPieceRow3 = {} + local tdYCommpos = {} -- tabella valori Y con sottopezzi identici + + while dCalcLen > 0 and nInd <= nNumTotVacRow do + + local nIndVac = EgtIf( DISPMODE > 0, nInd, ( nNumTotVacRow - nInd + 1)) + + local sInd = tostring( nIndVac) + + if nCodeVacDisp <= 1 then + + tPosRowSubPieceRow1[nIndVac] = CalcDispositionSubPieces( 1, nFixId, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, + sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, + tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, + nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, + tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 2 then + + local nIdVac = 2 + if bUseOnly2Bars then + nIdVac = 3 + end + + tPosRowSubPieceRow2[nIndVac] = CalcDispositionSubPieces( nIdVac, nMobId1, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, + sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, + tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, + nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, + tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) + end + + if ( nCodeVacDisp == 0 or nCodeVacDisp == 3) and not bUseOnly2Bars then + + tPosRowSubPieceRow3[nIndVac] = CalcDispositionSubPieces( 3, nMobId2, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, + sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, + tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, + nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, + tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) + end + + -- aggiorno la lunghezza di calcolo e l'indice + dCalcLen = dCalcLen - dInterAx + nInd = nInd + 1 + end -- end while + + -- elimino geometrie per verifica + EndVacVerify() + + for l = 1, nNumTotVacRow do + + local nIndVac = EgtIf( DISPMODE > 0, l, ( nNumTotVacRow - l + 1)) + + if nCodeVacDisp <= 1 then -- porta o frame su prima linea vicino a riferimenti + DispositionSubPieces( 1, nIndVac, tPosRowSubPieceRow1, tMainTabPar.FVR, tsBaseNameVac, + tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, + tsBaseNameVacSld_2, nIndVac, tabOri, tsNoteRow, nDispId) + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 2 then -- porta o frame su linea intermedia + local nIdVac = 2 + if bUseOnly2Bars then + nIdVac = 3 + end + DispositionSubPieces( nIdVac, nIndVac, tPosRowSubPieceRow2, tMainTabPar.FVR, tsBaseNameVac, + tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, + tsBaseNameVacSld_2, ( nIndVac + 1), tabOri, tsNoteRow, nDispId) + end + + if nCodeVacDisp == 0 or nCodeVacDisp == 3 then -- porta o frame su ultima linea lontana dai riferimenti + DispositionSubPieces( 3, nIndVac, tPosRowSubPieceRow3, tMainTabPar.FVR, tsBaseNameVac, + tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, + tsBaseNameVacSld_2, nIndVac, tabOri, tsNoteRow, nDispId) + end + end + + -- scrivo nota linea di ventose + if string.len( tsNoteRow[1]) > 0 then + EgtSetInfo( Pz, 'FixVacRow_Phase_'..tostring(nNumPhase), tsNoteRow[1]) + end + if string.len( tsNoteRow[2]) > 0 then + EgtSetInfo( Pz, 'Mob1VacRow_Phase_'..tostring(nNumPhase), tsNoteRow[2]) + end + if string.len( tsNoteRow[3]) > 0 then + EgtSetInfo( Pz, 'Mob2VacRow_Phase_'..tostring(nNumPhase), tsNoteRow[3]) + end + + -- scrivo note con i valori di partenza della prima ventosa in basso a destra + EgtSetInfo( Pz, 'FixValX', tMainTabPar.DVR) + EgtSetInfo( Pz, 'FixValY', dFixval) + + -- verifico se numero di ventose sufficienti e do errore nel caso contrario + bOk, DGD.EMC = CheckEnoughVacuums( ( nInd - 1), nCodeVacDisp, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, bUseOnly2Bars) + if not bOk then break end + + ---------------------- + ---------------------- + -- *** Lavorazioni *** + ---------------------- + ---------------------- + + local bMakeGhost = EgtIf( bFirstStep, true, false) + local tSideMachDoor={} + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + if v == 1 then -- solo il primo pezzo + -- print Machining table + for i = nIndexStartMach, #tLocMach do + DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + end + end + + -- solo il primo giro aggiusto i profili bevel per essere coerente con la sequenza di tabella + if bFirstStep and ( not bShiftMchng or bSmallShiftedDoor) and nProbeMode ~= 1 then + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then +-- MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf) + MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep) + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + if v == 1 then -- solo il primo pezzo + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + end + + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sottp + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + end +-- local bEnBreak = false + bEnBreak = false + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = nIndexStartMach, #tLocMach do + + -- se devo uscire dal ciclo + if bEnBreak then break end + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local sHide = EgtIf( bFirstStep, '','_HIDE') + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide) + -- Applico le lavorazioni + for j = 1, #EntList do + + local nNewIdEnt + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then + + bLocMach, _, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf, bMakeGhost) +-- bLocMach, _, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, nil, bMakeGhost) + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 12) + end + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 11) + end + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + if not bInsLav then + nNumMachSkipResult = nNumMachSkip + 1 + EgtSetInfo( nNewIdEnt, 'Mach', 13) + end + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if string.len( tsMachProf[v]) > 0 then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) + elseif string.lower( sEdge) == 'bottom' then + tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) + end + elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + else + bOk = false + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' or tLocMach[i].Oper == 'AdjPrfThrouCurve' and + ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then + + if tLocMach[i].Oper == 'AdjustThrouCurve' then + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) + else -- altrimenti + bLocMach, nNewIdEnt = MB.AdjPrfThrouCurve( EntList[j], bMakeGhost, tsProperties, tMainTabPar.P2P1, bNoVertProf, bFirstStep, tLocMach[i].Name) +-- bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveOld( EntList[j], bMakeGhost, tsProperties, tMainTabPar.P2P1) + end + + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + nNumMachSkipResult = nNumMachSkip + 1 + end + + -- se la lavorazione è applicabile e non scatena lo shift +-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if string.len( tsMachProf[v]) > 0 then + if not string.find( tsMachProf[v], sEdge) then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + end + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) + elseif string.lower( sEdge) == 'bottom' then + tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) + end + elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + else + bOk = false + end + nNumMachSkip = nNumMachSkipResult + end +--[[ + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end +]]-- + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouCurveInt' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) + + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + nNumMachSkipResult = nNumMachSkip + 1 + end + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if string.len( tsMachProf[v]) > 0 then + if not string.find( tsMachProf[v], sEdge) then + tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge + end + else + tsMachProf[v] = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then + dOffsLoc = dThickDoor * TAN3 + end + tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) + elseif string.lower( sEdge) == 'top' then + tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) + elseif string.lower( sEdge) == 'bottom' then + tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) + end + elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + else + bOk = false + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' and nProbeMode ~= 1 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo AdjustThrouIsle non dovrebbe restituire il 3 + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione non è applicabile + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillX' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillY' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' and nProbeMode ~= 1 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE) + if bLocMach then + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertHole' and nProbeMode ~= 1 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo AdjustVertHole non dovrebbe restituire il 3 + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione non è applicabile + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustHole' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjPreHoleAndPocket( EntList[j], bMakeGhost, tsProperties, {tMainTabPar.P2P2, tMainTabPar.P2P1}) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustProbeHole' and nProbeMode == 1 and nNumProperties == 0 then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, false, bMakeGhost) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then -- il metodo AdjustProbeHole non dovrebbe restituire il 3 + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile setto la nota sul pezzo + if bInsLav then + EgtSetInfo( Pz, 'ExistsProbeZ', true) -- presenza del probe in Z + else -- altrimenti la lavorazione non è applicabile + + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) + else + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + end + + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + end + end + else -- se nessuna operazione + if nProbeMode ~= 1 then + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + end + end + + -- LAVORAZIONI + + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + local bScroll = true + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + -- se prima lavorazione, valida, con chiave Shift abilitata, esco dal giro +--[[ + if ( nMach > 0 and nMach < 10) and + not bShiftMchng and + tLocMach[i].Shift == 1 then + + bShiftMchng = true -- flag per traslazione Y + nIndexStartMach = i -- ripartenza da questa posizione + bScroll = false -- salto l'applicazione delle lavorazioni in seguito + bEnBreak = true -- blocco il for della scansione tabella + -- se fase di ripresa rimetto la nota mach disabilitata + if not bFirstStep then + nMach = nMach + 10 + EgtSetInfo( EntList[j], 'Mach', nMach) + nNumMachSkip = nNumMachSkip + 1 + end + end +--]] + + if not bScroll then + break -- esco dal ciclo for j + else + if nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, NOT_GEN_MACH) + else + DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') .. + EgtDoorsMsg[596]..tostring( nNumPhase), 0) + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end + end -- end for + + local i = 1 + while i <= #tLocMachOrd and not bEnBreak do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGroup = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGroup, sProperty) + + if sProperty then -- se esiste proprietà del gruppo + + if sProperty == 'MinDist' or sProperty == 'MinDistByPiece' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local nPz + local nTotPz + + if sProperty == 'MinDistByPiece' then + nTotPz = #tPz + else + nTotPz = 1 + end + + for v = 1, nTotPz do + + local nPz + + if sProperty == 'MinDistByPiece' then + nPz = tPz[v] + else + nPz = tPz + end + + local tMachining = {} + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( nPz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 o 2 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se è fuori range o non corrispondono le lavorazioni + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGroup, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH, tMachining) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + end -- end for + elseif sProperty == 'Layer' then -- lavorazione layer + + for v = 1, #tPz do + + local nPz = tPz[v] + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, nPz, '_HIDE') + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGroup, nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach) + end + end -- end for + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( tPz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGroup, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + end + end + + i = i + 1 + end + + -- se ci sono state lavorazioni accodo la disposizione delle fase + if nNumMach > 0 then + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + end + + -- se sono al primissimo giro + if not bGenFirstStep then + + -- la lavorazione di traslazione ha priorità sul ribaltamento + -- se trovata traslazione setto il flag per il prossimo giro + if bShiftMchng then + bGenFirstStep = true + if not bFirstStep then -- se sono già in ripresa porta resetto il contatore di lavorazioni saltate + nNumMachSkip = 0 -- resetto per il prossimo giro + end + else + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + -- con lavorazioni skippate ma già con pezzo non i prima face e non shiftato, esco + if not bFirstStep then + bWork = false + else + bFirstStep = false + end + nNumMachSkip = 0 -- resetto per il prossimo giro + end + end + else -- altrimenti ho già fatto un giro e ho trovato la traslazione + -- se nessuna geometria skippata esco + if nNumMachSkip == 0 then bWork = false end + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + if bFirstStep then -- se ho terminato il giro con eventuale traslazione disabilito la traslazione + -- disativo la traslazione sul giro successvo + bShiftMchng = false + -- disattivo il flag che indica di disporre la porta subito traslata + bSmallShiftedDoor = false + end + bFirstStep = false + end + end + + -- controllo di sicurezza + if nNumCycle > 4 then bWork = false end + + nNumCycle = nNumCycle + 1 + end -- end while + + -------------------------- + -------------------------- + -- *** Tools Setup *** + -------------------------- + -------------------------- + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + bSetUp = EgtImportSetup() + sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], ' ') .. ' (from Default)' + end + + -- se fallito quello di default o utensili mancanti provo quelli indicati nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + local nContImport = 0 + + -- ciclo tra quelli disponibili + for k = 1, 30 do + + if not bSetUp then + if k == 1 then + sSetup = mCamData[nNumMachFromCam].Setup1 + elseif k == 2 then + sSetup = mCamData[nNumMachFromCam].Setup2 + elseif k == 3 then + sSetup = mCamData[nNumMachFromCam].Setup3 + elseif k == 4 then + sSetup = mCamData[nNumMachFromCam].Setup4 + elseif k == 5 then + sSetup = mCamData[nNumMachFromCam].Setup5 + elseif k == 6 then + sSetup = mCamData[nNumMachFromCam].Setup6 + elseif k == 7 then + sSetup = mCamData[nNumMachFromCam].Setup7 + elseif k == 8 then + sSetup = mCamData[nNumMachFromCam].Setup8 + elseif k == 9 then + sSetup = mCamData[nNumMachFromCam].Setup9 + elseif k == 10 then + sSetup = mCamData[nNumMachFromCam].Setup10 + elseif k == 11 then + sSetup = mCamData[nNumMachFromCam].Setup11 + elseif k == 12 then + sSetup = mCamData[nNumMachFromCam].Setup12 + elseif k == 13 then + sSetup = mCamData[nNumMachFromCam].Setup13 + elseif k == 14 then + sSetup = mCamData[nNumMachFromCam].Setup14 + elseif k == 15 then + sSetup = mCamData[nNumMachFromCam].Setup15 + elseif k == 16 then + sSetup = mCamData[nNumMachFromCam].Setup16 + elseif k == 17 then + sSetup = mCamData[nNumMachFromCam].Setup17 + elseif k == 18 then + sSetup = mCamData[nNumMachFromCam].Setup18 + elseif k == 19 then + sSetup = mCamData[nNumMachFromCam].Setup19 + elseif k == 20 then + sSetup = mCamData[nNumMachFromCam].Setup20 + elseif k == 21 then + sSetup = mCamData[nNumMachFromCam].Setup21 + elseif k == 22 then + sSetup = mCamData[nNumMachFromCam].Setup22 + elseif k == 23 then + sSetup = mCamData[nNumMachFromCam].Setup23 + elseif k == 24 then + sSetup = mCamData[nNumMachFromCam].Setup24 + elseif k == 25 then + sSetup = mCamData[nNumMachFromCam].Setup25 + elseif k == 26 then + sSetup = mCamData[nNumMachFromCam].Setup26 + elseif k == 27 then + sSetup = mCamData[nNumMachFromCam].Setup27 + elseif k == 28 then + sSetup = mCamData[nNumMachFromCam].Setup28 + elseif k == 29 then + sSetup = mCamData[nNumMachFromCam].Setup29 + elseif k == 30 then + sSetup = mCamData[nNumMachFromCam].Setup30 + end + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + if bSetUp then -- se importato il fle da CurrCamInfo + nContImport = nContImport + 1 + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + break + else -- se utensili mancanti prendo la lista e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else -- se non importato carico il messaggio di errore e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + end + end + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + -- se ho importato almeno un attrezzaggio do errore + if ( sDefSetUp and #sDefSetUp > 0) or + nContImport > 0 then + DGD.EMC = ' ' .. EgtDoorsMsg[551] + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + else -- setup default non definito + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + end + end + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation + + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Forzo aggiornamento calcolo assi macchina e movimenti tra lavorazioni e finale + EgtUpdateAllMachinings() + + -- Salvo progetto + EgtSaveFile() + + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..EgtIf( nProbeMode ~= 1,'.cnc','.prb'), 'EgtCam5 - '..sFilePath) + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo la disposizione nel log + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + else -- altrimenti errore cn + + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) + + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + + return false + end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup +end + +return MachiningLoc diff --git a/Machining_6.lua b/Machining_6.lua new file mode 100644 index 0000000..33b76ec --- /dev/null +++ b/Machining_6.lua @@ -0,0 +1,4207 @@ +-- +-- 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 +-- +-- by EgalWare s.r.l. 10/07/2016 +-- Machining generation for Doors program machine Multiax N1622 +-- 2017.06.01 V1.011 FM Manage machining optimization +-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece +-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining +-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole +-- 2017.12.07 V1.014 FM Change hinge shuttle assignement with 3 hinges: 60% always on shuttle near door reference, now V1.3 +-- 2017.12.08 V1.015 FM Manage two new probe pointposition , before and after the hinge/pivot to probe always on left of hinge (according to disposition) +-- 2017.12.16 V1.016 FM Change the percentage of shuttle assignement to variable dPercentDoorLength (by Adam L. requests) +-- 2017.12.28 V1.016 FM Set note about hinge side machining +-- 2017.12.28 V1.016 FM Set note about hinge side profile +-- 2017.12.28 V1.016 FM Set note about door shift on Y with hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about door probe error on hinge not machined profile on reference +-- 2017.12.28 V1.016 FM Set note about lock side machining +-- 2018.02.26 V1.0b1 FM Manage door dimension checking +-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces +-- 2018.10.18 V1.0b3 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles +-- 2018.10.23 V1.0b4 FM Manage rough machining +-- 2019.01.14 V1.0b5 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set +-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name) +-- 2019.01.23 V1.0b6 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. +-- 2019.01.24 V1.0b7 FM Extend cases to machine with AdjustHeadChisel operation, +-- use new settings to use with this extended operation: NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL +-- 2019.03.27 V1.0b8 FM Manage check door/jamb dimension by function CheckPieceDimension +-- 2019.03.27 V1.0b9 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values +-- 2019.03.27 V1.0b9 FM Modify error messages format into CheckPieceDimension +-- 2019.03.27 V1.0c1 FM Manage estimate time +-- 2019.03.29 V1.0c2 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.08 V1.0c3 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines +-- Now it uses 1 line for antisplint blade and 1 line for normal blade +-- 2019.04.08 V1.0c3 FM Manage Blade groove function AdjustBladeVertCurve +-- 2019.04.30 v1.0c4 FM Manage function AdjustASplintWithBlade to manage anti-splint paths when machine groove by blade +-- 2019.04.30 v1.0c4 FM Manage function AdjustHeadOnASplint to manage hinge anti-splint paths when machine groove by blade +-- 2019.05.28 v1.0c5 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings +-- 2019.07.22 V1.0c7 FM Manage better the updoor/underdoor machinings counter that generate flags values +-- 2019.08.27 V1.0c8 FM Manage underneath machining checking (by machining note 'UD_CHECK') to disable vacuums +-- (use new underneath distance by variable dDistInterferUnder) +-- 2019.11.05 V1.0c9 FM Manage setup files +-- 2020.03.19 V1.0d0 FM Fix error on check door dimension into CheckPieceDimension (when door is shifted by Bullnose profile on hinge side) +-- 2021.03.18 V1.0d1 FM Add new variables to CurrCamInfo that was managed inside this (dVacOffsY, dMobOffsY, dLeftDistX, dRightDistX, MaxOverMat, StepOverMat) +-- 2021.04.06 V1.0d1 FM Fix error on rename lock profile with _LK suffix +-- 2021.04.07 V1.0d2 FM Manage new CurrCamInfo parameter (ForceDirMachHinge) to force the hinge machining direction (descending or ascending) +-- 2021.04.20 V1.0d3 FM Manage new CurrCamInfo parameter (MaxPosMobBar) to limit the mobile ba to a max value with wide door +-- 2021.05.03 V2.101 FM Manage simulation in background to verify collisions, if something collide, not generate CNC program +-- 2021.05.04 V2.102 FM Manage new CurrCamInfo parameter (nDisableAutoCncName) to disable the automatic cnc name composed when generate cnc by GENERATE button +-- to have always the same cnc file name +-- 2021.05.21 V2.103 FM Manage new CurrCamInfo parameter (EnableCollisionDetect) to manage the collision detection +-- 2021.10.13 V2.104 FM Add variables from CurrCamInfo for define safeety zone around pods +-- 2021.10.26 V2.104 FM Manage FD Wedge Cup (FDWC) profile +-- 2021.10.28 V2.105 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter +-- 2021.11.23 V2.107 FM Manage option side probing. Expand function number of CurrDoorCustomData DGC.Pms: 3 side probe on all hardware (for NE machines) ; +-- 4: side probe on all hardware except hardware on hinge side (for machines with shuttles) +-- 2022.01.17 V2.108 FM Manage Split door cut by new CurrCamInfo parameter sCutDirectionAdmitted: = 'H' for cut along door Height; +-- = 'W' for cut along door Width +-- 2022.05.03 V2.109 FM use table paremeter tMainTabPar.NVP instead of variable bNoVertProf. This allow to unify Machining_4 and Machinin_8 processor +-- 2022.11.15 V2.112 FM Manage side groove region as throu path and not as blind region +-- 2023.01.20 V2.114 FM Modification to use compiled code +-- 2023.03.07 V2.115 FM Fix error on manage region into StartVacVerify function +-- 2023.03.29 V2.116 FM Fix error on calculate rough paths on Convex profile +-- 2023.03.31 V1.117 FM Manage offsetted path ( by path note) to extra path of Convex profile +-- 2023.04.03 V2.118 FM Manage Scrap piece removing +-- 2023.05.12 V2.119 FM Manage virtual milling option into collision avoid check +-- 2023.05.24 V2.120 FM Manage by new function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides +-- 2023.09.07 V2.121 FM Manage new file .tok (it's a copy of .txt file) to say Dprod when the generation is finished +-- 2023.09.15 V2.122 FM Write shift value note OffSetPhase... +-- 2023.09.16 V2.123 FM Manage invert paths on convex profile when door is dispose bevel up +-- 2023.09.19 V2.124 FM Modify door disposition: if door has top or bottom trimmed side, dispose the door on right reference +-- 2023.10.19 V2.125 FM Manage new parameter tMainTabPar.SVP to manage sand machining with 5xis head or not +-- 2023.10.25 V2.126 FM Manage new parameter tMainTabPar.DSL to add extra length on profiling machining on hinge and lock sides (if sand machining found) +-- 2023.11.16 V2.127 FM Manage new parameter tMainTabPar.DPSL to add extra length on sand machining on hinge and lock sides (if sand machining found) +-- 2023.12.01 V2.125 FM Manage small planes on Convex profile +-- 2024.05.30 V2.126 FM Manage new parameter tMainTabPar.NWD ( NarrowWidth CurrCamInfo parameter) to manage narrowest door to machine with only one head + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +local MachiningLoc = {} + +-- Librerie particolari +local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') +local MB = require( 'MachiningBase') + +-- Impostazioni Cam per consentire forature con utensile più piccolo +EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) +EgtMdbSave() +-- Criterio di disposizione porta contro riferimenti, se fisso o guidato dalla disposizione porta +-- 0: in base alla disposizione porta, 1: forzato solo a sinistra; -1: forzato solo a destra +local FORCEDISPMODE = -1 +-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) +local NO_WORK_UNDERSQUARE = false +-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) +local NO_WORK_UPSQUARE = false +-- Definizione possibilità di lavorare testa chisel rimanendo solo orizzontale o seguendo il bevel ( per teste non shuttle) +local CHISEL_ONLY_HORIZONTAL = false +-- variabili generazione lavorazioni +local GEN_MACH = false +local NOT_GEN_MACH = true +-- Variabile distanza minima tra pezzo finito e ventosa (in X) +local DIST_MIN_VAC_L = 5.5 +local DIST_MIN_VAC_R = 7.5 +local KIND_DISP_MODE = 1 -- 1: fixture, prende i sottopezzi dalla cartella fixture; 0: machine, alza i sottopezzi dal disegno della macchina +-- variabile per applicare sempre la lavorazione degli anti-scheggia fatti con gli shuttle ( >= 4 inserisce solo quelle necessarie, < 4 inserisce tutte) +-- in caso il groove sia fatto con lama +local MAXMACH = 4 +-- variabile che indica se sono state inserite lavorazioni da sotto +local bMachUnder +-- variabile dimensione porta considerata lunga che segna il diverso parcheggio dello shuttle 1 come è settata nella macro P5INIT +local Big_Dorr_Height + +local tVacType = { 'VAC_158_43_H55', 'VAC_78_43_H55'} +-- la sequenza è specchiata: il primo indice è riferito alla prima ventosa a destra, l'ultimo indice all'ultima ventosa a sinistra +local tMapVac = { 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1} +local bSandFound = false + +----------------------------------------------------------------- +-- *** Error write file *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERR == 0 then + if DGD.ERM and #DGD.ERM > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + else + if DGD.EMC and #DGD.EMC > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.EMC) + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + end + if sDispMsg and #sDispMsg > 0 then + nIdFile:write('\n' .. sDispMsg) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** Add machining combine in table for second part *** +----------------------------------------------------------------- +local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) + + if tSecMcng then + + if #tSecMcng > 0 then + + local bFound = false + MTMachLine.Row = nIndexTab + + for k = 1, #tSecMcng do + if MTMachLine == tSecMcng[k] then + bFound = true + end + end + + -- se non trovato lo inserisco + if not bFound then + table.insert( tSecMcng,MTMachLine) + end + else + MTMachLine.Row = nIndexTab + table.insert( tSecMcng,MTMachLine) + end + end + + return tSecMcng + +end + +local function SetInfoTable( tListEnt, sNameInfo, nValInfo) + + for j = 1, #tListEnt do + if tListEnt[j] then + EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) + end + end +end + +----------------------------------------------------------------- +-- *** Apply Machining by Mach number *** +----------------------------------------------------------------- +local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, + sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, + bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed ) + + local dOverL = EgtGetInfo( tEndId[1], 'OL') + local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') + local sProbeSide = EgtGetInfo( tEndId[1], 'ProbeSide') -- ProbeMachXY + local nSetMaxElev = EgtGetInfo( tEndId[1], 'SetMaxElev', 'i') + local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) + local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) + local sSetMaxElev + local sProbeSideCode + + -- determino in base alla direzione dell'entità quale codice sProbeSide dare alla lavorazione + if sProbeSide and not bNotGenMachining then + sProbeSideCode = 'CPBP' -- CORR_POS_BY_PROBE + end + -- + if nSetMaxElev and not bNotGenMachining then + sSetMaxElev = 'MaxElev=0.0' + end + if nMach == 1 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, + tMainTabPar.DPSL, tMainTabPar.NWD) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + end + -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) + if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale + bSandFound = true + end + end + -- se non genero la lavorazione + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMach) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + elseif nMach == 2 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, + tMainTabPar.DPSL, tMainTabPar.NWD) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + end + -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) + if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale + bSandFound = true + end + end + -- se non genero la lavorazione + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachUp) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + elseif nMach == 3 then + local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, + nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, + tMainTabPar.DPSL, tMainTabPar.NWD) + if nRes < 0 then -- se la lavorazione ha fallito + bOk = false + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + elseif nRes == 0 then -- se lavorazione mancante + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + if bNotGenMachining then + -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) + end + else -- lavorazione ok + if bModifyMacNote then + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + end + -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) + if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale + bSandFound = true + end + end + -- se non genero la lavorazione + if bNotGenMachining then + nNumMach = nNumMach + 1 + -- setto nota per non lavorarla di nuovo + SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) + SetInfoTable( tEndId, 'Machining', sMachDw) + else + if tMachining then + table.insert( tMachining,{nMachId,sToolName}) + end + -- cerco se nelle note ho quella per l'aggregato da sotto + if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota + local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) + if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto + SetInfoTable( tEndId, 'UnderneathMach', true) + bMachUnder = true + end + end + end + end + end + + return bOk, nNumMach, tMachining +end + +----------------------------------------------------------------- +-- *** Calc Machining for same group *** +----------------------------------------------------------------- +local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed ) + + local nParendId = EgtGetParent(nEndId) + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + local sLocMachId + local bNotGenMachining = true + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + if tLocTable[i].On ~= 0 then + + sLocMachId = tLocTable[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 + + if ( tLocTable[i].Oper == 'AdjustHead' or tLocTable[i].Oper == 'AdjustHeadOnASplint') and nMachCk > 0 and nMachCk < 10 then + + -- assegno la stessa nota nMach dell'entità del gruppo + EgtSetInfo( EntList[j], 'Mach', nMach) + -- duplico entià + local nNewEntId = MB.MakeGhostCopy( EntList[j]) + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewEntId) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Add Machining for same group *** +----------------------------------------------------------------- +local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, + nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, + dBladePerpLeadIn, dPercRedFeed) + + local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo + + -- ordinare lavorazioni navette come scritto su foglio nella documentazione + + for i = 1, #tLocTable do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) + + -- Applico le lavorazioni + for j = 1, #EntList do + + local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end + + if nMachCk > 0 and nMachCk < 10 then + + local nNewEntId = EntList[j] + local sMachining = EgtGetInfo( nNewEntId, 'Machining') + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, + tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, + GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + return bOk, nNumMach +end + +----------------------------------------------------------------- +-- *** Movimento ventose *** +----------------------------------------------------------------- +local ThroughId, BlindId +----------------------------------------------------------------- +local function StartVacVerify( nIdSolid, bFlipped, dThDoor) + -- regioni passante e cieca non definite + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + -- recupero le regioni sopra e sotto della porta messa in macchina + local UpId, DwId + local DwIdExtraBlind = {} + local sExtraBlindRegName + local DwIdExtraGrvBlind = {} + local sExtraGrvBlindRegName + local dZedToMove + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + sExtraBlindRegName = 'FLAT_UP_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_UP_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = dThDoor + else + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + -- superficie sopra + UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + sExtraBlindRegName = 'FLAT_DW_BLIND' + DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) + sExtraGrvBlindRegName = 'FLAT_DW_SD_BLIND' + DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) + dZedToMove = 0 + end + -- creo le regioni complementari + local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT) + local CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) + local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) + local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end + EgtSurfFrSubtract( CompUpId, UpId) + if not EgtExistsObj( CompUpId) then CompUpId = nil end + + local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT) + local CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) + -- faccio una copia per gli altri controlli + local DownRegId = nil + if CompDwId then + DownRegId = EgtCopyGlob( CompDwId, nIdSolid) + EgtInvertSurf( DownRegId) + end + local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) + local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) + if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end + EgtSurfFrSubtract( CompDwId, DwId) + if not EgtExistsObj( CompDwId) then CompDwId = nil end + if CompDwId then EgtInvertSurf( CompDwId) end + + -- calcolo le regioni passante e cieca + local ThroughRegId = nil + local BlindRegId = nil + -- se ci sono entrambe le regioni + if CompUpId and CompDwId then + -- per ottenere la regione passante faccio intersezione tra sopra e sotto + EgtSurfFrIntersect( CompUpId, CompDwId) + if EgtExistsObj( CompUpId) then + ThroughRegId = CompUpId + end + -- per ottenere la regione cieca faccio differenza tra sotto e passante + if ThroughRegId then + EgtSurfFrSubtract( CompDwId, ThroughRegId) + if EgtExistsObj( CompDwId) then + BlindRegId = CompDwId + end + else + BlindRegId = CompDwId + end + -- se c'è solo la regione sotto è già quella delle lavorazioni cieche + elseif CompDwId then + BlindRegId = CompDwId + -- se c'è solo la sopra, non interessa e la cancello + elseif CompUpId then + EgtErase( CompUpId) + end + -- sistemazioni finali + if ThroughRegId or #DwIdExtraGrvBlind then + ThroughId = EgtGroup( GDB_ID.ROOT) + EgtSetName( ThroughId, 'THROUGH') + EgtSetColor( ThroughId, RED()) + EgtSetLevel( ThroughId, GDB_LV.TEMP) + local nChunk = 0 + if ThroughRegId then + while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraGrvBlind do + local nIdBl = DwIdExtraGrvBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, ThroughId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + EgtErase( ThroughRegId) +-- EgtSetName( ThroughRegId, 'THROUGH') +-- EgtSetColor( ThroughRegId, RED()) +-- EgtSetLevel( ThroughRegId, GDB_LV.TEMP) + end + if BlindRegId or #DwIdExtraBlind > 0 then + BlindId = EgtGroup( GDB_ID.ROOT) + EgtSetName( BlindId, 'BLIND') + EgtSetColor( BlindId, BLUE()) + EgtSetLevel( BlindId, GDB_LV.TEMP) + local nChunk = 0 + if BlindRegId then + while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do + nChunk = nChunk + 1 + end + end + -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) + for l = 1, #DwIdExtraBlind do + local nIdBl = DwIdExtraBlind[l] + if nIdBl then + -- faccio la copia e la muovo alla Z bassa + local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) + if nTempBlndReg then + -- prendo il punto iniziale + local pCenTmp = EgtCP( nTempBlndReg) + if pCenTmp then + EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) + end + -- estraggo i contorni e li aggiungo al gruppo blind + nChunk = 0 + while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, BlindId) do + nChunk = nChunk + 1 + end + -- cancello la copia locale + EgtErase( nTempBlndReg) + end + end + end + if BlindRegId then + EgtErase( BlindRegId) +-- EgtSetName( BlindRegId, 'BLIND') +-- EgtSetColor( BlindRegId, BLUE()) +-- EgtSetLevel( BlindRegId, GDB_LV.TEMP) + end + end + if DownRegId then + FaceDwId = EgtGroup( GDB_ID.ROOT) + EgtSetName( FaceDwId, 'DWREG') + EgtSetColor( FaceDwId, BLUE()) + EgtSetLevel( FaceDwId, GDB_LV.TEMP) + local nChunk = 0 + while EgtExtractSurfFrChunkLoops( DownRegId, nChunk, FaceDwId) do + nChunk = nChunk + 1 + end + EgtErase( DownRegId) +-- EgtSetName( DownRegId, 'DWREG') +-- EgtSetColor( DownRegId, GREEN()) +-- EgtSetLevel( DownRegId, GDB_LV.TEMP) + end +end + +----------------------------------------------------------------- +local function ExecVacVerify( ptVac, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, sAngGrooveNote, + nIdSolid, bFlipped, ptVacId) + -- verifica con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferThru then + return false + end + end + nId = EgtGetNext( nId) + end + -- verifica con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferBlind then + return false + end + end + nId = EgtGetNext( nId) + end + + -- se ho delle lavorazioni da sotto + if bMachUnder then + local tUnderList = {} + tUnderList = MB.FindGeomWithNote( Pz, 'UnderneathMach', 'b', true, tUnderList) + for i = 1, #tUnderList do + local ptNear = EgtNP( tUnderList[i], ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + -- se distanza inferiore al limite ... + if dDist < dDistInterferUnder then + return false + end + end + end + end + + -- se ho groove su top angolo + if sAngGrooveNote and #sAngGrooveNote > 0 then + local tGrooveOnAng = EgtSplitString( sAngGrooveNote) + if tGrooveOnAng and #tGrooveOnAng > 0 then + for i = 1, #tGrooveOnAng do + -- prendo la prima geometria del layer + local nGrvId = EgtGetFirstInGroup( tGrooveOnAng[i]) + if nGrvId then + local ptNear = EgtNP( nGrvId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + + -- controllo che la ventosa sia al di fuori della regione + local DwId + local bDistBtwRegion + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + else + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + end + + if DwId then + bDistBtwRegion = EgtSurfFrTestExternal( DwId, ptVacId, 0.1) + end + + -- se punto ventosa esterno alla regione e distanza inferiore al limite ... + if bDistBtwRegion and dDist > min( dDistInterferThru, dDistInterferBlind, dDistInterferUnder) then + return false + end + end + end + end + end + end + + -- nessuna interferenza + return true +end + +----------------------------------------------------------------- +local function ExecVacShapeVerify( ptVac, sNameVac, tabOri, dDistThru, dDistBlind, + dDistCont, bCodeMobileVac, dRotVal, dMove2, sAngGrooveNote, + nIdSolid, bFlipped, ptVacId) + + local nShapeId + local nShapeBlindId + local nAreaId + local dMoveLoc = EgtIf( bCodeMobileVac, dMove2, 0) + local dRotLoc = EgtIf( bCodeMobileVac, dRotVal, 0) + local dMaxMov = 0 + local nRetErr = 0 + local nCustomType + + -- inserisco la ventosa e ne ottengo l'id + local nFixVac = EgtAddFixture( sNameVac, ( ptVac - tabOri), dRotLoc, dMoveLoc) + + if nFixVac then + + -- cerco l'id della geometria shape + if bCodeMobileVac then + nAreaId = EgtGetFirstNameInGroup( nFixVac, 'MOBILE') + else + nAreaId = EgtGetFirstNameInGroup( nFixVac, 'AREA') + end + + -- leggo la nota del typo custom + nCustomType = EgtGetInfo( nFixVac, 'CustomType', 'i') + + if nAreaId then + if bCodeMobileVac then -- se mobile leggo la nota di movimento massimo + dMaxMov = EgtGetInfo( nAreaId, 'MAXMOV', 'd') or 0 + end + -- cerco il nome della regione + nShapeId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE') + -- cerco il nome della regione dedicata alle geometrie cieche + nShapeBlindId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE_BL') + -- se non ho la doppia regione prendo l'unica + if nShapeId and not nShapeBlindId then + nShapeBlindId = nShapeId + end + else + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 1 + return false, nRetErr + end + end + + -- se ho la regione provo a verificare + if nShapeId then + + -- se ventosa mobile controllo se la distanza di movimento è superiore a quella ammessa + if bCodeMobileVac and dMoveLoc > dMaxMov then + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + -- verifica se regione ventosa interferisce con le regioni passanti + local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) +-- EgtSaveFile() + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistThru) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni cieche + nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeBlindId, nId, dDistBlind) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr, true + end + nId = EgtGetNext( nId) + end + -- verifica se regione ventosa interferisce con le regioni contorno + nId = EgtGetFirstInGroup( FaceDwId or GDB_ID.NULL) + while nId do + local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistCont) + if bDistBtwRegion then -- se interferisce cancello ventosa ed esco + EgtRemoveFixture( nFixVac) + return false, nRetErr + end + nId = EgtGetNext( nId) + end + else -- regione non trovata + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 2 + return false, nRetErr + end + + -- se ho groove su top angolo + if sAngGrooveNote and #sAngGrooveNote > 0 then + local tGrooveOnAng = EgtSplitString( sAngGrooveNote) + if tGrooveOnAng and #tGrooveOnAng > 0 then + for i = 1, #tGrooveOnAng do + -- prendo la prima geometria del layer + local nGrvId = EgtGetFirstInGroup( tGrooveOnAng[i]) + if nGrvId then + local ptNear = EgtNP( nGrvId, ptVac, GDB_ID.ROOT) + if ptNear then + local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) + + -- controllo che la ventosa sia al di fuori della regione + local DwId + local bDistBtwRegion + -- se porta ribaltata + if bFlipped then + -- superficie a contatto con le ventose + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) + else + DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) + end + + if DwId then + bDistBtwRegion = EgtSurfFrTestExternal( DwId, ptVacId, 0.1) + end + + -- se punto ventosa esterno alla regione e distanza inferiore al limite ... + if bDistBtwRegion and dDist > min( dDistInterferThru, dDistInterferBlind, dDistInterferUnder) then + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + nRetErr = 3 + return false, nRetErr + end + end + end + end + end + end + -- nessuna interferenza + if nFixVac then -- se inserita ventosa la rimuovo + EgtRemoveFixture( nFixVac) + end + return true, nRetErr, nil, nCustomType +end + +----------------------------------------------------------------- +local function EndVacVerify() + -- cancello regioni passante e cieca + EgtErase( ThroughId or GDB_ID.NULL) + ThroughId = nil + EgtErase( BlindId or GDB_ID.NULL) + BlindId = nil + EgtErase( FaceDwId or GDB_ID.NULL) + FaceDwId = nil +end + +----------------------------------------------------------------- +local function MoveVac( nId, dVal) + local dOldVal = EgtGetInfo( nId, 'Val', 'd') + EgtMove( nId, Vector3d( 0, 0, dVal - dOldVal), GDB_RT.GLOB) + EgtSetInfo( nId, 'Val', dVal) +end + +----------------------------------------------------------------- +local function AddMoveShowHideVac( nMode, nGroupId, sNameVac, sNameCol, dVal, sVacName, pPointApp) + + local nVac + local nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameVac) + if nMode == 1 then -- se disposizione fixture + EgtSetAlpha( nId, 20) -- imposto trasparenza poco visibile + -- inserisco la ventosa + nVac = EgtAddFixture( sVacName, pPointApp, 0) + elseif nMode == 0 then -- disposizione machine + EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità + MoveVac( nId, dVal) + -- muovo anche la base + nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameCol) + MoveVac( nId1, dVal) + else + EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità + end + return nVac +end + +----------------------------------------------------------------- +local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local tListFaces = {} + if nProbeMode == 2 then + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) + else + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) + end + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) + table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) + + -- aggiungo anche il layer AUX escludendo il testo + if nAuxLayer then + + local nIdGeom = EgtGetFirstInGroup(nAuxLayer) + local nTypeEnt + + while nIdGeom do + -- se elemento passato è un testo lo escludo + nTypeEnt = EgtGetType( nIdGeom) + if nTypeEnt ~= GDB_TY.EXT_TEXT then + table.insert( tListFaces, nIdGeom) + end + nIdGeom = EgtGetNext(nIdGeom) + end + end + + local b3fx = BBox3d() -- inizializzo il box nullo + + for i = 1, #tListFaces do + if tListFaces[i] then + local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) + b3fx:Add(b3f1) + end + end + + return b3fx +end + +----------------------------------------------------------------- +local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth, + dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) + + local bFailDim = false + local sErrMess = '' + local dLimitToCheck + + dLimitToCheck = dMinDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorLength - abs(ShiftXOri) + if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), + EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMinDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + +-- dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri) + dLimitToCheck = dMaxDoorWidth + abs(ShiftYOri) + if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), + EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMinDoorThick + if dThickDoor < dLimitToCheck then -- se spessore inferiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + dLimitToCheck = dMaxDoorThick + if dThickDoor > dLimitToCheck then -- se spessore superiore + bFailDim = true + sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) + if #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n'.. sErrMess + else + DGD.EMC = '\n'.. sErrMess + end + end + + return bFailDim +end + +----------------------------------------------------------------- +-- *** Funzione di generazione lavorazioni *** +----------------------------------------------------------------- +function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) + +-- local nTime +-- -- inizializzo il contatore +-- EgtStartCounter() + + -- macchina e tabella di default + -- tabella parametri d'uso per variabili CurrcamInfo + tMainTabPar = {} + --macchina e tabella di default + tMainTabPar.MN = 'Multiax-' + + -- Machinings Tables + local MachiningsTable = 'MachStdTable' + local MachiningsTableOrd = 'MachStdTable_Ord' + + -- Define door disposition ( on left: 1, on right : -1) + local nDispMode = -1 + -- References on table (respect Zero machine) + -- Y Table + tMainTabPar.OR1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + tMainTabPar.OR2 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH + -- shift value + local vShift = Vector3d(0,0,0) + local vShiftVac = Vector3d(0,0,0) + tMainTabPar.SH1 = Vector3d(0,0,0) + local vNullShift = Vector3d(0,0,0) + tMainTabPar.SHL = Vector3d(0,0,0) + -- variabile per posizione media della porta per il cambio navette + local dPosShuttleChange = 40 * GEO.ONE_INCH + -- tabella raggi profili su ogni lato + local tsRadiusProf = {} + local tsPlaneProf = {} + + -- utilizzo la tabella dati cam + local sPathCurrMachtabOri = 'CurrCamInfo' + local mCamData = require( sPathCurrMachtabOri) + + -- variabili pezzo singolo + local nPz + local sAssemb + + -- variabile check dimensioni porta + local bFailDim = false + + -- resetto la macchinata (riporto il pezzo in area disegno) + EgtResetCurrMachGroup() + + -- elimino percorsi eventualmente creati dal Mach + -- cancello tutti i percorsi ghost + local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + + -- se la variabile è una tabella, estrapolo solo la porta + local PzIsTab = type(tPz) == 'table' + if PzIsTab then + for v = 1, #tPz do + + Pz = tPz[v] + sAssemb = tsAssemb[v] + + -- se non ha nota o nota della prima porta esco + if not sAssemb or ( sAssemb and sAssemb == 'first') then + break + end + end + else + Pz = tPz + sAssemb = tsAssemb + end + +-------------------------------------------------------------------------------- + -- Dati della porta + local sDoorCode = EgtGetInfo( Pz, 'Code') + local dWidthDoor = EgtGetInfo( Pz, 'W', 'd') + local dLengthDoor = EgtGetInfo( Pz, 'H', 'd') + local dThickDoor = EgtGetInfo( Pz, 'T', 'd') + local sSwing = EgtGetInfo( Pz, 'Swing') + MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente + local sSecure = EgtGetInfo( Pz, 'Secure') + local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') + local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') + local sTopTrim = EgtGetInfo( Pz, 'top_trimming') + local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') + local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') + local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') + local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') + local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') + local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra + local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) + local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' ) + tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') + tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') + tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') + tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') + tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') + tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') + tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') + tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') + local nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 + local nPostProbeSet = EgtGetInfo( Pz, 'PostProbeSet', 'i') or 0 + local dNumHingesPivots = EgtGetInfo( Pz, 'NumHingesPivots', 'd') or 0 + local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 + local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 + + -- Box pezzo + local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') + local Aux = EgtGetFirstNameInGroup( Pz, 'AUX') + local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) + + -- Box solido: lo ottengo dalla somma delle varie superfici della porta + local b3Solid = BBox3d() -- inizializzo il box nullo + b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) + + -- Project path, name, extension + local sFilePath = EgtGetCurrFilePath() + local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) + + ------------------------------------------------------ + -- se codice porta contiene comandi speciali + -- che non producono la generazione del part program della porta ma dei part program speciali + if sDoorCode then + local sCode = string.lower(sDoorCode) + if sCode == 'p1' or sCode == 'p2' or sCode == 'p3' or sCode == 'p4' or sCode == 'p5' or sCode == 'p6' then + EgtSetInfo( Pz, 'SpecialCmd', sCode) + end + end + ------------------------------------------------------ + +-------------------------------------------------------------------------------- + -- *** settaggi CAM *** -- Mtable 1 + if not MachiningsTable then -- se non c'è il nome della MTable esco + DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato + return false + end + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') + local TAB + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then + TAB = require( MachiningsTable) + if not TAB then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato + return false + end + local MachinesName = TAB.MMachineData + if not MachinesName then + DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable + return false + end + -- *** settaggi CAM *** -- Mtable 2 + MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) + EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') + local TABORD + if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then + TABORD = require( MachiningsTableOrd) + if not TABORD then + DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + else + DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file + return false + end + + -- imposto i dati macchina secondo le informazioni del file cam + tMainTabPar.MN = mCamData[nNumMachFromCam].MachName + tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 + tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 + tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 + tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck + tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength + tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength + tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth + tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth + tMainTabPar.MnDW = mCamData[nNumMachFromCam].MaxDoorThick + tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick + tMainTabPar.FUS = mCamData[nNumMachFromCam].ForceShuttleUse + tMainTabPar.FDMH = mCamData[nNumMachFromCam].ForceDirMachHinge + tMainTabPar.FDH = mCamData[nNumMachFromCam].ForceDisableHood + tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef + tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef + tMainTabPar.VOY = mCamData[nNumMachFromCam].dVacOffsY or 57.5 + tMainTabPar.MOY = mCamData[nNumMachFromCam].dMobOffsY or 201.6 + tMainTabPar.LDX = mCamData[nNumMachFromCam].dLeftDistX or 118.35 + tMainTabPar.RDX = mCamData[nNumMachFromCam].dRightDistX or 170.125 + tMainTabPar.MPMB = mCamData[nNumMachFromCam].MaxPosMobBar or 1155 + tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure + tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat + tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 + tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain + tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining + tMainTabPar.GCDN = mCamData[nNumMachFromCam].GenCncAsDdfName or 0 + tMainTabPar.DACN = mCamData[nNumMachFromCam].DisableAutoCncName or 0 + tMainTabPar.BPLI = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) + tMainTabPar.PRF = mCamData[nNumMachFromCam].PercRedFeed or 0.3 + FORCEDISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or FORCEDISPMODE -- SideDoorDispose + tMainTabPar.DTG = mCamData[nNumMachFromCam].SafetyDistVacThru or 12 + tMainTabPar.DBG = mCamData[nNumMachFromCam].SafetyDistVacBlind or 45 + tMainTabPar.DUG = mCamData[nNumMachFromCam].SafetyDistVacUnder or 55 + tMainTabPar.DSG = mCamData[nNumMachFromCam].SafetyDistVacSide or 1 + tMainTabPar.ECD = mCamData[nNumMachFromCam].EnableCollisionDetect or 0 -- new + tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels or 0 -- new + tMainTabPar.PTK = mCamData[nNumMachFromCam].dProbeThickness or 0 -- new + tMainTabPar.NVP = mCamData[nNumMachFromCam].ProfBy5AaxisHead == 1 -- new + tMainTabPar.SVP = mCamData[nNumMachFromCam].SandingBy5AxisHead == 1 -- new + tMainTabPar.CDA = mCamData[nNumMachFromCam].sCutDirectionAdmitted or '' -- new + tMainTabPar.BDH = mCamData[nNumMachFromCam].BigDoorHeight or 1800.0 -- new + tMainTabPar.NWD = mCamData[nNumMachFromCam].NarrowWidth or 253.9 -- new + tMainTabPar.RSM = mCamData[nNumMachFromCam].RemoveScrapMode or 0 -- new + tMainTabPar.MSV = mCamData[nNumMachFromCam].MinScrapValue or 0 -- new + tMainTabPar.DSL = mCamData[nNumMachFromCam].dDistSandLength or 1700 -- new + tMainTabPar.DPSL = mCamData[nNumMachFromCam].dDistPreSandLength or 1550 -- new + tMainTabPar.FDD = mCamData[nNumMachFromCam].ForceDisposByDust or 0 -- new + + -- se non devo generare il cn esco subito + if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then + DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable + return true + end + + -- setto come generare il nome del file cnc (di default è uguale al nome del parametro interno ad ddf) + if tMainTabPar.GCDN == 0 then + -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi + sFileName = sDoorCode + end + + -- per prima cosa provo ad eliminare il file .tok per il prod + EgtEraseFile( sFileDir..sFileName..'.tok') + + local MTable = TAB.MTable + local MTableOrd = TABORD.MTable + -- variabile principale per definizione disposizione porta a destra o sinistra + local sLocMachId + local bOk = true + local bFirstStep = true + local bShiftedDoor = false + local sDispMode + local sTotDispMode = '' + local sNumGroup = '' + local bWork = true + -- variabili utilizzate dentro al ciclo + local nMchId + local sTab + local tabOri + local Ori + local ColA + local nRaw + local bMoveRaw + local bPush + local bFlip + local bTopOnRight + -- variabili per disposizione sottopezzi + local dMobOffs + local dVacOffs + local dDistMinX + local dDistMaxX + local dVacOn + local dInterAx + local OffsXSovr = 0 + local OffsYSovr = 0 + local dDistInterferThru + local dDistInterferBlind + local dDistInterferUnder + local dDistInterferSide + -- variabile per tool setup + local MSetup + local sSetup + -- variabili calcolo box + local b3SolidOnTab + local pMin + local pMax + -- variabili conteggio lavorazioni profilatura bevel e saltate + local nNumMachSkip = 0 + local bLocMach + local sMachProf + local bWorkUnder = true + -- variabile per conteggio lavorazioni + local nNumMach + local nNumSkip + local tSecMachTab = {} + -- variabili per fase + local nNumPhase + local nNumCycle = 1 + -- variabili per gestione ripresa porta + local bFlipFirst + local bTopOnRightFirst + local sProfiles = '' + local nNumGeomBottom = 0 + local nNumGeomTop = 0 + local nNumGeomBottomHole = 0 + local nNumGeomTopHole = 0 + -- variabili per geometrie lato Hinge + local nNumTopGeom = 0 + local nNumBottomGeom = 0 + -- variabile piazzamento porta + local sLight + -- variabile direzione riordino gruppi + local nDirReorderGroups + -- tabella lavorazioni + local tLocMach = {} + local tLocMachOrd = {} + local tSplitDoorEnt = {} + local tSplitDataInf = {} + + local bGetSplitCuts = false + local nNumProbeZ + + -- Set Current Machine: si setta sulla fase 1 + EgtSetCurrMachine( tMainTabPar.MN) + + ------------------------------------------------------------------------------------------------------- + -- per questa macchina è importante differenziare il nome del profilo lato lock rispetto al lato hinge + -- in modo che venga lavorato prima il lato hinge e poi il lock + ------------------------------------------------------------------------------------------------------- + -- Recupero le entità + local nLockProf + -- se serratura è a destra cerco il nome dl profilo corrispondente a quel lato + if bAtRight then + nLockProf = EgtGetFirstNameInGroup( Pz, 'Right') + else + nLockProf = EgtGetFirstNameInGroup( Pz, 'Left') + end + + local EntListHg = MB.FindEntities( nLockProf) + sLockTrim = sLockTrim..'_LK' + + -- rinomino tutte le entità del gruppo + for j = 1, #EntListHg do + local sNameEnt = EgtGetName( EntListHg[j]) + if not string.find( sNameEnt, '_LK') then + sNameEnt = sNameEnt .. '_LK' + end + EgtSetName( EntListHg[j], sNameEnt) + end + + -- faccio tutte le fasi ( probabilmente solo una perché non sono previsti ribaltamenti) + while bWork do + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '1 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + sDispMode = '' + bMachUnder = nil + + nNumGroup = nNumGroup + 1 + -- Set Machining Group + if not sAssemb then -- se pezzo unico + nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) + else + nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '2 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + if nMchId then + if tMainTabPar.DACN == 1 then + local sLocNumGroup = '' + if nNumGroup > 1 then sLocNumGroup = '_'..EgtNumToString(nNumGroup,0) end + EgtSetInfo( nMchId, 'NcName', sFileName .. sLocNumGroup .. '.cnc') + end + -- assegno al gruppo di lavoro l'info relativo allo stato del controllo collisione + EgtSetInfo( nMchId, 'EnableCollisionDetect', tMainTabPar.ECD) + -- assegno al gruppo di lavoro la lunghezza minima porta + EgtSetInfo( nMchId, 'LongDoorLimit', tMainTabPar.BDH) + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + EgtSetInfo( nMchId, 'Vm', '1') + end + end + + nNumPhase = EgtGetCurrPhase() + + ----------------------------------------------------------------------- + -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo + ----------------------------------------------------------------------- + + -- se check macchina settato per non gestire grezzo + if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then + dLeftOffs = 0 + dRightOffs = 0 + dTopOffs = 0 + dBottomOffs = 0 + end + + ColA = Color3d( 255, 165, 0, 15) + nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, + b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) + + EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs, dBottomOffs, 0), nRaw) + + -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, + -- decido su quale lato disporre la porta per evitare inutili ribaltamenti + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + + tLocMach = MTable + tLocMachOrd = MTableOrd + sMachProf = '' + + -- in base ai valori di sovramateriale sui lati, se tutti sono al di sotto di 3 volte il valore di attivazione della sgrossatura + -- allora disabilito lo scrapmode + if dLeftOffs < tMainTabPar.MSV and dRightOffs < tMainTabPar.MSV and dTopOffs < tMainTabPar.MSV and dBottomOffs < tMainTabPar.MSV then + tMainTabPar.RSM = 0 + end + + -- prendo nota dei profili tipo bevel e bull nose + -- verifico se cave da sotto o da sopra + -- verifico se trovate lavorazioni applicate con 'shift' + local nUnderGeom + + for i = 1, #tLocMach do + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + -- se non c'è il campo macchina setto di default la 1 + if not sLocMachId then sLocMachId = 1 end + + -- se macchina corrispondente + if sLocMachId == nNumMachFromTable then + + local sUpperProfName = string.upper(tLocMach[i].Name) + -- prendo i profili bevel direttamente dalla tabella + if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then + if not string.find( sProfiles, sUpperProfName) then + sProfiles = sProfiles .. sUpperProfName .. ',' + end + end + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Test delle lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + end + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) + if bLocMach then + if nUnderGeom and nUnderGeom == 1 then + nNumGeomBottom = nNumGeomBottom + 1 + nNumGeomBottomHole = nNumGeomBottomHole + 1 + elseif nUnderGeom and nUnderGeom == -1 then + nNumGeomTop = nNumGeomTop + 1 + nNumGeomTopHole = nNumGeomTopHole + 1 + end + end + end + end + end + end + end + + ----------------------- + -- *** Disposizione *** + ----------------------- + + -- controllo se ho profili bullnose sul lato hinge (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sHingeTrim == '1B' or sHingeTrim == '2B') then -- se profilo cerniere è bullnose + bShiftedDoor = true + end + + -- controllo se ho profili bullnose sul lato serratura (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) + if ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK') then -- se profilo serratura indicato è bullnose + vShiftVac = tMainTabPar.SHL + else + vShiftVac = vNullShift + end + + -- Scelta della tavola + sTab = 'Tab' + EgtSetTable( sTab) + + -- Origine tavola corrente rispetto a Zero macchina + tabOri = EgtGetTableRef( 1) + + -- Rotazione porta in base alla macchina + bMoveRaw = false + + -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf + -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. + -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge + -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf + -- se non c'è il parametro considero la porta come se avesse bevel down + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or + sSwing == 'LH' or sSwing == 'LHA' or sSwing == 'LHI' then + bPush = true + else + bPush = false + end + + local sNumPhase + if nNumPhase and nNumPhase < 10 then + sNumPhase = '0'.. tostring( nNumPhase) + elseif nNumPhase then + sNumPhase = tostring( nNumPhase) + else + sNumPhase = '0' + end + + local bOkDisp = false + nNumProbeZ = 0 + + -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, + -- se non ha bevel nemmeno il lato serratura considero il parametro secure +-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel e da lavorare + if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel + + -- verifico se i profili risultanti sono presenti in tabella + if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or + ( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo serratura indicato bevel (e da lavorare) +-- if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK') and bLockMach and not bOkDisp then + if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB_LK') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sLockTrim == 'BD_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BD_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BDEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then + bOkDisp = true + elseif sLockTrim == 'BU_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + elseif sLockTrim == 'BUEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- a meno che ho il profilo opposto, in questo caso non ribalto la porta, altrimenti devo ribaltare la porta + -- e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') and bPush) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and not bPush and not bOppoBevelProf) or + ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and bPush and bOppoBevelProf) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or + ( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- se profilo top indicato bevel (e da lavorare) + if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then + + -- verifico se i profili risultanti sono presenti in tabella + if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then + bOkDisp = true + elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then + bOkDisp = true + end + + if bOkDisp then + + -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing + -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or + ( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then + + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + + -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing + -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti + else + + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + end + end + + -- in caso non ci sia nessun profilo bevel verifico il parametro Secure + if not bOkDisp then + + -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo altrimenti do errore + if sSecure and string.upper(sSecure) == '0' then + -- se parametro da CurrcamInfo non è valido do errore + if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[590] + break + else + sSecure = tMainTabPar.LS + end + end + + -- se lato secure va sopra il ribaltamento è obbligato + if sSecure and string.upper(sSecure) == 'UP' then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif sSecure and string.upper(sSecure) == 'DN' then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) quella di considerare la porta bevel down + -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata + -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) + else + + if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing + + -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down + if bPush then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + -- se porta a tirare non la ribalto perché si presta già ad essere bevel down + else + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + end + else -- in base alle geometrie trovate ribalto o meno la porta + + if nNumGeomBottom > nNumGeomTop then + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + elseif nNumGeomTop >= nNumGeomBottom then + bFlip = false + if bAtRight then -- se serratura a destra + bTopOnRight = false + else + bTopOnRight = true + end + else -- altrimenti vecchio metodo + bFlip = true + if bAtRight then -- se serratura a destra + bTopOnRight = true + else + bTopOnRight = false + end + end + end + end + end + + -- faccio le rotazioni della porta + if bFlip then + EgtRotateRawPart( nRaw, Y_AX(), 180) + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] + else + sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] + end + + if bTopOnRight then + EgtRotateRawPart( nRaw, Z_AX(), -90) + sDispMode = sDispMode .. EgtDoorsMsg[481] + else + EgtRotateRawPart( nRaw, Z_AX(), 90) + sDispMode = sDispMode .. EgtDoorsMsg[482] + end + + if bShiftedDoor then + sDispMode = sDispMode .. EgtDoorsMsg[510] + end + sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' + + ----------------------------------------------------------------------------------------------- + -- Scelta della disposizione e di conseguenza dell'origine (ora espressa rispetto Zero Tavola) + ----------------------------------------------------------------------------------------------- + + if FORCEDISPMODE == 0 then -- disposizione segue il top della porta + if bTopOnRight then + nDispMode = -1 + else + -- 19.09.2023 richiesta di MarkHoffman per problemi di pesenza della polvere: se la porta ha lato top e/o bottom lavorate, la disposizione della porta + -- deve essere fatta a destra + if tMainTabPar.FDD > 0 and ( bTopMach or bBottomMach) then + nDispMode = -1 + else + nDispMode = 1 + end + end + else + nDispMode = FORCEDISPMODE + end + + Ori = EgtIf( nDispMode > 0, tMainTabPar.OR1, tMainTabPar.OR2) + + -- se porta da traslare setto lo shift da applicare + if bShiftedDoor then + vShift = tMainTabPar.SH1 + else + vShift = vNullShift + end + + Ori = Ori + vShift + + -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto + if nProbeMode == 1 then + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimenenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + end + -- mi tengo via il numero di probe in Z + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbePoint') + end + -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto + elseif nProbeMode == 0 and nPostProbeSet >= 3 then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + end + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + -- rinomino i rimenenti + if bFlip then + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') + else + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') + end + -- mi tengo via il numero di probe sul fianco + nNumProbeZ = #DelList + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtSetName( DelList[j], 'ProbeSidePoint') + end + else -- se non c'è il probe point elimino tutti i percorsi di probe (in Z) + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint') + -- ciclo su tutte le entità trovate + for j = 1, #DelList do + EgtErase( DelList[j] ) + end + end + + ------------------------------------------------------------------ + -- calcolo delta Y in base al profilo e al ribaltamento del pezzo + ------------------------------------------------------------------ + local vExtraYDelta + local dExtraY = 0 + local dExtraYOppo = 0 + local dDeltaProbe = 0 + local dDeltaProf = 0 + local dDeltaProfOppo = 0 + -- variabili per note relative al lato hinges + local nHingeMach = 0 -- setto default non lavorato + local nLockMach = 0 -- setto default non lavorato + local nSideType = -1 -- 0 per profili SQ or FDWC + local nSideOppoType = -1 -- 0 per profili SQ + + -- verifico profilo in battuta (hinge) + if sHingeTrim == 'SQ' or sHingeTrim == 'EB' or sHingeTrim == 'FDWC' then + nSideType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then + nSideType = 1 + if dThickDoor > tMainTabPar.AR then + dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 + end + -- calcolo errore del probe tastando a metà spessore +-- dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se disposizione bevel up uso il riferimento in basso + elseif sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then + nSideType = 2 + dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 + -- calcolo errore del probe tastando a metà spessore +-- dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProf = (( dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + dDeltaProbe = dDeltaProf - dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo bull nose verifico in base al raggio + elseif sHingeTrim == '1B' or sHingeTrim == '2B' or + sHingeTrim == '3B' or sHingeTrim == '4B' then + + nSideType = 3 + -- calcolo punto massimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = 0 + + -- se punto max è sotto il minimo riferimento + if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then + dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf + -- se punto max è sopra il massimo riferimento + elseif dAltProf > tMainTabPar.AR then + dAltcalc = dAltProf - tMainTabPar.AR + end + + -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y + if dAltcalc > 0 then + dExtraY = tsRadiusProf[1] - sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = -dExtraY + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + -- se profilo convex verifico in base al raggio + elseif sHingeTrim == 'CV' then + + nSideType = 4 + -- calcolo punto minimo ingombro profilo + local dAltProf = dThickDoor/2 + local dAltcalc = (tMainTabPar.TR/2) + -- calcolo il delta Y massimo del minimo ingombro profilo + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-((dAltProf-tsPlaneProf[1])*(dAltProf-tsPlaneProf[1]))) + + -- se riferimento è sul max ingombro porta + if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then + dAltcalc = 0 + -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento + elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = tMainTabPar.AR - dAltProf + -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento + elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then + dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR + end + + -- calcolo il delta Y + if dAltcalc > 0 then + dExtraY = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) - dMaxInsPrf + end + -- calcolo errore del probe tastando a metà spessore + dDeltaProbe = tsRadiusProf[1] - (dExtraY + dMaxInsPrf) + -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY + dDeltaProf = dExtraY + end + + -- verifico profilo opposto alla battuta (lock) + if sLockTrim == 'SQ_LK' or sLockTrim == 'EB_LK' then + nSideOppoType = 0 + -- se disposizione bevel down uso il riferimento in alto + elseif sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK' then + nSideOppoType = 1 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = tMainTabPar.EZPB * TAN3 + else + -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) + end + -- se disposizione bevel up uso il riferimento in basso + elseif sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then + nSideOppoType = 2 + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe + dDeltaProfOppo = (( dThickDoor - tMainTabPar.EZPB) * TAN3) + else + -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe + dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) + end + -- se profilo bull nose verifico in base al raggio + elseif sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or + sLockTrim == '3B_LK' or sLockTrim == '4B_LK' then + + nSideOppoType = 3 + -- se profilo convex verifico in base al raggio + elseif sLockTrim == 'CV_LK' then + + nSideOppoType = 4 + local dAltProfOppo + local dAltProfOppoTh + local dExtraYOppoTh + -- se abilitato il side probe + if nProbeMode == 0 and nPostProbeSet >= 3 then + -- calcolo punto minimo ingombro profilo + dAltProfOppoTh = dThickDoor/2 - tsPlaneProf[2] + -- calcolo errore del probe tastando a spessore completo - extra z + dAltProfOppo = (dThickDoor/2) - tMainTabPar.EZPB - tsPlaneProf[2] + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) + dExtraYOppoTh = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppoTh*dAltProfOppoTh)) + -- calcolo errore del probe tastando dallo spessore - quota extra z + dDeltaProfOppo = dExtraYOppo - dExtraYOppoTh + else + -- calcolo punto minimo ingombro profilo + dAltProfOppo = dThickDoor/2 - tsPlaneProf[2] + -- calcolo il delta Y massimo del minimo ingombro profilo + dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) + -- calcolo errore del probe tastando a metà spessore + dDeltaProfOppo = tsRadiusProf[2] - dExtraYOppo + end + end + + -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota + if bHingeMach then + dExtraY = 0 + nHingeMach = 1 + dDeltaProbe = 0 + dDeltaProf = 0 + end + -- se profilo lock da lavorare setto la variabile per la nota + if bLockMach then + dExtraYOppo = 0 + nLockMach = 1 + dDeltaProfOppo = 0 + end + + vExtraYDelta = Vector3d(0,-dExtraY,0) + -- scrivo le note + EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) + EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) + EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) + EgtSetInfo( Pz, 'DoorProbeThick', tMainTabPar.PTK) + EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) + EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) + EgtSetInfo( Pz, 'SideDisposition', nDispMode) + -- scrivo nota disabilitazione cuffia + EgtSetInfo( Pz, 'ForceDisableHood', tMainTabPar.FDH) + -- scrivo nota lavorazione lato hinge + EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) + -- scrivo nota tipo profilo lato hinge + EgtSetInfo( Pz, 'SideHingeProf', nSideType) + -- scrivo profilo lato in battuta + EgtSetInfo( Pz, 'SideProfOnRef', nSideType) + -- scrivo profilo lato opposto + EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) + -- scrivo nota lavorazione lato lock + EgtSetInfo( Pz, 'SideLockMach', nLockMach) + -- scrivo la nota relativa al controllo collisioni + EgtSetInfo( Pz, 'EnableCollisionDetect', tMainTabPar.ECD) + -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) + EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) + -- assegno al gruppo di lavoro la lunghezza minima porta + EgtSetInfo( Pz, 'LongDoorLimit', tMainTabPar.BDH) + -- scrivo nota flag modalita remove scrap + EgtSetInfo( Pz, 'RemoveScrapMode', tMainTabPar.RSM) + -- assegno al gruppo di lavoro la larghezza di riferimento per considerarla stretta e lavorarla con una sola fresa + EgtSetInfo( Pz, 'NarrowDoorLimit', tMainTabPar.NWD) + + -- sommo il delta spostamento + Ori = Ori + vExtraYDelta + + -- Muovo porta con l'angolo indicato dal tipo di disposizione nella posizione di origine + bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, EgtIf( nDispMode > 0, MCH_CR.BL, MCH_CR.BR)) + + -- memorizzo i flag per le fasi successive + bFlipFirst = bFlip + bTopOnRightFirst = bTopOnRight + + if not bMoveRaw then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[474] -- Error positioning raw part on table + break + end + + EgtSetInfo( Pz, 'MachineNameFromCurrCamInfo', tMainTabPar.MN) + if bShiftedDoor then + -- salvo una nota con le info della disposizione traslata + EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'SHIFT') + EgtSetInfo( Pz, 'OffSetPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) + else + -- salvo una nota con le info della disposizione normale + EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) + EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'NORMAL') + EgtSetInfo( Pz, 'OffSetPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) + end + + if bFlip then -- se porta capovolta + if bTopOnRight then -- se top a destra + -- il lato sinistro è quello delle hinges + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato destro è quello delle hinges + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) + end + else -- altrimenti non è capovolta + if bTopOnRight then -- se top a destra + -- il lato destro è quello delle hinges + OffsYSovr = dRightOffs + OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) + else -- se top a sinistra + -- il lato sinistro è quello delle hinges + OffsYSovr = dLeftOffs + OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) + end + end + + -- Controllo dimensioni pezzo + -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi + bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, + vShift:getX(), vShift:getY(), tMainTabPar.MnDL, tMainTabPar.MxDL, tMainTabPar.MnDW, + tMainTabPar.MxDW, tMainTabPar.MnDT, tMainTabPar.MnDW) + + if bFailDim then + + DGD.ERR = 19 + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..'.txt') + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + DoorOutLog( DGD.EMC, 0) + EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + return false + end + + ------------------------------------------------------------------------------------------------------------- + -- abilito/disabilito geometrie probe in base alla lavorazione del lato hinge e alla disposizione sulla tavola + ------------------------------------------------------------------------------------------------------------- + if bHingeMach then -- se profilo hinge è da lavorare rinomino nome entita + + -- Recupero le entità probe + local ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) + end + + -- Recupero le entità pivot + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_POS') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + + ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_NEG') + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) + end + + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- profilo hinge non lavorato + else + -- il probe deve essere sempre quello a sinistra rispetto al piazzamento + -- considerando lo swing perché le cerniere a seconda di questo vengono ruotate e il probe _POS e _NED risultano + -- scambiati rispetto al top della porta + local sProbeHingeToFind = '' + local sProbeHingeDis = '' + local sProbePivotToFind = '' + local sProbePivotDis = '' + + if nDispMode > 0 then -- se disposizione a sinistra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + else + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + end + sProbePivotToFind = 'Pivot_Probe_NEG' + sProbePivotDis = 'NO_Pivot_Probe_NEG' + else -- disposizione a destra + if ( bPush and bAtRight) or ( not bPush and not bAtRight) then + sProbeHingeToFind = 'Hinge_Probe_POS' + sProbeHingeDis = 'NO_Hinge_Probe_POS' + else + sProbeHingeToFind = 'Hinge_Probe_NEG' + sProbeHingeDis = 'NO_Hinge_Probe_NEG' + end + sProbePivotToFind = 'Pivot_Probe_POS' + sProbePivotDis = 'NO_Pivot_Probe_POS' + end + local ProbeList = MB.FindEntitiesWithName( Pz, sProbeHingeToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbeHingeDis) + end + ProbeList = MB.FindEntitiesWithName( Pz, sProbePivotToFind) + for j = 1, #ProbeList do + EgtSetName( ProbeList[j], sProbePivotDis) + end + -- se non da lavorare e profilo bevel dn cambio lo spessore a: spessore probe + extra probe z + if sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif sHingeTrim == '1B' or sHingeTrim == '2B' or sHingeTrim == '3B' or sHingeTrim == '4B' or + sHingeTrim == '5B' or sHingeTrim == '6B' or sHingeTrim == '7B' or sHingeTrim == '8B' then + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + else + -- recupero entità probe di fianco + ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 1 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + end + + if bLockMach then -- se profilo lock è da lavorare rinomino nome entita + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not bLockMach and ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z + elseif not bLockMach and ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK' or + sLockTrim == '5B_LK' or sLockTrim == '6B_LK' or sLockTrim == '7B_LK' or sLockTrim == '8B_LK') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not bLockMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 3 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + if bTopMach then -- se profilo top è da lavorare rinomino nome entita + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not bTopMach and ( sTopTrim == 'BD' or sTopTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not bTopMach and ( sTopTrim == '1B' or sTopTrim == '2B' or sTopTrim == '3B' or sTopTrim == '4B' or + sTopTrim == '5B' or sTopTrim == '6B' or sTopTrim == '7B' or sTopTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not bTopMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 2 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sTopTrim == 'BU' or sTopTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + if bBottomMach then -- se profilo top è da lavorare rinomino nome entita + -- recupero entità probe di fianco su lato secure + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) + end + end + -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z + elseif not bBottomMach and ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') + end + end + -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + elseif not bBottomMach and ( sBottomTrim == '1B' or sBottomTrim == '2B' or sBottomTrim == '3B' or sBottomTrim == '4B' or + sBottomTrim == '5B' or sBottomTrim == '6B' or sBottomTrim == '7B' or sBottomTrim == '8B') then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) + end + end + -- in tutti gli altri profili setto l'affondamento a extra probe z + elseif not bBottomMach then + -- recupero entità probe di fianco + local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') + local eProSide + -- ciclo su tutte le entità trovate + for j = 1, #ProbeList do + eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 + if eProSide == 4 then + EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) + -- se profilo bevel up assegno nota + if sBottomTrim == 'BU' or sBottomTrim == 'BUEB' then + EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') + end + end + end + end + + -- *** Lavorazioni *** + -- setto variabili in funzione della disposizione porta + local bMakeGhost = true + -- se esiste la forzatura sulla direzione lavorazione cerniere + if tMainTabPar.FDMH and abs( tMainTabPar.FDMH) == 1 then + nDirReorderGroups = tMainTabPar.FDMH + -- altrimenti come in precedenza, in base alla disposizione lato top porta + else + nDirReorderGroups = nDispMode + end + local dPercentDoorLength + --------------------------------------------------------------------------------------------------------------------------- + -- 06/05/2021 in base al seguente avvenimento: porta lunga 3025 con 4 cerniere, 2 per ogni shuttle, e con una groove che + -- sborda sul lato cerniere. Alla chiamata della DANGER_L (nel Processo4) lo shuttle 1 a sinistra chiede di parcheggiare + -- nella posizione calcolata (L88) nel P5INIT che è a pacco con lo shuttle 2 nella parte destra della porta. L'arbitro non + -- da il consenso al parcheggio perchè la posizione è ancora occupata dallo shuttle 2 che sta lavorando e quindi manda + -- in parcheggio lo shuttle 1 fuori (tutto a sinistra) ma che, data la lunghezza elevata della porta, quando il gruppo 4 + -- andando a lavorare la groove vicino al lato hinge, rischia di collidere con lo shuttle 1. + -- Quindi per ovviare al problema è stato stabilito, in accordo con Carlo Viviani, di controllare per prima + -- la dimensione della porta, e se la lunghezza porta è maggiore del valore stabilito nella macro P5INIT nella variabile + -- L116 (ad oggi al valore 1800mm) allora la percentuale di distribuzione cerniere passa a 45% (su questa macchina) dalla + -- parte dove la porta è riferita (cioè 45% da sinistra se porta disposta a sinistra, 45% da destra se porta riferita a destra), + -- in questo modo lo shuttle più vicino al riferimento porta lavora meno dello shuttle opposto così, se viene chiamato + -- un danger sul lato opposto a riferimento ci sono più probabilità che lo shuttle vicino al riferimento abbia già finito + -- e la richiesta di parcheggio interno per lo shuttle opposto trova lo spazio disponibile. + --------------------------------------------------------------------------------------------------------------------------- + if dLengthDoor >= tMainTabPar.BDH then + dPercentDoorLength = 0.45 -- 45% sempre dalla parte dove è riferita -- EgtIf( nDispMode > 0, 0.52, 0.48) + else + + ------------------------------------------------------------------------------------------- + -- Su richiesta del cliente (Adam Linch) in data 06/12/2017 la ripartizione delle tre cerniere è la seguente: + ------------------------------------------------------------------------------------------- + -- 2 cerniere allo shuttle corrispondente al lato di riferimento porta. V1.3 + -- quanto viene dopo è stato cambiato + -- assegno una percentuale di 0.6 sempre verso lo shuttle di sinistra (Viviani 30/01/2017) + -- se disposta a sinistra assegno 0.6 da sinistra, se disposta a destra assegno 0.4 da destra, il risultato è quindi + -- sempre 0.6 da sinistra + -- ma con 3 cerniere o 3 pivot, inverto la percentuale, cioè sempre 0.4 da sinistra V1.2 + -- V1.1 + --local dPercentDoorLength = EgtIf( nDispMode > 0, 0.6, 0.4) -- V1.1 + -- V1.2 + --local dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.4, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) -- V1.2 + -- V1.3 + dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.6, 0.4), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) -- V1.3 + end + + -- Se uso shuttle forzato su uno dei due shuttle cambio la percentuale + if tMainTabPar.FUS then + if tMainTabPar.FUS == 1 then + dPercentDoorLength = 0 + elseif tMainTabPar.FUS == 2 then + dPercentDoorLength = 1 + else + tMainTabPar.FUS = 0 + end + else + tMainTabPar.FUS = 0 + end + + -- scrivo la nota + EgtSetInfo( Pz, 'ForceShuttle', tMainTabPar.FUS) + -- calcolo una direzione locale perchè se ha segno opposto e la porta è disposta sul lato opposto, viene fatto un errore nel calcolo della posizione di scambio + local nLocalDirReorderGroup = EgtIf( nDirReorderGroups == nDispMode, nDirReorderGroups, -nDirReorderGroups) + + -- quanto segue nella sottostante spiegazione è stato cambiato + ---- determino la posizione del cambio shuttle utilizzando un coefficente di 0.4 verso destra se il posizionamento è a destra + ---- e un coefficente di 0.6 verso destra se il posizionamento è a sinistra, in modo + ---- da favorire lo shuttle che è dalla parte del riferimento ( a destra con assegnazione nMach a 2 e a sinistra con assegnazione nMach a 3) + dPosShuttleChange = EgtIf( nDispMode > 0, tMainTabPar.OR1:getX(), tMainTabPar.OR2:getX()) + ( dLengthDoor * dPercentDoorLength * nLocalDirReorderGroup) + ( OffsXSovr * nLocalDirReorderGroup) + tabOri:getX() + + --verifico se la porta è da considerarsi stretta + if dWidthDoor <= tMainTabPar.NWD then +-- tMainTabPar.DSL = 0 +-- tMainTabPar.DPSL = 200 + -- riassegno il valore della variabile + tMainTabPar.NWD = true + -- scrivo la nota che indica la porta stretta + EgtSetInfo( Pz, 'NarrowestDoor', tMainTabPar.NWD) + else + -- riassegno il valore della variabile + tMainTabPar.NWD = false + end + + -- ricavo minimo e massimo del solido del pezzo + b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) + pMin = b3SolidOnTab:getMin() + pMax = b3SolidOnTab:getMax() + local tOrderGrp = {} + + -- print Machining table + -- solo il primo giro: aggiusto i profili bevel per essere coerente con la sequenza di tabella + -- riordino i gruppi geometrici che hanno l'operazione AdjustHead o AdjustHeadOnASplint in ordine di X decrescente + for i = 1, #tLocMach do + + -- print Machining table + DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. + ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) + + if tLocMach[i].On ~= 0 then + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + -- OPERAZIONI + if tLocMach[i].Oper then + if tLocMach[i].Oper == 'AdjustBevel' then + local sNewName + _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP, nil, true) + elseif tLocMach[i].Oper == 'AdjustBevelToSand' then + local sNewName + _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.SVP, nil, true) + elseif tLocMach[i].Oper == 'AdjustHead' or tLocMach[i].Oper == 'AdjustHeadOnASplint' then + -- nDirReorderGroups = -1 = ordine decrescente ( da dx a sx <--); nDirReorderGroups = 1 ordine crescente ( da sx a dx -->) + MB.ReorderGroup( EntList[j], tOrderGrp, nDirReorderGroups) + -- Nuova ma non va bene + -- MB.ReorderGroup( EntList[j], tOrderGrp, EgtIf( nDispMode > 0 , - nDirReorderGroups, nDirReorderGroups)) -- sempre decrescente; + end + end + end + end + end + end + + -- conteggio lavorazioni saltate + nNumMachSkipResult = 0 + -- variabile per conteggio lavorazioni + nNumMach = 0 + nNumSkip = 0 + -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto + if bFlip then + local nValAppo = nNumGeomBottom + nNumGeomBottom = nNumGeomTop + nNumGeomTop = nValAppo + nValAppo = nNumGeomBottomHole + nNumGeomBottomHole = nNumGeomTopHole + nNumGeomTopHole = nValAppo + end + + -- Machining adding, only for selected machine + -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni + for i = 1, #tLocMach do + + if tLocMach[i].On ~= 0 then + + sLocMachId = tLocMach[i].MachId + if not sLocMachId then sLocMachId = 1 end + + if sLocMachId == nNumMachFromTable then + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) + -- Applico le lavorazioni + for j = 1, #EntList do + + local bAdjustHead = false + local nNewIdEnt + + -- OPERAZIONI + if tLocMach[i].Oper then + + if tLocMach[i].Oper == 'AdjustBevel' or tLocMach[i].Oper == 'AdjustBevelToSand' then + + local sNewName + if tLocMach[i].Oper == 'AdjustBevel' then + bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP, bMakeGhost, nil, tMainTabPar.NWD) + else + bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.SVP, bMakeGhost, nil, tMainTabPar.NWD) + end + + if bLocMach then + + local bInsLav = false + -- faccio il test per vedere se la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + -- se la lavorazione è applicabile + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustVertCurve' then + bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustRoughCurve' then + + local bInvertOnZPos = false + + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if string.lower( sEdge) == 'left' then + if bAtRight then + if sHingeTrim == 'CV' then + bInvertOnZPos = true + end + elseif not bAtRight then + if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + bInvertOnZPos = true + end + end + elseif string.lower( sEdge) == 'right' then + if bAtRight then + if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + bInvertOnZPos = true + end + elseif not bAtRight then + if sHingeTrim == 'CV' then + bInvertOnZPos = true + end + end + elseif string.lower( sEdge) == 'top' then + if sTopTrim == 'CV' then + bInvertOnZPos = true + end + elseif string.lower( sEdge) == 'bottom' then + if sBottomTrim == 'CV' then + bInvertOnZPos = true + end + end + + bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true, bInvertOnZPos) + elseif tLocMach[i].Oper == 'AdjustThrouCurve' then + + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, nil, nil, tMainTabPar.NWD) + if bLocMach then + + local bInsLav = false + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + if nMach == 1 then + bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if bInsLav then + -- ottengo il nome del lato lavorato + local sEdge = EgtGetName( EgtGetParent( EntList[j])) + if sEdge then + if #sMachProf > 0 then + sMachProf = sMachProf .. ',' .. sEdge + else + sMachProf = sEdge + end + end + + -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura + if string.lower( sEdge) == 'left' then + local dOffsLoc = 0 + if bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'right' then + local dOffsLoc = 0 + if bAtRight then + if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or + sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then + dOffsLoc = dThickDoor * TAN3 + elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[2] + local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[2] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + elseif not bAtRight then + if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sHingeTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[1] + local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[1] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + end + MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'top' then + local dOffsLoc = 0 + if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + elseif sTopTrim == 'CV' then + -- calcolo minimo ingombro profilo + local dAltProf = dThickDoor/2 - tsPlaneProf[3] + local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) + dOffsLoc = tsRadiusProf[3] - dMaxInsPrf + -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta + EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) + end + MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + elseif string.lower( sEdge) == 'bottom' then + local dOffsLoc = 0 + if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then + dOffsLoc = dThickDoor * TAN3 + end + MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) + end + end + else + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustThrouIsle' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then -- se operazione fallita + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andata a buon punto vedo di sottrarle ai contatori degli skip + if nMach == 1 then + if nNumGeomTop > 0 then + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottom > 0 then + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustProbeMill' and nProbeMode == 0 and nPostProbeSet > 2 then + local sMachRetured + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeMill( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, + bFirstStep, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, tMainTabPar.PTK, + tMainTabPar.EZPB) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + if bOk then + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + nLocMach = nMach + + if nMach == 1 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) + elseif nMach == 3 then + bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate + if sMachRetured then + nNumMachSkip = nNumMachSkip + 1 + end + -- ricambio la nota come non lavorabile in questa fase + if nMach == 1 then + EgtSetInfo( nNewIdEnt, 'Mach', 11) + elseif nMach == 2 then + EgtSetInfo( nNewIdEnt, 'Mach', 13) + elseif nMach == 3 then + EgtSetInfo( nNewIdEnt, 'Mach', 12) + end + -- se nome lavorazione non nullo, incremento i contatori + if sMachRetured then + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andata a buon punto setto nota alla porta + EgtSetInfo( Pz, 'ExistsProbeXY', true) -- presenza del probe in XY + end + else + EgtSetInfo( nNewIdEnt, 'Mach', 31) + end + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillX' then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true, 0) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizDrillY' then + bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true, 0) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorizAS' then + bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then + bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustMortise' then + bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBevelChisel' then + bLocMach,_, nNewIdEnt = MB.AdjustBevelChisel( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadChisel' then + bLocMach, nNewIdEnt, nNumMachSkipResult = MB.AdjustHeadChisel( EntList[j], bMakeGhost, CHISEL_ONLY_HORIZONTAL, nNumMachSkip, NO_WORK_UPSQUARE, NO_WORK_UNDERSQUARE) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + end + elseif tLocMach[i].Oper == 'AdjustVertHole' then + bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) + if not bLocMach then + bOk = false + end + if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + nNumMachSkip = nNumMachSkipResult + else -- se non skippata provo a verificare se la lavorazione è applicabile + + local bInsLav = true + -- faccio un test per vedere che la lavorazione è applicabile + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + local sResMach + + if nMach == 1 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) + elseif nMach == 2 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) + elseif nMach == 3 then + bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) + end + + if not bInsLav then + if bFirstStep then + -- inserisco in tabella solo se non già presente + tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) + end + -- se nome lavorazione non nullo, incremento i contatori + if sResMach and #sResMach > 0 then + -- aumento di 1 il numero di lavorazioni skippate + nNumMachSkip = nNumMachSkip + 1 + -- ricambio la nota come non lavorabile in questa fase + EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) + -- incremento il numero di lavorazioni da sotto + nNumGeomBottom = nNumGeomBottom + 1 + end + else -- se è andato a buon fine, verifico di sottrarlo agle variabili skip + if nMach == 1 then + if nNumGeomTopHole > 0 then + nNumGeomTopHole = nNumGeomTopHole - 1 + nNumGeomTop = nNumGeomTop - 1 + end + elseif nMach == 2 then + if nNumGeomBottomHole > 0 then + nNumGeomBottomHole = nNumGeomBottomHole - 1 + nNumGeomBottom = nNumGeomBottom - 1 + end + end + end + end + elseif tLocMach[i].Oper == 'AdjustHole' then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHead' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHead( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustHeadOnASplint' then + bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHeadOnASplint( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nil, + nDispMode, bFlip, MAXMACH) + bAdjustHead = true + if not bLocMach then + bOk = false + end + elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then + bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustASplintWithBlade' then + bOk, nNewIdEnt = MB.AdjustASplintWithBlade( EntList[j], bMakeGhost, nDispMode, bFlip) + elseif tLocMach[i].Oper == 'AdjustSplitDoor' and nProbeMode ~= 1 then + if not bGetSplitCuts then + tSplitDoorEnt = EntList + table.insert( tSplitDataInf, { tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, nNumMach, bMakeGhost}) + bGetSplitCuts = true + end + elseif tLocMach[i].Oper == 'AdjustConeCleanPaths' and nProbeMode ~= 1 then + bOk, nNewIdEnt = MB.AdjustConeCleanPaths( EntList[j], bMakeGhost) + elseif tLocMach[i].Oper == 'AdjustVertAsOnHeads' and nProbeMode ~= 1 then + bLocMach, nNewIdEnt = MB.AdjustVertAsOnHeads( EntList[j], bMakeGhost) + if not bLocMach then + bOk = false + end + end + else -- se nessuna operazione + nNewIdEnt = MB.MakeGhostCopy( EntList[j]) + end + + -- LAVORAZIONI + local nMach + if nNewIdEnt then + nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + else + nMach = 0 + end + if nMach > 30 and nMach < 40 then nMach = nMach - 30 end + + if bAdjustHead and nMach > 0 and nMach < 4 then -- se navette + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = FindAndCalcGroupMachining( EntList[j], nNewIdEnt, tLocMach, nNumMachFromTable, nMach, + nNumGroup, nNumMach, bOk, tMainTabPar.BPLI, tMainTabPar.PRF) + elseif nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, + tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, + NOT_GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + else + if not bAdjustHead then + DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') .. + EgtDoorsMsg[596]..tostring( nNumPhase), 0) + nNumSkip = nNumSkip + 1 + end + end + end + end + end + end + + local i = 1 + while i <= #tLocMachOrd do + + -- carico tutto il gruppo in una tabella + local tGroup = {} + local nNumGrp = tLocMachOrd[i].Group + local sProperty = tLocMachOrd[i].Property + tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) + + if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0 + + if sProperty == 'MinDist' or sProperty == 'FromXPosToXNeg' then -- ottimizzare alla minima distanza + + -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) + local LastMch = EgtGetLastOperation() + local EndLastMach + + -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale + if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then + EgtSetCurrMachining( LastMch) + EndLastMach = EgtGetMachiningEndPoint() + end + + local tMachining = {} + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + -- se lavorazione esiste e corrisponde e numero lavorazione è = 1 + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + if sProperty == 'FromXPosToXNeg' then + tListSameMach = MB.OrderEnt( tListSameMach, nil, 1) + else + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + end + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, tMachining, tMainTabPar.BPLI, tMainTabPar.PRF) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + + -- ordino le lavorazioni + if #tMachining > 1 then + + -- Tavole per fresature da ordinare + local TabMill = {} + local TabMStEnP = {} + local TabZMach = {} + + for k = 1, #tMachining do + -- Se appartiene alla fase corrente e fresatura non vuota + if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then + EgtSetCurrMachining( tMachining[k][1]) + local ptStart = EgtGetMachiningStartPoint() + local ptEnd = EgtGetMachiningEndPoint() + if ptStart and ptEnd then + table.insert( TabMill, tMachining[k][1]) + table.insert( TabMStEnP, { ptStart, ptEnd}) + MB.InsZedByTool( TabZMach, tMachining, k) + end + end + end + -- calcolo ordinamento + EgtSpInit() + for k = 1, #TabMill do + EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, + TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) + end + + local vMillOrd + + if sProperty == 'FromXPosToXNeg' then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,10000,0,0,90,90) + vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + else + if EndLastMach then + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) + else + EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) + end + vMillOrd = EgtSpCalculate(SHP_TY.OPEN) + end + EgtSpTerminate() + -- applico ordinamento calcolato + -- parto da LastMch precedente + if vMillOrd then + for k = 1, #vMillOrd do + EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) + LastMch = TabMill[vMillOrd[k]] + end + end + end + elseif sProperty == 'Shuttle' then -- lavorazione con shuttle + + -- per ogni layer padre nella lista fatta con il reordergroup + for k = 1, #tOrderGrp do + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( tOrderGrp[k][1], true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, tOrderGrp[k][1], tGroup, nMach, nNumGrp, + nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach, + tMainTabPar.BPLI, tMainTabPar.PRF) + end + elseif sProperty == 'Layer' then -- lavorazione layer + + -- ottengo tutte le entità del gruppo + local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE') + + -- Applico le lavorazioni + for j = 1, #EntListGrp do + + local nParendId = EgtGetParent(EntListGrp[j]) + + -- Recupero la prima entità del layer padre + local EntList = MB.FindEntities( nParendId, true) + + -- LAVORAZIONI + local nMach = 1 + + -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme + bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, + nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach, + tMainTabPar.BPLI, tMainTabPar.PRF) + end + elseif sProperty == '' then -- proprietà nulla + + -- creo lavorazioni del gruppo + for k = 1, #tGroup do + + -- Recupero le entità + local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') + local bAdjustHead = false + + -- Applico le lavorazioni + for j = 1, #EntList do + + -- LAVORAZIONI + local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 + nMach = nMach - 30 -- se lavorazione corretta ottengo 1 + local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 + local sMachining = EgtGetInfo( EntList[j], 'Machining') + -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima + if nMach > 0 and nMach < 4 then nMach = 1 end + + if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then + + -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) + local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) + + -- se più di 1 entità le ordino + if #tListSameMach > 1 then + tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) + EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) + end + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, + tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, + GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + + -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto + SetInfoTable( tListSameMach, 'Mach2nd', 1) + + local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 + if nNewMach > 30 and nNewMach < 40 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo + elseif nNewMach > 40 and nNewMach < 50 then + SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo + end + end + end + + -- tolgo di mezzo le note secondarie + for j = 1, #EntList do + EgtRemoveInfo( EntList[j], 'Mach2nd') + end + end + end + elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore + DGD.ERR = -15 + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + if DGD.ERM and #DGD.ERM > 0 then + DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + else + DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza + end + end + + i = i + 1 + end + + ---------------------------------------- + -- Inserimento riferimenti e ventose + ---------------------------------------- + + -- Offset ventose da bordo pezzo in Y + dVacOffs = tMainTabPar.VOY + -- Offset barra riferimenti mobile da riferimenti quando posizione 0 + dMobOffs = tMainTabPar.MOY + dVacOffs + -- Lunghezza minima per alzare prima ventosa da bordo sinistro + dDistMinX = tMainTabPar.LDX + 40 + DIST_MIN_VAC_L -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Lunghezza minima per alzare prima ventosa da bordo destro + dDistMaxX = tMainTabPar.RDX + 40 + DIST_MIN_VAC_R -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) + -- Posizione ventose in alto + dVacOn = 75 + -- Interasse ventose + dInterAx = 232 + -- distanza interferenza con cave passanti + dDistInterferThru = tMainTabPar.DTG -- modificato da 20 a 12 il 26/10/2017 su richiesta di Mark + dDistInterferBlind = tMainTabPar.DBG + dDistInterferUnder = tMainTabPar.DUG + dDistInterferSide = tMainTabPar.DSG + + -- Ventose + local nTabId = EgtGetTableId( 'Tab') + local nMobId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE') + local nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') + local nDispId = EgtGetPhaseDisposition( nNumPhase) + -- se gruppi richiesti non trovati + if not nMobId or not nFixId then + bOk = false + DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' + break + end + -- Posizionamento barra mobile + local dOldVal = EgtGetInfo( nMobId, 'Val', 'd') + -- calcolo nuova posizione con: larghezza finita porta ( uso getDimX perché presa prima della disposizione porta) + + -- 2 volte il sovramateriale a contatto con il riferimento in basso - distanza ventose - offset barra + local dNewVal = b3Solid:getDimX() + OffsYSovr + OffsYSovr + vShift:getY() + vShiftVac:getY() - dVacOffs - dMobOffs + -- controllo che la posizione non supera la posizione massima raggiungibile dalla barra mobile + if dNewVal > tMainTabPar.MPMB then + dNewVal = tMainTabPar.MPMB + end + EgtMove( nMobId, Vector3d( 0, dNewVal - dOldVal, 0), GDB_RT.GLOB) + EgtSetInfo( nMobId, 'Val', dNewVal) + EgtSetInfo( nDispId, 'MOB', dNewVal) + -- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) + + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa + local dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( nDispMode > 0, dDistMinX, dDistMaxX) + + -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto + StartVacVerify( Ls, bFlip, dThickDoor) + + -- verifico se presente groove applicato a top su angolo + local sAngGrooveNote = EgtGetInfo( Pz, 'GrooveOnAngle', 's') + + -- ciclo sulle ventose + local nInd = 1 + local nIndVac + local nNumTotVacRow = 13 + local nCountFailed = 0 + local nIniFailed = 0 + local nMiddleFailed = 0 + local nEndFailed = 0 + local nMaxIniFailed = 0 + local nMaxMiddleFailed = 0 + local nMaxEndFailed = 0 + + while dCalcLen > 0 and nInd <= nNumTotVacRow do + + nIndVac = EgtIf( nDispMode > 0, nInd, ( nNumTotVacRow - nInd + 1)) + + local sInd = tostring( nIndVac) + + -- eseguo verifica + local nCenFixId = EgtGetFirstNameInGroup( nFixId, 'CEN'..sInd) + local pPntFix = EgtSP( nCenFixId, GDB_ID.ROOT) + + local bBlindColl = false + local bCanUpFix, nVacErr, bBlindColl, nCustType = ExecVacShapeVerify( pPntFix, tVacType[tMapVac[nInd]], tabOri, dDistInterferThru, dDistInterferBlind, + dDistInterferSide, false, 0, 0, EgtIf( nInd < 3, sAngGrooveNote, nil), + Ls, bFlip, nCenFixId) + if not bCanUpFix and nVacErr > 0 then + if nVacErr == 1 then + DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + elseif nVacErr == 3 then + DoorOutLog( 'Vacuul external of top angle path: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '.', 0) + else + DoorOutLog( 'Region SHAPE not found into vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + end + end +-- local bCanUpFix = ExecVacVerify( pPntFix, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), +-- Ls, bFlip, nCenFixId) + + local nCenMobId = EgtGetFirstNameInGroup( nMobId, 'CEN'..sInd) + local pPntMob = EgtSP( nCenMobId, GDB_ID.ROOT) + local bCanUpMob + bCanUpMob, nVacErr, bBlindColl, nCustType = ExecVacShapeVerify( pPntMob, tVacType[tMapVac[nInd]], tabOri, dDistInterferThru, dDistInterferBlind, + dDistInterferSide, false, 0, 0, EgtIf( nInd < 3, sAngGrooveNote, nil), + Ls, bFlip, nCenMobId) + if not bCanUpFix and nVacErr > 0 then + if nVacErr == 1 then + DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + elseif nVacErr == 3 then + DoorOutLog( 'Vacuul external of top angle path: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '.', 0) + else + DoorOutLog( 'Region SHAPE not found into vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) + end + end +-- local bCanUpMob = ExecVacVerify( pPntMob, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), +-- Ls, bFlip, nCenMobId) + -- eventuale movimento + if bCanUpFix and bCanUpMob then + + local nIdFix = AddMoveShowHideVac( KIND_DISP_MODE, nFixId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, tVacType[tMapVac[nInd]], ( pPntFix - tabOri)) + local nIdMov = AddMoveShowHideVac( KIND_DISP_MODE, nMobId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, tVacType[tMapVac[nInd]], ( pPntMob - tabOri)) + + -- salvo lo stato e info modalità disposizione + EgtSetInfo( nDispId, 'VAC'..sInd, dVacOn) + EgtSetInfo( nDispId, 'KIND_DISP_MODE'..sInd, KIND_DISP_MODE) +-- EgtSetInfo( nDispId, 'FIXIDS'..sInd, nIdFix) +-- EgtSetInfo( nDispId, 'MOBIDS'..sInd, nIdMov) + EgtSetInfo( nDispId, 'FIXPOS'..sInd, ( pPntFix - tabOri)) + EgtSetInfo( nDispId, 'MOBPOS'..sInd, ( pPntMob - tabOri)) + -- interrompo le serie negative + if nInd > 1 then + nCountFailed = 0 + if nMaxIniFailed < nIniFailed then + nMaxIniFailed = nIniFailed + end + if nMaxMiddleFailed < nMiddleFailed then + nMaxMiddleFailed = nMiddleFailed + end + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nIniFailed = 0 + nMiddleFailed = 0 + nEndFailed = 0 + end + else + EgtRemoveInfo( nDispId, 'VAC'..sInd) + EgtRemoveInfo( nDispId, 'KIND_DISP_MODE'..sInd) + AddMoveShowHideVac( 2, nFixId, 'VAC'..sInd) -- rendo visibile ventosa + AddMoveShowHideVac( 2, nMobId, 'VAC'..sInd) -- rendo visibile ventosa + + nCountFailed = nCountFailed + 1 + if nInd == 1 then -- setto solo il fallimento iniziale + nIniFailed = nCountFailed + elseif nInd == nNumTotVacRow or ( dCalcLen - dInterAx) <= 0 then -- setto solo quello finale e annullo il medio + nEndFailed = nCountFailed + if nMaxEndFailed < nEndFailed then + nMaxEndFailed = nEndFailed + end + nMiddleFailed = 0 + else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati + if nIniFailed > 0 then + nIniFailed = nCountFailed + elseif nEndFailed > 0 then + nEndFailed = nCountFailed - 1 + else + nMiddleFailed = nCountFailed + end + end + end + -- aggiorno la lunghezza di calcolo e l'indice + dCalcLen = dCalcLen - dInterAx + nInd = nInd + 1 + end + -- elimino geometrie per verifica + EndVacVerify() + + -- riassegno la quantità di file che effettivamente potrebbero essere alzate + nInd = nInd - 1 + + -- casi di scarse ventose + if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then -- tutte le ventose basse + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + elseif nInd > 0 and nMaxIniFailed / nInd > 0.35 then -- ventose iniziali ( parte destra) + local nNumMsg = EgtIf( nDispMode > 0, 532, 534) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then -- ventose intermedie + DGD.EMC = ' ' .. EgtDoorsMsg[533] + bOk = false + break + elseif nInd > 0 and nMaxEndFailed / nInd > 0.35 then -- ventose finale ( parte sinistra) + local nNumMsg = EgtIf( nDispMode > 0, 534, 532) + DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] + bOk = false + break + elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then -- somma di vari intervalli + DGD.EMC = ' ' .. EgtDoorsMsg[531] + bOk = false + break + end + + ------------------------------------------------- + -- gestione messaggi LIGHT: red, yellow, green + ------------------------------------------------- + + -- se ho geometrie da entrambe le parti la luce è red + if nNumGeomBottom > 0 and nNumGeomTop > 0 then + sLight = 'RED' + -- se non ho geometrie la luce è green + elseif nNumGeomBottom == 0 and nNumGeomTop == 0 then + sLight = 'GREEN' + -- se una delle due ha delle geometrie + else + -- in caso di geometrie tutte sotto luce yellow + if nNumGeomBottom > 0 then + sLight = 'YELLOW' + -- in caso di geometrie tutte sopra luce green + elseif nNumGeomTop > 0 then + sLight = 'GREEN' + end + end + + -- *** Tools Setup *** + -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri + local bSetUp = EgtImportSetup() + local tListError + local sListTool = '' + + if bSetUp then -- se importato quello di default + + sSetup = EgtGetDefaultSetupName() + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default + if bSetUp then + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- preparo la lista degli utensili mancanti + sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + end + + -- se fallito quello di default o utensili mancanti provo quello indicato nel CurrCamInfo + if not bSetUp then + + local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default + local nContImport = 0 + + -- ciclo tra quelli disponibili + for k = 1, 8 do + + if not bSetUp then + if k == 1 then + sSetup = mCamData[nNumMachFromCam].Setup1 + elseif k == 2 then + sSetup = mCamData[nNumMachFromCam].Setup2 + elseif k == 3 then + sSetup = mCamData[nNumMachFromCam].Setup3 + elseif k == 4 then + sSetup = mCamData[nNumMachFromCam].Setup4 + elseif k == 5 then + sSetup = mCamData[nNumMachFromCam].Setup5 + elseif k == 6 then + sSetup = mCamData[nNumMachFromCam].Setup6 + elseif k == 7 then + sSetup = mCamData[nNumMachFromCam].Setup7 + elseif k == 8 then + sSetup = mCamData[nNumMachFromCam].Setup8 + end + -- se nome attrezzaggio non è vuoto + if sSetup and #sSetup > 0 then + bSetUp = EgtImportSetup(sSetup) + end + + if bSetUp then -- se importato il fle da CurrCamInfo + nContImport = nContImport + 1 + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + break + else -- se utensili mancanti prendo la lista e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + end + else -- se non importato carico il messaggio di errore e passo al successivo + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) + end + end + end + + -- se nessuno è andato bene verifico se il primo era stato importato + if not bSetUp then + if ( sDefSetUp and #sDefSetUp > 0) or + nContImport > 0 then + if DGD.EMC and #DGD.EMC > 0 then + DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] + else + DGD.EMC = ' ' .. EgtDoorsMsg[551] + end + bOk = false + if #sListTool > 0 then + DGD.EMC = DGD.EMC .. sListTool + end + break + else -- setup default non definito + -- assegno ugualmente un attrezzaggio vuoto + EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) + end + else -- ha importato il file da CurrCamInfo + -- verifico se l'attrezzaggio è idoneo + bSetUp, tListError = EgtVerifyCurrSetup() + + if bSetUp then -- se è andato bene + -- assegno nota con il nome del file setup assegnato + EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) + else -- se utensili mancanti + sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', 1) + sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] + for k = 1, #tListError do + sListTool = sListTool .. '\n ' .. tListError[k] + end + DGD.EMC = DGD.EMC .. sListTool + bOk = false + break + end + end + end + + -- se nessuna geometria skippata esco + if nNumMachSkip and nNumMachSkip == 0 then bWork = false end + + -- se lavorazioni skippate abilito il ribaltamento porta in altra fase + if nNumMachSkip and nNumMachSkip > 0 then + nNumMachSkip = 0 -- resetto per il prossimo giro + -- per interrompere il giro forzatamente ( perché nessun ribaltamento) setto bWork + bWork = false + end + + nNumCycle = nNumCycle + 1 + + -- se deve uscire dal ciclo, prima di farlo, eseguo l'eventuale split della porta + if not bWork then + + -- gestione taglio longitudinale split door + -- assegnamento variabili + + -- se è una porta e nessuna lavorazione da sotto + if not sAssemb and nNumGeomBottom == 0 then + + local EntList = tSplitDoorEnt + + if #EntList == 1 then + -- acquisisco nota direzione taglio e la confronto con il parametro del currcaminfo + local sDirCut = EgtGetInfo( EntList[1], 'DirectionCut', 's') + if sDirCut and + ( ( sDirCut == 'H' and string.find( tMainTabPar.CDA, 'H')) or + ( sDirCut == 'W' and string.find( tMainTabPar.CDA, 'W'))) then + + bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[1], tSplitDataInf[1][7]) + + if bLocMach then + + local bInsLav = false + + local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 + + nLocMach = nMach + if nMach == 1 then + + -- carico id entità in una tabella + local tListSameMach = {} + table.insert( tListSameMach, nNewIdEnt) + + bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tSplitDataInf[1][1], tSplitDataInf[1][2], tSplitDataInf[1][3], + tSplitDataInf[1][4], tSplitDataInf[1][5], bOk, tSplitDataInf[1][6], false, + NGEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) + end + else + bOk = false + end + end + -- se ho più di un taglio do errore + elseif #EntList > 1 then + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + else + EgtOutBox( EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) + end + else + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[695], 0) + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + end + end + end -- end while + +--bOk = false -- per forzare l'errore + + if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end + + -- Eventuale messaggio di errore + if not bOk then + + DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + + DGD.ERR = 20 + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + + -- stampo gli errori del machiningBase + if DGD.EMC and #DGD.EMC > 0 then + DoorOutLog( DGD.EMC, 0) + end + + DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello il file cn e il txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con l'errore + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) + + if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD + if DGD.EMC and #DGD.EMC > 0 then + EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + else + EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation + end + end + + -- Salvo progetto + EgtSaveFile() + + return false, nNumGroup + end + + -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) + EgtApplyAllMachinings( false, false) + + -- Salvo progetto + EgtSaveFile() + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '3 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + -- controllo collisioni + local bSimOk + + -- Simulation for collision check + if tMainTabPar.ECD == 1 then + DoorOutLog( ' +++ Simulating with collision check >>>', 0) + EgtOutText( 'Start hidden simulation to find collision, It keep some time') + local nErr, sErr + bSimOk, nErr, sErr = EgtSimulate() + if not bSimOk then + if nErr == MCH_SHE.INIT then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[686], sErr) + EgtOutBox( string.format(EgtDoorsMsg[686], sErr), 'Simulation', 'Simulation') + elseif nErr == MCH_SHE.COLLISION then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[687], sErr) + EgtOutBox( string.format(EgtDoorsMsg[687], sErr), 'Collision', 'Collision') + elseif nErr == MCH_SHE.OUTSTROKE then + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[688], sErr) + EgtOutBox( string.format(EgtDoorsMsg[688], sErr), 'Outstroke', 'Outstroke') + else + DGD.ERR = 33 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[689], sErr) + EgtOutBox( string.format(EgtDoorsMsg[689], sErr), 'Simulation', 'Simulation') + end + end + EgtOutText( 'hidden simulation finished') + else + bSimOk = true + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '4 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end +-- -- inizializzo il contatore +-- EgtStartCounter() + + if bSimOk then + -- Estimation + bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) + -- NC code generation + bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath) + else + bOk = false + -- luce di caricamento porta + if sLight then + DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM + end + end + + if bOk then + + if not DGD.ERR then DGD.ERR = 0 end + + -- luce di caricamento porta + if sLight then + DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM + end + + DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori + end + end + DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) + -- copio il file txt con nuova estensione .tok + EgtCopyFile( sFileDir..sFileName..sNumGroup..'.txt', sFileDir..sFileName..sNumGroup..'.tok') + else + + -- se la simulazione è stata corretta ma errore nella generazione + if bSimOk then + DGD.ERR = 20 + DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) + end + + -- cancello il file tok + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') + -- cancello e ricreo il file txt + EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') + --ricreo il file txt con la disposizione + WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') + + -- se la simulazione è stata corretta ma errore nella generazione + if bSimOk then + -- scrivo messaggio nei file log + DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation + end + else + if not DGD.NCGEN then + if DGD.ERM and #DGD.ERM > 0 then + DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori + end + end + -- scrivo messaggio nei file log + DoorOutLog( EgtDoorsMsg[690], 0) -- Error on simulation + + -- se lanciato da DMach stampo anche un messaggio a video + if not DGD or not DGD.NCGEN then + DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) + EgtOutBox( EgtDoorsMsg[690], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on simulation + end + end + return false, nNumGroup + end + +-- nTime = EgtStopCounter() +-- if not DGD or not DGD.NCGEN then +-- EgtOutBox( string.format( '5 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') +-- end + + -- reset librerie locali + package.loaded[MachiningsTable] = nil + package.loaded[MachiningsTableOrd] = nil + + return true, nNumGroup +end + +return MachiningLoc diff --git a/Main.lua b/Main.lua new file mode 100644 index 0000000..8e718b9 --- /dev/null +++ b/Main.lua @@ -0,0 +1,12860 @@ +-- +-- 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 +-- +-- Main.lua by EgalWare s.r.l. 2016.05.28 +-- Main creazione porte da descrizione DDF +-- 2016.09.07 V1.001 FM Modificata gestione flush bolt +-- 2016.09.14 V1.002 FM Aggiunta gestione log file +-- 2017.06.27 V1.013 FM Manage frame jamb ( hinges jamb and lock jamb) +-- 2017.07.24 V1.014 FM Manage frame jamb ( top frame) and assembly ( more pieces into one ddf file) +-- 2017.12.13 V1.014 FM Manage parameter side on groove and face on flushpull models +-- 2018.01.12 V1.015 FM Fix errors on calculate frame point +-- 2018.01.22 V1.016 FM Manage Arc on top door side +-- 2018.02.14 V1.017 FM Add sizing +-- 2018.02.16 V1.018 FM Sizing top arc +-- 2018.02.16 V1.018 FM Fix missing assignement of DGD.SIDE with Stop & Closer and OverHead hardware model +-- 2018.03.23 V1.019 FM Add notes on side paths +-- 2018.04.09 V1.01a FM Manage KeepBackSet notes on flush pull geometries (into MoveFlushPull) and +-- on Lock sides (keyway and secure) rectangles and lines geometries (into MoveSubGeomLock) +-- 2018.04.17 V1.01b FM Manage new ddf parameters for viewers, louver and vision cutouts (to manage different application points) +-- 2018.05.09 V1.01c FM Assign name to all face surfaces ( before only on top and bottom surfaces) +-- 2018.05.17 V1.01d FM Manage position of Groove on narrow face and its surface +-- 2018.05.23 V1.01e FM Manage grove for all 4 sides +-- 2018.06.01 V1.01f FM Manage Z probe geometry near hardware templates +-- 2018.06.15 V1.020 FM Manage Rebuid Door and hardware application by probe point +-- 2018.06.22 V1.021 FM Fix bug on calculate rebuildel door +-- 2018.06.25 V1.022 FM Read different probe distance from dat file and extend line by these values +-- 2018.06.27 V1.023 FM Modify dat table, add manage error messages if dat file is missing and if enable side trim with probe mode +-- 2018.07.18 V1.024 FM Manage new groove parameters into ddf +-- 2018.07.19 V1.025 FM Manage properties field into DDF +-- 2018.07.20 V1.026 FM Fix bug on Strike Half disposition ( modify also EdgePullFlat component) +-- 2018.07.23 V1.027 FM Manage Alias Swing (actually for Haley Bros) +-- 2018.08.24 V1.028 FM Manage data.dat file instead of .dat into LoadDataProbeFile function +-- 2018.10.01 V1.029 FM Manage read zero value parameter (means disable probe in Z) into LoadDataProbeFile function +-- 2018.10.17 V1.02a FM Manage by parameter DGC.Edp ( into CurrDoorsCustomData.lua) differents profiles on Top Arc between top and sdes +-- 2018.10.17 V1.02a FM Fix error on create top arc beveled machining path +-- 2018.10.18 V1.02b FM Manage better recognizing opposite bevel profile (between sides) on Inactive doors +-- 2018.10.19 V1.02c FM Manage better recognize bad swing code from ddf +-- 2018.10.19 V1.02c FM Fix pivot disposition with new offset pivot dispositions +-- 2018.10.22 V1.02d FM Manage reference position (backset or door side) for secure and keyway geometries, for: lock +-- 2018.10.23 V1.02e FM DDF can manage more LouverCutOut items +-- 2018.10.26 V1.02f FM Manage disposition of flush bolt extra geometries +-- 2018.10.31 V1.030 FM Fix error on check backset (when backset is not defined into ddf) +-- 2018.11.09 V1.031 FM Move hinges geometries by new function MoveSubGeomHinge to manage which geometries have to rotate on profile or not +-- 2018.11.16 V1.032 FM Manage OH Stop and Closer aggregate of lua templates +-- 2018.11.26 V1.033 FM Manage Lock hardware disposition also on top and bottom door side by ddf parameter 'side:' +-- 'lock', 'bottom', 'top'. If ddf parameter is missing the default application side is 'lock' +-- 2018.11.30 V1.034 FM Manage RollerLatch hardware disposition also on lock door side +-- 2018.12.06 V1.035 FM Fix error on move keyway geometries into MoveSubGeomFlushBolt function +-- 2018.12.10 V1.036 FM Manage better solid geometry/shape with deepr striker horizontal faces: +-- (Roller latch strike, Edge pull flat, Mortise hinge, Over head Arm, Stop and Closer Arm) +-- 2018.12.11 V1.037 FM Manage reading DDF radius parameter on VisionCutOut with rectangle shape +-- 2018.12.17 V1.038 FM Fix bug on contour machining paths when profiles between head (top, bottom) and side (lock, hinge) are differents +-- 2018.12.18 V1.039 FM Make anti-splint machining path on top bottom side ( for horizontal tool) +-- 2018.12.20 V1.03a FM Extend previous feature V1.033 to different disposition side/reference assigned to ddf parameter 'side:' +-- 'lock_top', 'lock_bottom', 'bottom', 'top'. If ddf parameter is missing the default application side is 'lock_top' +-- 2019.01.15 V1.03b FM Fix error when load old ddf that not have lock reference with 'lock_top', 'lock_bottom' but only 'lock' +-- 2019.03.22 V1.03c FM Make better top arc paths with precise end point +-- 2019.03.29 V1.03d FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles +-- 2019.04.11 V1.03e FM Fix bug on calculate top arc points with new mode to set side profile (now top and side profiles can be set indipendent) +-- 2019.04.19 V1.03e FM Fix import hinges as nge file +-- 2019.04.29 V1.03f FM Manage new disposition for Flush_pull hardware, now dispose geometries one by one +-- 2019.05.06 V1.040 FM Fix semantic error on assign value = 0 to a not specified variable: tHinge.thickness into GetOneHinge function +-- 2019.05.15 V1.041 FM Manage new hardware type: Decoration +-- 2019.05.21 V1.042 FM Draw short sides on Draw mode only +-- 2019.05.30 V1.043 FM Fix error on calculate negative value for sqrt into CalcSideRectTringle function +-- 2019.07.01 V1.044 FM Manage new probe modes by variable DGC.Pms: 0 old complete probe (8 probe points) and door rebuild; +-- 1: recalculate dimension only on door width (4 probe points); 2: recalculate dimension on door width and length (5 probe points) +-- 2019.08.16 V1.045 FM Fix error on Move strike geometry managed as EdgePull, now it manage also 'upper' geometry in case side face is deep than 1/6 of door thickness +-- 2019.08.16 V1.046 FM Fix error on Move strike geometry managed as EdgePull, now not consider the backset value (that's used for locks and not for EdgePull) +-- 2019.08.27 V1.046 FM Modify the disposition of Pivot, now it move one by one geometry instead of move layer +-- 2019.08.30 V1.047 FM Manage 8 bullnose radius (according to default.ini Compo configuration amd CurrDoorsCustomdata.lua) +-- 2019.09.16 V1.048 FM Identify door properties by DGC settings variables +-- 2019.09.19 V1.049 FM Add manage new ddf side distance parameters for Decoration +-- 2019.10.03 V1.048 FM Remove: identify door properties by DGC settings variables +-- 2019.10.04 V1.049 FM Manage new ddf section: material. Now, by material value, lua components change geometries +-- 2019.10.18 V2.000 FM Manage use Materials +-- 2019.11.11 V2.001 FM Manage Top Chamfer Shape +-- 2019.11.22 V2.002 FM Manage let any profiles (SQ,BV,EB,BVEB,1B,2B,3B,4B,5B,6B,7B,8B,CV) to any sides (Top, Top Arc, Top Angle, Bottom, Hinge, Lock) +-- 2019.12.19 V2.003 FM Fix error on double use of SetInvertEdgeTrimming when bevel lock side is set to opposite bevel +-- 2020.05.06 V2.004 FM Enable roller latch, pivot, flush bolt also on frame bottom +-- 2020.05.18 V2.005 FM Manage frame disposition (on wide side or narrow side) by CurrDoorCustomData parameter DGC.Dxjs (x depend to material) +-- 2020.05.20 V2.006 FM Manage frame disposition narrow face limit by CurrDoorCustomData parameter DGC.Mjn +-- if narros side is smaller than this parameter then frame is dispossed on wide side (wide side on pods) +-- 2020.05.20 V2.007 FM Enable roller latch also on lock jamb, enable lock also on top and bottom frames +-- 2020.10.28 V2.008 FM Fix lock/strike disposition on top and bottom frames +-- 2020.11.12 V2.009 FM Fix flush_bolt disposition on top and bottom frames with or without lock/hinge rabbets +-- 2020.11.13 V2.00a FM Fix type error on definition of name variable sLocalHingeProf was sLocalHingeProfm +-- 2021.02.10 V3.000 FM Manage apply rabbet on opposite face (than standard) +-- 2021.04.23 V3.001 FM set DGD variable if a cut out has not hatching +-- 2021.05.27 V3.002 FM Manage special region (added to main region) from hatching paths to remove pods under hatching paths +-- 2021.06.01 V3.003 FM If not run by dProd, Show a message to update the ddf if ddf parameter 'piece:' not exists +-- 2021.08.05 V3.004 FM Fix error on disposition of geometry used to calculate regions of EdgePull flat hardware +-- 2021.10.11 V3.005 FM I not agree to this modification: manage DGC.Bwd parameter to refer the backset on wide side dimension, but this modification is not +-- for general purpose but apply this reference change only to some geometries that are on keyway/secure faces +-- 2021.10.26 V3.006 FM Manage FD Wedge Cup (FDWC) profile +-- 2021.11.23 V3.007 FM Manage option side probing. Expand function number of CurrDoorCustomData DGC.Pms: 3 side probe on all hardware (for NE machines) ; +-- 4: side probe on all hardware except hardware on hinge side (for machines with shuttles) +-- 2022.01.17 V3.008 FM Manage Split door cut by new Vision CutOut type +-- 2022.03.11 V3.009 FM Fix error (into MoveFlushBolt function) on calculate probe path with corner flush bolt and into InsertProbeGeom when side probe path has not to does +-- 2022.04.12 V3.00a FM Manage better the Sideprobe info into function InsertProbeGeom +-- 2022.04.28 V3.00a FM Manage Split door on door width direction +-- 2022.07.07 V3.00b FM Manage Lock aggregate of lua templates +-- 2022.07.27 V3.00c FM Modification to use compiled code +-- 2022.08.31 V3.00d FM Manage groove applied on top angle +-- 2022.11.15 V3.00e FM Manage side grove region as throu region and not as blind region +-- 2023.04.26 V3.00f FM Manage new DDF format by new ddf version number parameter +-- 2023.05.11 V3.010 FM Read new ddf group 'options:' (actually not used) at the end of ddf file +-- 2023.09.07 V3.011 FM try to delete the .tok file (it's a copy of .txt file) that dProd uses +-- 2023.12.01 V3.012 FM Manage new CurrDoorCustomData parameter DGC.CVP to define a small line on both corner of Convex profile +-- 2023.12.04 V3.013 FM Fix errors on build solid with bevel profile on top arc +-- 2024.02.01 V3.014 FM Manage new CurrCamInfo parameter 'SideDoorDefined' to manage door disposition with lock side machined by shuttle/s +-- 2024.07.01 V3.015 FM Fix error (that it appens only with frames) on DGD variable assignemente into InsertGeom function +-- 2024.10.15 V3.016 FM Manage new DGC.NPM parameter to indicate new DGD.PROBE meaning +-- 2024.10.31 V3.017 FM Manage probe id number and note 'ProbeId' on geometries that have hinge or lock probe geometry +-- 202x.xx.xx V3.xxx FM Manage new CurrCamInfo parameter 'WideDoorWidth' to manage large wide doors stored into new DGD.Part parameter + +-- 2023.04.27 Max num error message DGD.ERR = 28 + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +if not _G.DGD then + _G.DGD = {} +end + +--local sBaseDir = EgtGetSourceDir() +local sBaseDir = DGD.BASEDIR +EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') +EgtAddToPackagePath( sBaseDir .. '?.lua') +require( 'EgtDoorsBase') +require( 'EgtDoorsData') +require( 'CurrDoorsCustomData') +local EgtDoorsMsg = require( 'EgtDoorsMsg') + +-- variabili gestione macchine +local tMachineData +local sMTable +local sMTablePath +local sMTableOri + +-- info della porta +local tGenInfo={} +local tProbeDoor={} +local nNumHingePivot = 0 +local nCountPieces = 0 +local nTypePiece = 0 +local sFirstDoor +local sSecondDoor +local sFrameSx +local sFrameDx +local sFrameTop +local sFrameBot + +-- variabili dei file +local sFileDir, sFileName, sFileExt +local sErrFileM +local sErrFile +local sTxtOkFile +local sCncFile +local sLogFile +local sNgeFile +local sPrbFile +local sOriPrbFile + +-- variabili percorsi creati da probe 2 +local nDoorLeft +local nDoorRight +local nDoorTop +local nDoorBot +local nDoorLeftTop +local nDoorRightTop +local nDoorTopTop +local nDoorBotTop +local nDoorLeftMid +local nDoorRightMid +local nDoorTopMid +local nDoorBotMid +local bRemake = false + +---------------------------------------------------------------- +-- *** Error write file functions *** +----------------------------------------------------------------- +local function WriteErrFile( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.ERM and string.len(DGD.ERM) > 0 then + nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) + if DGD.EGR == 0 then + DGD.EGR = DGD.ERR + end + if DGD.EGM then + DGD.EGM = DGD.EGM .. '\n' .. DGD.ERM + end + else + nIdFile:write( 'Err=' .. tostring( DGD.ERR)) + end + if sDispMsg and string.len(sDispMsg) > 0 then + nIdFile:write('\n' .. sDispMsg) + DoorOutLog( sDispMsg, 0) + if DGD.EGM then + DGD.EGM = DGD.EGM .. '\n' .. sDispMsg + end + end + nIdFile:close() + end +end + +local function WriteErrFileAsmbl( sFileErr, sDispMsg) + local nIdFile = io.open( sFileErr, 'w') + if nIdFile then + if DGD.EGR ~= 0 then + nIdFile:write( 'Err=' .. tostring( DGD.EGR) .. DGD.EGM) + else + nIdFile:write( 'Err=' .. tostring( DGD.EGR)) + end + if sDispMsg and string.len(sDispMsg) > 0 then + nIdFile:write('\n' .. sDispMsg) + DoorOutLog( sDispMsg, 0) + end + nIdFile:close() + end +end + +----------------------------------------------------------------- +-- *** Geometry Calc *** +----------------------------------------------------------------- +local function CalcSideRectTringle( nCat1, nCat2, nIpo) + + local nSide = 0 + if not nIpo then -- se non ho l'ipotenusa + nSide = sqrt((nCat1*nCat1)+(nCat2*nCat2)) + elseif not nCat1 then -- se manca cateto 1 + nSide = sqrt(abs((nIpo*nIpo)-(nCat2*nCat2))) -- use abs in case the sub results is near 0 but negative value + elseif not nCat2 then -- se manca cateto 2 + nSide = sqrt(abs((nIpo*nIpo)-(nCat1*nCat1))) -- use abs in case the sub results is near 0 but negative value + end + return nSide +end + +----------------------------------------------------------------- +-- *** DDF file parsing *** +----------------------------------------------------------------- +local function KeyFromLine( sKey) + local sLine = GetLine() + if not sLine then + return false + end + if not sLine:find( sKey, 1, true) then + UngetLine( sLine) + return false + end + return true +end + +----------------------------------------------------------------- +local function CheckKeyFromLine( sKey) + local sLine = GetLine() + if not sLine then + return false + end + if not sLine:find( sKey, 1, true) then + UngetLine( sLine) + return false + else + UngetLine( sLine) + end + return true +end + +----------------------------------------------------------------- +local function EndOfFile( ) + local sLine = GetLine() + if not sLine then + return true + else + UngetLine( sLine) + return nil + end +end + +----------------------------------------------------------------- +local function StringFromLine( sKey) + local sLine = GetLine() + if not sLine then + return nil + end + if not sLine:find( sKey, 1, true) then + UngetLine( sLine) + return nil + end + local sVal = sLine:gsub( sKey, '') + return EgtTrim( sVal) +end + +----------------------------------------------------------------- +local function LenFromLine( sKey, bNotConv) + local sVal = StringFromLine( sKey) + if not sVal then return nil end + local dVal = tonumber( sVal) + if not dVal then return nil end + if not bNotConv and not DGD.bMM then dVal = dVal * GEO.ONE_INCH end + return dVal +end + +----------------------------------------------------------------- +local function GetVersion() + -- leggo il parametro di produzione del pezzo + local nPr = LenFromLine( 'version:', true) + if not nPr then + DGD.nVersion = 1 + else + DGD.nVersion = nPr + end + -- salvo in tabella + table.insert( tGenInfo, {'DDF version', DGD.nVersion}) + return true +end + +----------------------------------------------------------------- +local function GetProoduce() + -- leggo il parametro di produzione del pezzo + local sPr = StringFromLine( 'produce:') + if not sPr then + DGD.bProoduce = true + else + -- la interpreto + DGD.bProoduce = sPr == 'true' + end + -- salvo in tabella + table.insert( tGenInfo, {'Produce',DGD.bProoduce}) + return true +end + +----------------------------------------------------------------- +local function GetMeasures() + -- leggo l'unità di misura + local sUM = StringFromLine( 'measures:') + if not sUM then return false end + -- la interpreto + DGD.bMM = not ( sUM == 'inches') + -- salvo in tabella + table.insert( tGenInfo, {'MM',DGD.bMM}) + return true +end + +----------------------------------------------------------------- +local function GetCode() + -- leggo il codice + DGD.sCode = StringFromLine( 'code:') + if not ( DGD.sCode and DGD.sCode:len() > 0) then + return false + end + -- salvo in tabella + table.insert( tGenInfo, {'Code',DGD.sCode}) + return true +end + +----------------------------------------------------------------- +local function GetOrder() + -- leggo la chiave + if not KeyFromLine( 'order:') then + return false + end + -- leggo tutte le voci dell'ordine + line = GetLine() + + while line do + -- se trovo la data ho finito + if line:find( 'date:', 1, true) then + UngetLine( line) + break + end + -- leggo la voce + line = EgtTrim( line) + table.insert( DGD.tOrder, line) + -- leggo la prossima linea utile + line = GetLine() + end + -- salvo in tabella + table.insert( tGenInfo, {'Order', table.concat( DGD.tOrder, ',')}) + return true +end + +----------------------------------------------------------------- +local function GetDate() + -- leggo la data + DGD.sDate = StringFromLine( 'date:') + if not ( DGD.sDate and DGD.sDate:len() > 0) then + return false + end + -- salvo in tabella + table.insert( tGenInfo, {'Date',DGD.sDate}) + return true +end + +----------------------------------------------------------------- +local function GetPiece() + -- leggo se è un pezzo porta o telaio + local sPiece = StringFromLine( 'piece:') + -- se non trovato Piece assegno codice come porta singola e visualizzo un avviso + if not ( sPiece and sPiece:len() > 0) then + nTypePiece = 1 + DGD.nTypePz = nTypePiece + DoorOutLog( string.format( EgtDoorsMsg[691], DGD.FILE), 0) + if not DGD.NCGEN then + EgtOutBox( string.format(EgtDoorsMsg[691], DGD.FILE), EgtDoorsMsg[501], EgtDoorsMsg[502]) + end + return false + end + + if string.find( sPiece, 'DO_1') then + nTypePiece = 1 + DGD.sFrame = nil + elseif string.find( sPiece, 'DO_2') then + nTypePiece = 2 + DGD.sFrame = nil + elseif string.find( sPiece, 'FL_') then + nTypePiece = 3 + DGD.sFrame = string.gsub( sPiece, 'FL_', '') + elseif string.find( sPiece, 'FR_') then + nTypePiece = 4 + DGD.sFrame = string.gsub( sPiece, 'FR_', '') + elseif string.find( sPiece, 'FT_') then + nTypePiece = 5 + DGD.sFrame = string.gsub( sPiece, 'FT_', '') + elseif string.find( sPiece, 'FB_') then + nTypePiece = 6 + DGD.sFrame = string.gsub( sPiece, 'FB_', '') + else + nTypePiece = 1 + DGD.sFrame = nil + end + DGD.nTypePz = nTypePiece + + -- salvo in tabella + table.insert( tGenInfo, {'Frame',DGD.sFrame}) + table.insert( tGenInfo, {'Piece Type',nTypePiece}) + return true +end + +----------------------------------------------------------------- +local function GetPosition() + if not KeyFromLine( 'position:') then + return false + end + -- leggo la posizione in X + table.insert( DGD.tPosition, LenFromLine( 'x:')) + -- leggo la posizione in Y + table.insert( DGD.tPosition, LenFromLine( 'y:')) + -- leggo la posizione in Z + table.insert( DGD.tPosition, LenFromLine( 'z:')) + + if not ( DGD.tPosition[1] and DGD.tPosition[2] and DGD.tPosition[3]) then + return false + end + + table.insert( tGenInfo, {'PosFromDoor', DGD.tPosition}) + return true +end + +----------------------------------------------------------------- +local function GetSize() + -- leggo la chiave + if not KeyFromLine( 'size:') then + return false + end + -- leggo la larghezza + DGD.dW = LenFromLine( 'width:') + -- leggo l'altezza + DGD.dH = LenFromLine( 'height:') + -- leggo lo spessore + DGD.dT = LenFromLine( 'thickness:') + + -- leggo la pressione + local sPressure = StringFromLine( 'pressure:') or '0' + DGD.Pressure = tonumber(sPressure) + if DGD.Pressure < 0 then + DGD.Pressure = 0 + elseif DGD.Pressure > 20 then + DGD.Pressure = 20 + end + + -- verifico le letture + if not ( DGD.dW and DGD.dH and DGD.dT) then + return false + end + -- salvo in tabella + if DGD.sFrame then + if DGD.nTypePz == 5 or DGD.nTypePz == 6 then + table.insert( tGenInfo, {'W',DGD.dT}) + table.insert( tGenInfo, {'H',DGD.dW}) + table.insert( tGenInfo, {'T',DGD.dH}) + else + table.insert( tGenInfo, {'W',DGD.dT}) + table.insert( tGenInfo, {'H',DGD.dH}) + table.insert( tGenInfo, {'T',DGD.dW}) + end + else + table.insert( tGenInfo, {'W',DGD.dW}) + table.insert( tGenInfo, {'H',DGD.dH}) + table.insert( tGenInfo, {'T',DGD.dT}) + end + table.insert( tGenInfo, {'P',DGD.Pressure}) + return true +end + +----------------------------------------------------------------- +local function GetDoorHeight() + + -- leggo l'altezza originale porta + DGD.dOH = LenFromLine( 'origdoorheight:') + if not DGD.dOH then + return false + end + + -- salvo in tabella + table.insert( tGenInfo, {'OH', DGD.dOH}) + + return true +end + +----------------------------------------------------------------- +local function GetSwing() + + -- leggo il brandeggio + DGD.sAliasSwng = StringFromLine( 'swing:') + if not ( DGD.sAliasSwng and #DGD.sAliasSwng > 0) then + return false, '' + end + + DGD.sAliasSwng = string.upper(DGD.sAliasSwng) + + ----------------------------------------------------- + -- interpretazione swing e gestione alias per Haley + ----------------------------------------------------- + if DGD.sAliasSwng == 'LW' or DGD.sAliasSwng == 'RM' or DGD.sAliasSwng == 'BLANK' then -- alias per RH + DGD.sSwing = 'RH' + elseif DGD.sAliasSwng == 'RW' or DGD.sAliasSwng == 'LM' then -- alias per LH + DGD.sSwing = 'LH' + else -- per tutti gli altri casi + if DGD.sAliasSwng == 'RH' or DGD.sAliasSwng == 'RHA' or DGD.sAliasSwng == 'RHI' or + DGD.sAliasSwng == 'RHR' or DGD.sAliasSwng == 'RHRA' or DGD.sAliasSwng == 'RHRI' or + DGD.sAliasSwng == 'LH' or DGD.sAliasSwng == 'LHA' or DGD.sAliasSwng == 'LHI' or + DGD.sAliasSwng == 'LHR' or DGD.sAliasSwng == 'LHRA' or DGD.sAliasSwng == 'LHRI' then + + DGD.sSwing = DGD.sAliasSwng + else + return false, DGD.sAliasSwng + end + end + + -- salvo in tabella + table.insert( tGenInfo, {'AliasSwing', DGD.sAliasSwng}) + table.insert( tGenInfo, {'Swing', DGD.sSwing}) + return true +end + +----------------------------------------------------------------- +local function GetSecurSide() + -- leggo la disposzione del lato secure + DGD.sSecSide = StringFromLine( 'secure:') + if not ( DGD.sSecSide and #DGD.sSecSide > 0) then + return false + end + -- salvo in tabella + table.insert( tGenInfo, {'Secure', DGD.sSecSide}) + return true +end + +----------------------------------------------------------------- +local function GetDoorMaterial() + -- leggo il materiale porta + DGD.Material = StringFromLine( 'material:') + if not DGD.Material then + return false + end + -- se nome materiale esiste tolgo eventuali spazi vuoti + if #DGD.Material > 0 then + DGD.Material = string.gsub( DGD.Material, ' ', '') + else + return false + end + -- salvo in tabella + table.insert( tGenInfo, {'Material', DGD.Material}) + return true +end + +----------------------------------------------------------------- +local function GetDoorProperties() + -- leggo i parametri di proprietà + local sProperties = StringFromLine( 'properties:') + if not ( sProperties and sProperties:len() > 0) then + return false + end + -- converto in tabella + DGD.Properties = EgtSplitString( sProperties) + -- salvo in tabella + table.insert( tGenInfo, {'Properties', sProperties}) + return true +end + +----------------------------------------------------------------- +local function GetOneProfile( sName, nFindTopCurve) + local tProf = {} +-- tProf.trimming = EgtIf( DGD.sFrame, 'SQ', StringFromLine( sName..':')) + tProf.trimming = StringFromLine( sName..':') + if DGD.nVersion >= 2 then + tProf.trimming = StringFromLine( 'type:') + end + if not ( #tProf.trimming > 0) then + if DGD.nVersion >= 2 then + return 11 + else + return 5 + end + end + if StringFromLine( 'machining:') == 'ON' then + tProf.machining = true + else + tProf.machining = false + end + tProf.offset = LenFromLine( 'overmaterial:') + if not tProf.offset then + return 1 + end + if nFindTopCurve == 1 and not DGD.sFrame then + + tProf.radius = LenFromLine( 'radius:') + tProf.xdeltapos = LenFromLine( 'posx:') + tProf.angle = LenFromLine( 'angle:', true) + + -- se c'è il parametro del raggio e dell'angolo do errore + if tProf.angle and tProf.radius then + return 6 + -- se c'è l'angolo ma non il parametro della posizione x do errore + elseif tProf.angle and not tProf.xdeltapos then + return 7 + elseif tProf.angle and abs(tProf.angle) < GEO.EPS_SMALL then + tProf.angle = nil + tProf.xdeltapos = 0 + -- se c'è l'angolo e il parametro della posizione centro/inizio angolo in x è negativo, cambio di segno senza dare errore + elseif tProf.angle and tProf.xdeltapos < 0 then + tProf.xdeltapos = abs(tProf.xdeltapos) + -- se c'è l'angolo e il parametro posizione supera o eguaglia la larghezza porta azzero l'angolo e non do errore + elseif tProf.angle and tProf.xdeltapos > DGD.dW then + tProf.xdeltapos = 0 + tProf.angle = 0 + -- se c'è l'angolo e il suo valore supera i 45° do errore + elseif tProf.angle and abs(tProf.angle) > 45 then + return 9 + -- se c'è l'angolo e la risultante della parte inclinata in Y supera l'altezza porta do errore + elseif tProf.angle and abs((( DGD.dW - tProf.xdeltapos)*tan(abs(tProf.angle))) - DGD.dH) < GEO.EPS_SMALL*1000 then + return 10 + -- se c'è il parametro del centro in x ma non c'è il raggio o l'angolo do errore + elseif tProf.xdeltapos and not tProf.radius and not tProf.angle then + return 2 + -- se il raggio è inferiore alla metà larghezza porta do errore + elseif tProf.radius and tProf.radius < (DGD.dW/2) then + return 3 + -- Se la posizione X del centro sommata alla metà larghezza porta è maggiore del raggio + -- do errore perché non crea un arco che va tangente o secante al lato della porta opposto alla + -- posizione X del centro + elseif tProf.radius and tProf.xdeltapos and + abs(tProf.xdeltapos) + (DGD.dW/2) > tProf.radius then + return 3 + -- se profilo ad arco controllo i settaggi dei profili consentiti + elseif tProf.radius then + if DGC.Edp then -- se sono consentiti i profili differenti tra top e sides + -- in questo caso almeno i due lati devono essere uguali, se non lo sono do errore +-- if DGD.tProfs.lockedge.trimming ~= DGD.tProfs.hingeedge.trimming then +-- return 4 +-- end + -- altrimenti se non sono consentiti differenti profili tra top e sides e non lo sono do errore + elseif DGD.tProfs.lockedge.trimming ~= tProf.trimming or DGD.tProfs.hingeedge.trimming ~= tProf.trimming then + return 4 + end + end + end + + DGD.tProfs[sName] = tProf + -- salvo in tabella + table.insert( tGenInfo, { sName..'_trimming',tProf.trimming}) + table.insert( tGenInfo, { sName..'_machining',tProf.machining}) + table.insert( tGenInfo, { sName..'_offset',tProf.offset}) + + if nFindTopCurve == 1 then + if tProf.radius then + table.insert( tGenInfo, { sName..'_radius',tProf.radius}) + end + if tProf.xdeltapos then + table.insert( tGenInfo, { sName..'_xdeltapos',tProf.xdeltapos}) + end + if tProf.angle then + table.insert( tGenInfo, { sName..'_angle',tProf.angle}) + end + end + + return 0 +end + +----------------------------------------------------------------- +local function GetProfiles() + -- leggo la chiave + if not KeyFromLine( 'profiles:') then + return 1 + end + -- leggo le diverse parti + local nCodeErr = GetOneProfile( 'lockedge', 0) + if nCodeErr > 0 then + return nCodeErr + end + nCodeErr = GetOneProfile( 'hingeedge', 0) + if nCodeErr > 0 then + return nCodeErr + end + nCodeErr = GetOneProfile( 'top', 1) + if nCodeErr > 0 then + return nCodeErr + end + nCodeErr = GetOneProfile( 'bottom', 0) + if nCodeErr > 0 then + return nCodeErr + end + + return 0 +end + +----------------------------------------------------------------- +local function GetOneVisionCutOut() + local tVision = {} + tVision.shape = StringFromLine( '- shape:') + if not tVision.shape then + return false + end + local sSplit = StringFromLine( 'split:') + tVision.length = LenFromLine( 'length:') + tVision.width = LenFromLine( 'width:') + tVision.dir = StringFromLine( 'direction:') + tVision.top_rail = LenFromLine( 'top_rail:') + tVision.lock_stile = LenFromLine( 'lock_stile:') + tVision.radius = LenFromLine( 'radius:') + tVision.center_from_top = LenFromLine( 'center_from_top:') + tVision.center_from_lock = LenFromLine( 'center_from_lock:') + tVision.door_center = StringFromLine( 'door_center:') or 'lock' -- se nulla assegno vecchio valore default + tVision.split = sSplit == '1' + + if ( tVision.split and not tVision.width) or + ( sSplit == nil and + not ( tVision.length and tVision.width and tVision.top_rail and tVision.lock_stile) and + not ( tVision.radius and tVision.center_from_top and tVision.center_from_lock)) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[513]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[513]) + DGD.ERR = -9 + return false + end + -- se ho split abilitato ( == '1') + if tVision.split then + tVision.lock_stile = 0 + if not tVision.dir or tVision.dir == '0' then + tVision.door_center = 'center' + tVision.top_rail = 0 + else + if not tVision.top_rail then + tVision.top_rail = 0 + end + end + -- altrimenti se ho split assente + elseif sSplit == nil then + tVision.split = sSplit + end + table.insert( DGD.tVisions, tVision) + -- salvo in tabella + local sName = 'vision_cut_out'..tostring(#DGD.tVisions) + table.insert( tGenInfo, {sName ..'_shape',tVision.shape}) + table.insert( tGenInfo, {sName ..'_split',tVision.split}) + table.insert( tGenInfo, {sName ..'_length',tVision.length}) + table.insert( tGenInfo, {sName ..'_width',tVision.width}) + table.insert( tGenInfo, {sName ..'_direction',tVision.dir}) + table.insert( tGenInfo, {sName ..'_top_rail',tVision.top_rail}) + table.insert( tGenInfo, {sName ..'_lock_stile',tVision.lock_stile}) + table.insert( tGenInfo, {sName ..'_radius',tVision.radius}) + table.insert( tGenInfo, {sName ..'_center_from_top',tVision.center_from_top}) + table.insert( tGenInfo, {sName ..'_center_from_lock',tVision.center_from_lock}) + table.insert( tGenInfo, {sName ..'_door_center',tVision.door_center}) + return true +end + +----------------------------------------------------------------- +local function GetVisionCutOuts() + -- leggo la chiave + if not KeyFromLine( 'vision_cut_outs:') then + return false + end + -- leggo le diverse sfinestrature + while GetOneVisionCutOut() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneLouverCutOut() + local tLouver = {} + tLouver.shape = StringFromLine( '- shape:') + if not tLouver.shape then + return false + end + tLouver.length = LenFromLine( 'length:') + tLouver.width = LenFromLine( 'width:') + tLouver.bottom_rail = LenFromLine( 'bottom_rail:') + tLouver.lock_stile = LenFromLine( 'lock_stile:') + tLouver.door_center = StringFromLine( 'door_center:') or 'lock' -- se nulla assegno vecchio valore default + + if not ( tLouver.length and tLouver.width and tLouver.bottom_rail and tLouver.lock_stile) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[514]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[514]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tLouvers, tLouver) + -- salvo in tabella + local sName = 'louver_cut_out'..tostring(#DGD.tLouvers) + table.insert( tGenInfo, {sName ..'_shape',tLouver.shape}) + table.insert( tGenInfo, {sName ..'_length',tLouver.length}) + table.insert( tGenInfo, {sName ..'_width',tLouver.width}) + table.insert( tGenInfo, {sName ..'_bottom_rail',tLouver.bottom_rail}) + table.insert( tGenInfo, {sName ..'_lock_stile',tLouver.lock_stile}) + table.insert( tGenInfo, {sName ..'_door_center',tLouver.door_center}) + return true +end + +----------------------------------------------------------------- +local function GetLouverCutOut() + -- leggo la chiave + if not KeyFromLine( 'louver_cut_outs:') then + return false + end + -- leggo le diverse sfinestrature + while GetOneLouverCutOut() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneMailSlot( ) -- i parametri acquisiti in questa funzione e i loro nomi, possono non essere quelli passati + local tMailSlot = {} + tMailSlot.template = StringFromLine( '- template:') -- template o shape ? + if not tMailSlot.template then + return false + end + tMailSlot.length = LenFromLine( 'height:') -- cambiato nome parametro da length a height + tMailSlot.bottom_rail = LenFromLine( 'bottom_rail:') + tMailSlot.delta_center = LenFromLine( 'delta_center:') -- nome inventato + + if not ( tMailSlot.length and tMailSlot.bottom_rail and tMailSlot.delta_center) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[515]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[515]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tMailSlots, tMailSlot) + -- salvo in tabella + local sName = 'mail_slot'..tostring(#DGD.tMailSlots) + table.insert( tGenInfo, {sName ..'_template',tMailSlot.template}) + table.insert( tGenInfo, {sName ..'_height',tMailSlot.length}) + table.insert( tGenInfo, {sName ..'_bottom_rail',tMailSlot.bottom_rail}) + table.insert( tGenInfo, {sName ..'_delta_center',tMailSlot.delta_center}) + return true +end + +----------------------------------------------------------------- +local function GetMailSlots() + -- leggo la chiave + if not KeyFromLine( 'mail_slots:') then + return false + end + -- leggo le diverse sfinestrature + while GetOneMailSlot() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneViewer( ) -- i parametri acquisiti in questa funzione e i loro nomi, possono non essere quelli passati + local tViewer = {} + tViewer.template = StringFromLine( '- template:') -- template + if not tViewer.template then + return false + end + tViewer.bottom_rail = LenFromLine( 'bottom_rail:') + tViewer.delta_center = LenFromLine( 'delta_center:') -- nome inventato + tViewer.side = StringFromLine( 'side:') + + if not ( tViewer.bottom_rail and tViewer.delta_center) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[516]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[516]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tViewers, tViewer) + -- salvo in tabella + local sName = 'viewer'..tostring(#DGD.tViewers) + table.insert( tGenInfo, {sName ..'_template',tViewer.template}) + table.insert( tGenInfo, {sName ..'_bottom_rail',tViewer.bottom_rail}) + table.insert( tGenInfo, {sName ..'_delta_center',tViewer.delta_center}) + table.insert( tGenInfo, {sName ..'_side',tViewer.side}) + return true +end + +----------------------------------------------------------------- +local function GetViewers() + -- leggo la chiave + if not KeyFromLine( 'viewers:') then + return false + end + -- leggo le diverse sfinestrature + while GetOneViewer() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneFlushPull() + local tFlushPull = {} + tFlushPull.template = StringFromLine( '- template:') -- template o shape ? + if not tFlushPull.template then + return false + end + tFlushPull.position = LenFromLine( 'position:') + tFlushPull.back_set = LenFromLine( 'back_set:') + tFlushPull.depth = LenFromLine( 'depth:') + tFlushPull.face = StringFromLine( 'face:') + + if not ( tFlushPull.position and tFlushPull.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[517]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[517]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tFlushPulls, tFlushPull) + -- salvo in tabella + local sName = 'flush_pull'..tostring(#DGD.tFlushPulls) + table.insert( tGenInfo, {sName ..'_template',tFlushPull.template}) + table.insert( tGenInfo, {sName ..'_position',tFlushPull.position}) + table.insert( tGenInfo, {sName ..'_back_set',tFlushPull.back_set}) + table.insert( tGenInfo, {sName ..'_depth',tFlushPull.depth}) + table.insert( tGenInfo, {sName ..'_face',tFlushPull.face}) + return true +end + +----------------------------------------------------------------- +local function GetFlushPulls() + -- leggo la chiave + if not KeyFromLine( 'flush_pulls:') then + return false + end + -- leggo le diverse sfinestrature + while GetOneFlushPull() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneHinge( ) + local tHinge = {} + tHinge.template = StringFromLine( '- template:') + if not tHinge.template then + return false + end + tHinge.position = LenFromLine( 'ToptoTop:') + if not tHinge.position then + tHinge.position = LenFromLine( 'ToptoCL:') + end + tHinge.back_set = LenFromLine( 'back_set:') + tHinge.thickness = LenFromLine( 'thickness:') + +-- if not tHinge.thickness then tHinge.thickness = 0 end + if not ( tHinge.position and tHinge.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[518]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[518]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tHinges, tHinge) + -- salvo in tabella + local sName = 'hinge'..tostring(#DGD.tHinges) + table.insert( tGenInfo, {sName ..'_template',tHinge.template}) + table.insert( tGenInfo, {sName ..'_position',tHinge.position}) + table.insert( tGenInfo, {sName ..'_back_set',tHinge.back_set}) + table.insert( tGenInfo, {sName ..'_thickness',tHinge.thickness}) + return true +end + +----------------------------------------------------------------- +local function GetHinges() + -- leggo la chiave + if not KeyFromLine( 'hinges:') then + return false + end + -- leggo le diverse parti + while GetOneHinge() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneEPT( ) + local tEPT = {} + tEPT.template = StringFromLine( '- template:') + if not tEPT.template then + return false + end + tEPT.position = LenFromLine( 'ToptoCL:') + tEPT.back_set = LenFromLine( 'FacetoCL:') + + if not ( tEPT.position and tEPT.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[588]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[588]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tEPTs, tEPT) + -- salvo in tabella + local sName = 'ept'..tostring(#DGD.tEPTs) + table.insert( tGenInfo, {sName ..'_template',tEPT.template}) + table.insert( tGenInfo, {sName ..'_toptocl',tEPT.position}) + table.insert( tGenInfo, {sName ..'_facetocl',tEPT.back_set}) + return true +end + +----------------------------------------------------------------- +local function GetEPT() + -- leggo la chiave + if not KeyFromLine( 'ept:') then + return false + end + -- leggo le diverse parti + while GetOneEPT() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneLock( ) + local tLock = {} + tLock.template = StringFromLine( '- template:') + if not tLock.template then + return false + end + tLock.position = LenFromLine( 'position:') + tLock.back_set = LenFromLine( 'back_set:') + tLock.offset = LenFromLine( 'offset_WS:') + tLock.side = StringFromLine( 'side:') + tLock.other_door = StringFromLine( 'other_door:') + + -- per compatibilità con vecchie versioni, se parametro .side == 'lock' lo rinomino in 'lock_top' + if tLock.side and tLock.side == 'lock' then + tLock.side = 'lock_top' + end + + if not ( tLock.position and tLock.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[519]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[519]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tLocks, tLock) + -- salvo in tabella + local sName = 'lock'..tostring(#DGD.tLocks) + table.insert( tGenInfo, {sName ..'_template',tLock.template}) + table.insert( tGenInfo, {sName ..'_position',tLock.position}) + table.insert( tGenInfo, {sName ..'_back_set',tLock.back_set}) + table.insert( tGenInfo, {sName ..'_offset_WS',tLock.offset}) + table.insert( tGenInfo, {sName ..'_side',tLock.side}) + table.insert( tGenInfo, {sName ..'_other_door',tLock.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetLocks() + -- leggo la chiave + if not KeyFromLine( 'locks:') then + return false + end + -- leggo le diverse parti + while GetOneLock() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneFlushBolt( ) + local tFlushBolt = {} + tFlushBolt.template = StringFromLine( '- template:') + if not tFlushBolt.template then + return false + end + tFlushBolt.type = StringFromLine( 'type:') + tFlushBolt.side = StringFromLine( 'side:') + tFlushBolt.position = LenFromLine( 'position:') + tFlushBolt.offset = LenFromLine( 'offset_WS:') + tFlushBolt.back_set = LenFromLine( 'back_set:') + tFlushBolt.other_door = StringFromLine( 'other_door:') + + if not ( tFlushBolt.type and tFlushBolt.side and tFlushBolt.position) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[520]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[520]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tFlushBolts, tFlushBolt) + -- salvo in tabella + local sName = 'flush bolt'..tostring(#DGD.tFlushBolts) + table.insert( tGenInfo, {sName ..'_template',tFlushBolt.template}) + table.insert( tGenInfo, {sName ..'_type',tFlushBolt.type}) + table.insert( tGenInfo, {sName ..'_side',tFlushBolt.side}) + table.insert( tGenInfo, {sName ..'_position',tFlushBolt.position}) + table.insert( tGenInfo, {sName ..'_offset_WS',tFlushBolt.offset}) + table.insert( tGenInfo, {sName ..'_back_set',tFlushBolt.back_set}) + table.insert( tGenInfo, {sName ..'_other_door',tFlushBolt.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetFlushBolts() + -- leggo la chiave + if not KeyFromLine( 'flush_bolts:') then + return false + end + -- leggo le diverse parti + while GetOneFlushBolt() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneEdgePull() + local tEdgePull = {} + tEdgePull.template = StringFromLine( '- template:') + if not tEdgePull.template then + return false + end + tEdgePull.position = LenFromLine( 'position:') + tEdgePull.offset = LenFromLine( 'offset_WS:') + + if not ( tEdgePull.position) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[521]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[521]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tEdgePulls, tEdgePull) + -- salvo in tabella + local sName = 'edge_pull'..tostring(#DGD.tEdgePulls) + table.insert( tGenInfo, {sName ..'_template',tEdgePull.template}) + table.insert( tGenInfo, {sName ..'_position',tEdgePull.position}) + table.insert( tGenInfo, {sName ..'_offset_WS',tEdgePull.offset}) + return true +end + +----------------------------------------------------------------- +local function GetEdgePulls() + -- leggo la chiave + if not KeyFromLine( 'edge_pulls:') then + return false + end + -- leggo le diverse parti + while GetOneEdgePull() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneRollerLatch() + local tRollerLatch = {} + tRollerLatch.template = StringFromLine( '- template:') + if not tRollerLatch.template then + return false + end + tRollerLatch.side = StringFromLine( 'side:') + tRollerLatch.position = LenFromLine( 'position:') + tRollerLatch.offset = LenFromLine( 'offset_WS:') + tRollerLatch.other_door = StringFromLine( 'other_door:') + + if not ( tRollerLatch.side and tRollerLatch.position) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[522]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[522]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tRollerLatchs, tRollerLatch) + -- salvo in tabella + local sName = 'roller_latch'..tostring(#DGD.tRollerLatchs) + table.insert( tGenInfo, {sName ..'_template',tRollerLatch.template}) + table.insert( tGenInfo, {sName ..'_side',tRollerLatch.side}) + table.insert( tGenInfo, {sName ..'_position',tRollerLatch.position}) + table.insert( tGenInfo, {sName ..'_offset_WS',tRollerLatch.offset}) + table.insert( tGenInfo, {sName ..'_other_door',tRollerLatch.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetRollerLatchs() + -- leggo la chiave + if not KeyFromLine( 'roller_latchs:') then + return false + end + -- leggo le diverse parti + while GetOneRollerLatch() do + end + return true +end + +----------------------------------------------------------------- +local function GetOnePivot() + local tPivot = {} + tPivot.template = StringFromLine( '- template:') + if not tPivot.template then + return false + end + tPivot.type = StringFromLine( 'type:') + tPivot.side = StringFromLine( 'side:') + tPivot.radius = LenFromLine( 'radius:') + tPivot.position = LenFromLine( 'position:') + tPivot.back_set = LenFromLine( 'back_set:') + tPivot.depth_f = LenFromLine( 'depth:') + tPivot.offset = LenFromLine( 'offset_WS:') + tPivot.other_door = StringFromLine( 'other_door:') + + if not ( tPivot.type and tPivot.side and tPivot.position and tPivot.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[523]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[523]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tPivots, tPivot) + -- salvo in tabella + local sName = 'pivot'..tostring(#DGD.tPivots) + table.insert( tGenInfo, {sName ..'_template',tPivot.template}) + table.insert( tGenInfo, {sName ..'_type',tPivot.type}) + table.insert( tGenInfo, {sName ..'_side',tPivot.side}) + table.insert( tGenInfo, {sName ..'_radius',tPivot.radius}) + table.insert( tGenInfo, {sName ..'_position',tPivot.position}) + table.insert( tGenInfo, {sName ..'_back_set',tPivot.back_set}) + table.insert( tGenInfo, {sName ..'_depth',tPivot.depth_f}) + table.insert( tGenInfo, {sName ..'_offset_WS',tPivot.offset}) + table.insert( tGenInfo, {sName ..'_other_door',tPivot.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetPivots() + -- leggo la chiave + if not KeyFromLine( 'pivot:') then + return false + end + -- leggo le diverse parti + while GetOnePivot() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneStopAndCloser( ) + local tStopAndCloser = {} + tStopAndCloser.template = StringFromLine( '- template:') + if not tStopAndCloser.template then + return false + end + tStopAndCloser.position = LenFromLine( 'position:') + tStopAndCloser.pocket_offset = LenFromLine( 'pocket_offset_WS:') + tStopAndCloser.other_door = StringFromLine( 'other_door:') + + if not ( tStopAndCloser.position) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[524]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[524]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tStopsAndClosers, tStopAndCloser) + -- salvo in tabella + local sName = 'StopAndCloser'..tostring(#DGD.tStopsAndClosers) + table.insert( tGenInfo, {sName ..'_template',tStopAndCloser.template}) + table.insert( tGenInfo, {sName ..'_position',tStopAndCloser.position}) + table.insert( tGenInfo, {sName ..'_pocket_offset',tStopAndCloser.pocket_offset}) + table.insert( tGenInfo, {sName ..'_other_door',tStopAndCloser.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetStopsAndClosers() + -- leggo la chiave + if not KeyFromLine( 'stops_and_closers:') then + return false + end + -- leggo le diverse parti + while GetOneStopAndCloser() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneOHead( ) + local tOHead = {} + tOHead.template = StringFromLine( '- template:') + if not tOHead.template then + return false + end + tOHead.pockpos = LenFromLine( 'point_to_pocket:') + tOHead.pocklength = LenFromLine( 'pocket_length:') + tOHead.pocket_offset = LenFromLine( 'pocket_offset_WS:') + tOHead.armpos = LenFromLine( 'point_to_arm:') + tOHead.armlength = LenFromLine( 'arm_length:') + tOHead.other_door = StringFromLine( 'other_door:') + + if not ( tOHead.pockpos and tOHead.pocklength and + tOHead.armpos and tOHead.armlength) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[525]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[525]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tOHeads, tOHead) + -- salvo in tabella + local sName = 'OverHead'..tostring(#DGD.tOHeads) + table.insert( tGenInfo, {sName ..'_template',tOHead.template}) + table.insert( tGenInfo, {sName ..'_point_to_pocket',tOHead.pockpos}) + table.insert( tGenInfo, {sName ..'_pocket_length',tOHead.pocklength}) + table.insert( tGenInfo, {sName ..'_pocket_offset_WS',tOHead.pocket_offset}) + table.insert( tGenInfo, {sName ..'_point_to_arm',tOHead.armpos}) + table.insert( tGenInfo, {sName ..'_arm_length',tOHead.armlength}) + table.insert( tGenInfo, {sName ..'_other_door',tOHead.other_door}) + return true +end + +----------------------------------------------------------------- +local function GetOverHeads() + -- leggo la chiave + if not KeyFromLine( 'oh_stop_closer:') then + return false + end + -- leggo le diverse parti + while GetOneOHead() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneStrike( ) + local tStrike = {} + tStrike.template = StringFromLine( '- template:') + if not tStrike.template then + return false + end + tStrike.position = LenFromLine( 'position:') + tStrike.back_set = LenFromLine( 'back_set:') + tStrike.offset = LenFromLine( 'offset_WS:') + tStrike.other_door = StringFromLine( 'other_door:') + + if not ( tStrike.position and tStrike.back_set) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[538]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[538]) + DGD.ERR = -9 + return false + end + if not DGD.sFrame or DGD.sFrame == 'L' or DGD.sFrame == 'LE' then + table.insert( DGD.tStrikes, tStrike) + -- salvo in tabella + local sName = 'strike'..tostring(#DGD.tStrikes) + table.insert( tGenInfo, {sName ..'_template',tStrike.template}) + table.insert( tGenInfo, {sName ..'_position',tStrike.position}) + table.insert( tGenInfo, {sName ..'_back_set',tStrike.back_set}) + table.insert( tGenInfo, {sName ..'_offset_WS',tStrike.offset}) + table.insert( tGenInfo, {sName ..'_other_door',tStrike.other_door}) + end + return true +end + +----------------------------------------------------------------- +local function GetStrikes() + -- leggo la chiave + if not KeyFromLine( 'strikes:') then + return false + end + -- leggo le diverse parti + while GetOneStrike() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneGroove( ) + local tGroove = {} + tGroove.template = StringFromLine( '- template:') + if not tGroove.template then + return false + end + tGroove.type = StringFromLine( 'type:') + tGroove.width = LenFromLine( 'width:') + tGroove.depth = LenFromLine( 'depth:') + tGroove.fst = LenFromLine( 'face skin thick:') + tGroove.hst = LenFromLine( 'hinge style thick:') + tGroove.lst = LenFromLine( 'lock style thick:') + tGroove.groove_offset = LenFromLine( 'offset_WS:') + tGroove.side = StringFromLine( 'side:') + + if not ( tGroove.type and tGroove.width and tGroove.depth) and + not ( tGroove.type and tGroove.fst and tGroove.hst and tGroove.lst and tGroove.depth) then + -- messaggio errore dati incongruenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[539]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[539]) + DGD.ERR = -9 + return false + end + + table.insert( DGD.tGrooves, tGroove) + -- salvo in tabella + local sName = 'Groove'..tostring(#DGD.tGrooves) + table.insert( tGenInfo, {sName ..'_template',tGroove.template}) + table.insert( tGenInfo, {sName ..'_type',tGroove.type}) + table.insert( tGenInfo, {sName ..'_width',tGroove.width}) + table.insert( tGenInfo, {sName ..'_depth',tGroove.depth}) + table.insert( tGenInfo, {sName ..'_face_skin_thick',tGroove.fst}) + table.insert( tGenInfo, {sName ..'_hinge_skin_thick',tGroove.hst}) + table.insert( tGenInfo, {sName ..'_lock_skin_thick',tGroove.lst}) + table.insert( tGenInfo, {sName ..'_offset_WS',tGroove.groove_offset}) + table.insert( tGenInfo, {sName ..'_side',tGroove.side}) + return true +end + +----------------------------------------------------------------- +local function GetGrooves() + -- leggo la chiave + if not KeyFromLine( 'groove:') then + return false + end + -- leggo le diverse parti + while GetOneGroove() do + end + return true +end + +----------------------------------------------------------------- +local function GetOneRabbet( ) + local tRabbet = {} + tRabbet.template = StringFromLine( '- template:') + if not tRabbet.template then + return false + end + tRabbet.side = StringFromLine( 'side:') + tRabbet.width = LenFromLine( 'width:') + tRabbet.depth = LenFromLine( 'depth:') + tRabbet.angle = LenFromLine( 'angle:', true) + tRabbet.oppo = LenFromLine( 'opposite:', true) + + if not ( tRabbet.side and tRabbet.width and tRabbet.depth) then + -- messaggio errore dati inconguenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[550]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[550]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tRabbets, tRabbet) + -- salvo in tabella + local sName = 'Rabbet'..tostring(#DGD.tRabbets) + table.insert( tGenInfo, {sName ..'_template',tRabbet.template}) + table.insert( tGenInfo, {sName ..'_side',tRabbet.side}) + table.insert( tGenInfo, {sName ..'_width',tRabbet.width}) + table.insert( tGenInfo, {sName ..'_depth',tRabbet.depth}) + table.insert( tGenInfo, {sName ..'_angle',tRabbet.angle}) + table.insert( tGenInfo, {sName ..'_opposite',tRabbet.oppo}) + return true +end + +----------------------------------------------------------------- +local function GetRabbets() + -- leggo la chiave + if not KeyFromLine( 'rabbet:') then + return false + end + -- leggo le diverse parti + while GetOneRabbet() do + -- se è un frame lato lock o hinge, Exterior + if DGD.sFrame and + ( DGD.sFrame == 'LE' or DGD.sFrame == 'HE' or DGD.sFrame == 'TE' or DGD.sFrame == 'BE') then + -- prendo il parametro di affondamento del rabbet sul lato + local sRabbetType = DGD.tRabbets[#DGD.tRabbets].side + if sRabbetType == 'hinge' or sRabbetType == 'lock' then + + if DGD.dZedExtFrame == 0 then + DGD.dZedExtFrame = DGD.tRabbets[#DGD.tRabbets].depth + end + if DGD.dSideExtFrame == 0 and ( DGD.sFrame == 'LE' or DGD.sFrame == 'HE') then + DGD.dSideExtFrame = DGD.tRabbets[#DGD.tRabbets].depth + end + + -- prendo la larghezza del rabbet per il sill( frame bottom) con angolo + if DGD.sFrame == 'LE' or DGD.sFrame == 'HE' then + if DGD.dWidthRabbet == 0 then + DGD.dWidthRabbet = DGD.tRabbets[#DGD.tRabbets].width + end + end + end + end + end + return true +end + +----------------------------------------------------------------- +local function GetOneDecoration( ) + local tDecoration = {} + tDecoration.template = StringFromLine( '- template:') + if not tDecoration.template then + return false + end + tDecoration.type = StringFromLine( 'type:') + tDecoration.depth = LenFromLine( 'depth:') + tDecoration.dft = LenFromLine( 'topdistance:') + tDecoration.dfb = LenFromLine( 'bottomdistance:') + tDecoration.dfl = LenFromLine( 'lockstiledistance:') + tDecoration.dfh = LenFromLine( 'hingestiledistance:') + tDecoration.face = StringFromLine( 'face:') + + if not ( tDecoration.face and tDecoration.type) then + -- messaggio errore dati incongruenti + DoorOutLog( string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[646]), 0) + DGD.ERM = DGD.ERM .. string.format(EgtDoorsMsg[512], GetLineNumber(), EgtDoorsMsg[646]) + DGD.ERR = -9 + return false + end + table.insert( DGD.tDecorations, tDecoration) + -- salvo in tabella + local sName = 'Face Decoration'..tostring(#DGD.tDecorations) + table.insert( tGenInfo, {sName ..'_template',tDecoration.template}) + table.insert( tGenInfo, {sName ..'_type',tDecoration.type}) + table.insert( tGenInfo, {sName ..'_depth',tDecoration.depth}) + table.insert( tGenInfo, {sName ..'_distance_from_top',tDecoration.dft}) + table.insert( tGenInfo, {sName ..'_distance_from_bottom',tDecoration.dfb}) + table.insert( tGenInfo, {sName ..'_distance_from_lock',tDecoration.dfl}) + table.insert( tGenInfo, {sName ..'_distance_from_hinge',tDecoration.dfh}) + table.insert( tGenInfo, {sName ..'_face',tDecoration.face}) + return true +end + +----------------------------------------------------------------- +local function GetDecorations() + -- leggo la chiave + if not KeyFromLine( 'face_decoration:') then + return false + end + -- leggo le diverse parti + while GetOneDecoration() do + end + return true +end + +----------------------------------------------------------------- +local function GetOptions() + -- leggo la chiave + if not KeyFromLine( 'options:') then + return false + end + -- mentre non è finito il file + while not( CheckKeyFromLine( '---') or CheckKeyFromLine( '...') or EndOfFile()) do + -- leggo tutte le voci dell'ordine + line = GetLine() + -- leggo la voce + line = EgtTrim( line) + table.insert( DGD.tOptions, line) + end + -- salvo in tabella + table.insert( tGenInfo, {'Options', table.concat( DGD.tOptions, ',')}) + return true +end + +------------------------------------------------------------------------- +-- *** Insert probe point into door piece *** +------------------------------------------------------------------------- +local function InsertProbeGeom( nIdGeom, ptPosGeom, ptFromExt, nTypeHw, nNumSide) + + if not DGD.sFrame and DGD.MachEn > 0 then + + -- cerco se ho delle geometrie di tastatura con gli shuttle su lato hinge o lato lock + local bFoundShuttleProbe + local nIdEnt = EgtGetFirstInGroup( nIdGeom) -- ottengo prima entità + while nIdEnt do + local sNameEnt = EgtGetName( nIdEnt) or '' + if sNameEnt and string.find( sNameEnt, 'Hinge_Probe') or string.find( sNameEnt, 'Shuttle_Probe') then + bFoundShuttleProbe = true + break + end + nIdEnt = EgtGetNext(nIdEnt) + end + -- ottengo le note kbs o pbs dal layer + local bExistsKbs = EgtGetInfo( nIdGeom, 'kbs', 'i') or 0 + local bExistspbs = EgtGetInfo( nIdGeom, 'pbs', 'i') or 0 + local bProbeParGeom = ptPosGeom and ( bExistsKbs > 0 or bExistspbs > 0) + -- foro lato secure e parametri probe esistenti oppure presente shuttle probe + if bFoundShuttleProbe or bProbeParGeom then + DGD.CPR = DGD.CPR + 1 + -- assegnazione nota a tutte le geometrie del layer + nIdEnt = EgtGetFirstInGroup( nIdGeom) -- ottengo prima entità + while nIdEnt do + EgtSetInfo( nIdEnt, 'ProbeId', DGD.CPR) + nIdEnt = EgtGetNext(nIdEnt) + end + end + if bProbeParGeom then + -- se prod comanda tastature (completa o solo ricalcolo dimensioni) ed è presente il flag + if DGD.PROBE == 1 and bExistsKbs > 0 then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BOTTOM)) + local pCenter = Point3d( ptPosGeom:getX(),-ptPosGeom:getY(),0) + local nCircle = EgtArc( nIdGeom, pCenter, 0.25, 0, 360, 0, GDB_RT.GRID) + if nCircle then + EgtModifyCurveThickness( nCircle, -5) + EgtSetName( nCircle,'ProbePoint_secure') + EgtSetInfo( nCircle, 'ProbeId', DGD.CPR) + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + -- creazione geometria di tastatura laterale + if DGD.PROBE == 0 and bExistspbs > 0 and DGC.Pms and ( DGC.Pms == 3 or ( DGC.Pms == 4 and nTypeHw and nTypeHw ~= 5 and nTypeHw ~= 17)) and ptFromExt then + local nLine = EgtLine( nIdGeom, Point3d( ptFromExt:getX(), ptFromExt:getY(), 0), Point3d( ptPosGeom:getX(), ptPosGeom:getY(), 0), GDB_RT.GLOB) + if nLine then + -- se linea più lunga di un millimetro la accorcio o viceversa se è più corta + local dDist = dist( Point3d( ptFromExt:getX(), ptFromExt:getY(), 0), Point3d( ptPosGeom:getX(), ptPosGeom:getY(), 0)) + if dDist < 0.9 or dDist > 1.1 then + EgtTrimExtendCurveByLen( nLine, 1-dDist, Point3d( ptPosGeom:getX(), ptPosGeom:getY(), 0), GDB_RT.GLOB) + end + EgtModifyCurveThickness( nLine, 0) + EgtSetName( nLine,'ProbeSidePoint_secure') + EgtSetInfo( nLine, 'ProbeId', DGD.CPR) + EgtSetInfo( nLine, 'SideApplied', nNumSide) + end + end + end + -- se prod comanda tastature (completa o solo ricalcolo dimensioni) ed è presente il flag inserisco foro lato keyway + -- foro lato keyway + if DGD.PROBE == 1 and bExistsKbs > 0 and ptPosGeom then + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + local pCenter = Point3d( ptPosGeom:getX(),ptPosGeom:getY(),DGD.dT) + local nCircle = EgtArc( nIdGeom, pCenter, 0.25, 0, 360, 0, GDB_RT.GRID) + if nCircle then + EgtModifyCurveThickness( nCircle, -5) + EgtSetName( nCircle,'ProbePoint_keyway') + EgtSetInfo( nCircle, 'ProbeId', DGD.CPR) + end + end + -- creazione geometria di tastatura laterale + if ptPosGeom and DGD.PROBE == 0 and bExistspbs > 0 and DGC.Pms and ( DGC.Pms == 3 or ( DGC.Pms == 4 and nTypeHw and nTypeHw ~= 5 and nTypeHw ~= 17)) and ptFromExt then + local nLine = EgtLine( nIdGeom, Point3d( ptFromExt:getX(), ptFromExt:getY(), DGD.dT), Point3d( ptPosGeom:getX(), ptPosGeom:getY(), DGD.dT), GDB_RT.GLOB) + if nLine then + -- se linea più lunga di un millimetro la accorcio o viceversa se è più corta + local dDist = dist( Point3d( ptFromExt:getX(), ptFromExt:getY(), DGD.dT), Point3d( ptPosGeom:getX(), ptPosGeom:getY(), DGD.dT)) + if dDist < 0.9 or dDist > 1.1 then + EgtTrimExtendCurveByLen( nLine, 1-dDist, Point3d( ptPosGeom:getX(), ptPosGeom:getY(), 0), GDB_RT.GLOB) + end + EgtModifyCurveThickness( nLine, 0) + EgtSetName( nLine,'ProbeSidePoint_keyway') + EgtSetInfo( nLine, 'ProbeId', DGD.CPR) + EgtSetInfo( nLine, 'SideApplied', nNumSide) + end + end + end +end + +------------------------------------------------------------------------- +-- *** Geometric processing : VISION, LOUVER, MAIL *** +------------------------------------------------------------------------- +local function MoveCutOuts( tCutOut, sSideLk, bPushDr, bImport, nTypeCout) + + if not tCutOut then return end + if not tCutOut.geom then return end + if not DGD.SPLIT and DGD.SPLIT ~= nil then return end + + local ptPos + local ptRef + local dZedPos = 0 + local dExtraPosX = 0 + local dExtraPosY = 0 + local nAngleBase + local nRadBase + -- setto presenza cutout + DGD.ExistCutOut = true + -- rilevo e setto presenza hatching sfridi + if not EgtGetInfo( tCutOut.geom, 'hatch', 'b') then + DGD.NotExistHatch = true + end + + if bImport then dZedPos = DGD.dT end + + -- se vision cut out + if nTypeCout == 1 then + if tCutOut.lock_stile and tCutOut.top_rail then + if tCutOut.split and tCutOut.dir and tCutOut.dir == '1' then + if sSideLk == 'L' then -- se serratura a sinistra + dExtraPosX = 0 + else + dExtraPosX = DGD.dW - tCutOut.width + end + if abs(tCutOut.top_rail) > 0 then + dExtraPosY = 0 + else + dExtraPosY = (DGD.dH - tCutOut.width) / 2 + end + else + dExtraPosX = EgtIf( tCutOut.door_center == 'center', (( DGD.dW - tCutOut.width)/2), 0) + end + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + nAngleBase = atan((tCutOut.lock_stile + dExtraPosX),tCutOut.top_rail) + nRadBase = sqrt(((tCutOut.lock_stile + dExtraPosX)*(tCutOut.lock_stile + dExtraPosX))+(tCutOut.top_rail*tCutOut.top_rail)) + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( tCutOut.lock_stile + dExtraPosX), ( DGD.dH - tCutOut.top_rail - dExtraPosY), dZedPos) + end + else +-- if tCutOut.width < 0 then tCutOut.width = DGD.dW end -- vecchia modalita per creare porta ad arco + if bRemake then + nAngleBase = atan((tCutOut.lock_stile + tCutOut.width + dExtraPosX),tCutOut.top_rail) + nRadBase = sqrt(((tCutOut.lock_stile + tCutOut.width + dExtraPosX)*(tCutOut.lock_stile + tCutOut.width + dExtraPosX))+(tCutOut.top_rail*tCutOut.top_rail)) + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( DGD.dW - tCutOut.lock_stile - tCutOut.width - dExtraPosX), ( DGD.dH - tCutOut.top_rail - dExtraPosY), dZedPos) + end + end + else + dExtraPosX = EgtIf( tCutOut.door_center == 'center', (DGD.dW/2), 0) + if bRemake then + nAngleBase = atan((tCutOut.center_from_lock + dExtraPosX),tCutOut.center_from_top) + nRadBase = sqrt(((tCutOut.center_from_lock + dExtraPosX)*(tCutOut.center_from_lock + dExtraPosX))+(tCutOut.center_from_top*tCutOut.center_from_top)) + end + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( tCutOut.center_from_lock + dExtraPosX), DGD.dH - tCutOut.center_from_top, dZedPos) + end + else + if bRemake then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( DGD.dW - tCutOut.center_from_lock - dExtraPosX), DGD.dH - tCutOut.center_from_top, dZedPos) + end + end + end + -- per non scaricare sfrido quando corto e cade + if DGD.LENGTH and DGD.LENGTH < 400 then + DGD.NotExistHatch = false + end + + -- se louver cut out + elseif nTypeCout == 2 then + + dExtraPosX = EgtIf( tCutOut.door_center == 'center', (( DGD.dW - tCutOut.width)/2), 0) + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + nAngleBase = atan((tCutOut.lock_stile + dExtraPosX),tCutOut.bottom_rail) + nRadBase = sqrt(((tCutOut.lock_stile + dExtraPosX)*(tCutOut.lock_stile + dExtraPosX))+(tCutOut.bottom_rail*tCutOut.bottom_rail)) + ptRef = DGD.PminBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A3-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A3-nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( tCutOut.lock_stile + dExtraPosX), tCutOut.bottom_rail, dZedPos) + end + else + if bRemake then + nAngleBase = atan((tCutOut.lock_stile + tCutOut.width + dExtraPosX),tCutOut.bottom_rail) + nRadBase = sqrt(((tCutOut.lock_stile + tCutOut.width + dExtraPosX)*(tCutOut.lock_stile + tCutOut.width + dExtraPosX))+(tCutOut.bottom_rail*tCutOut.bottom_rail)) + ptRef = DGD.PmaxBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A8+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A8+nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( DGD.dW - tCutOut.lock_stile - tCutOut.width - dExtraPosX), tCutOut.bottom_rail, dZedPos) + end + end + -- per non scaricare sfrido quando corto e cade + if DGD.LENGTH and DGD.LENGTH < 400 then + DGD.NotExistHatch = false + end + + -- se mail slot + elseif nTypeCout == 6 then + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + nAngleBase = atan((( DGD.dW / 2) + tCutOut.delta_center),tCutOut.bottom_rail) + nRadBase = sqrt(((( DGD.dW / 2) + tCutOut.delta_center)*(( DGD.dW / 2) + tCutOut.delta_center))+(tCutOut.bottom_rail*tCutOut.bottom_rail)) + ptRef = DGD.PminBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A3-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A3-nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( ( DGD.dW / 2) + tCutOut.delta_center), tCutOut.bottom_rail, dZedPos) + end + else + if bRemake then + nAngleBase = atan((( DGD.dW / 2) - tCutOut.delta_center),tCutOut.bottom_rail) + nRadBase = sqrt(((( DGD.dW / 2) - tCutOut.delta_center)*(( DGD.dW / 2) - tCutOut.delta_center))+(tCutOut.bottom_rail*tCutOut.bottom_rail)) + ptRef = DGD.PmaxBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A8+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A8+nAngleBase)) , dZedPos) + else + ptPos = Point3d( ( ( DGD.dW / 2) - tCutOut.delta_center), tCutOut.bottom_rail, dZedPos) + end + end + -- per non scaricare sfrido (in questo caso piccolo e cade) + DGD.NotExistHatch = false + end + + EgtMove( tCutOut.geom, ptPos - ORIG()) + if bRemake then + if abs(dExtraPosX) > 0 or tCutOut.delta_center then + local dAngleLoc + dAngleLoc = (DGD.A3 + DGD.A8) / 2 + EgtRotate( tCutOut.geom, ptPos, Z_AX(), ( dAngleLoc-90)) + else + EgtRotate( tCutOut.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + end + + if bImport then + EgtModifyCurveThickness(tCutOut.geom, -DGD.dT) + -- se non ci sono tagli di hatching + if DGD.NotExistHatch then + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( tCutOut.geom, tCutOut.geom, false) + else + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( tCutOut.geom, tCutOut.geom, false, 1) + end + end + + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( tCutOut.geom, tCutOut.geom) +end + +------------------------------------------------------------------------- +-- *** Geometric processing : FLUSH_PULL *** +------------------------------------------------------------------------- +local function MoveFlushPull( tFlushPull, sSideLk, bPushDr, bImport) + + if not tFlushPull then return end + if not tFlushPull.geom then return end + + local ptPos + local ptPosBox + local ptRef + local dZedPos = 0 + local nNewEnt + local sTypeInfo + local sKeepBSNote + local nAngleBase + local nRadBase + local nRadBaseBox + + -- sul lato keyway o secure + if bImport then + nNewEnt = EgtGetFirstInGroup( tFlushPull.geom) -- ottengo nuova entità + while nNewEnt do + sTypeInfo = EgtGetInfo( nNewEnt, 'SideDoor') + if sTypeInfo then + EgtSetInfo( nNewEnt, 'SideDoor', '') + end + nNewEnt = EgtGetNext(nNewEnt) + end + end + + -- setto la faccia dove portare la geometrie + if not DGD.FACE then -- se non ho definito il face la setto come era prima + if bPushDr then -- se porta a spingere la geometria va dietro + DGD.FACE = 'secure' + else -- altrimenti + DGD.FACE = 'keyway' + end + end + + if string.lower(DGD.FACE) == 'secure' then -- se specificato face su lato interno (dietro) + -- faccio il mirror di tutte le geometrie su asse Z + nNewEnt = EgtGetFirstInGroup( tFlushPull.geom) -- ottengo nuova entità + while nNewEnt do + EgtMirror( nNewEnt, ORIG(), Z_AX()) -- faccio il mirror su asse Z + nNewEnt = EgtGetNext(nNewEnt) + end + if not bImport then + dZedPos = DGD.dT + InvertSurfName( tFlushPull.geom) + end + else -- altrimenti va su lato esterno (davanti) + if bImport then + dZedPos = DGD.dT + end + end + + if bRemake then + nAngleBase = atan(tFlushPull.back_set,tFlushPull.position) + nRadBase = sqrt((tFlushPull.back_set*tFlushPull.back_set)+(tFlushPull.position*tFlushPull.position)) + nRadBaseBox = tFlushPull.position + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A4)), ptRef:getY()+(nRadBaseBox*sin(DGD.A4)) , dZedPos) + else + ptPos = Point3d( tFlushPull.back_set, DGD.dH - tFlushPull.position, dZedPos) + ptPosBox = Point3d( 0, DGD.dH - tFlushPull.position, dZedPos) + end + else + if bRemake then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A7)), ptRef:getY()+(nRadBaseBox*sin(DGD.A7)) , dZedPos) + else + ptPos = Point3d( DGD.dW - tFlushPull.back_set, DGD.dH - tFlushPull.position, dZedPos) + ptPosBox = Point3d( DGD.dW, DGD.dH - tFlushPull.position, dZedPos) + end + + -- faccio il mirror di tutte le geometrie in X + nNewEnt = EgtGetFirstInGroup( tFlushPull.geom) -- ottengo nuova entità + while nNewEnt do + EgtMirror( nNewEnt, ORIG(), X_AX()) -- faccio il mirror in X + nNewEnt = EgtGetNext(nNewEnt) + end + end + + -- ciclo spostamento e rotazione di tutte le geometrie del flush_pull + nNewEnt = EgtGetFirstInGroup( tFlushPull.geom) -- ottengo la prima geometria + + while nNewEnt do + + local bReference = EgtGetInfo( nNewEnt, 'ReferHw', 'b') or false + local ptPosLoc = ptPos + if bReference then + ptPosLoc = Point3d( ptPosBox:getX(), ptPosLoc:getY() , ptPosLoc:getZ()) + end + + EgtMove( nNewEnt, ptPosLoc - ORIG()) +-- EgtSaveFile( sNgeFile) + if bRemake then + EgtRotate( nNewEnt, ptPosLoc, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) +-- EgtSaveFile( sNgeFile) + end + AddSurfTmByExtrusion( EgtGetParent(nNewEnt), nNewEnt, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( tFlushPull.geom, tFlushPull.geom) + nNewEnt = EgtGetNext(nNewEnt) + end +--[[ + -- spostamento e rotazione del layer del flush_pull + EgtMove( tFlushPull.geom, ptPos - ORIG()) + if bRemake then + EgtRotate( tFlushPull.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + + if bImport then + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( tFlushPull.geom, tFlushPull.geom, false) + end + + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( tFlushPull.geom, tFlushPull.geom) +]]-- + + -- setto le note per il probe in Z in base a dove si sono piazzate + -- devo ottenere tutte le geometrie + nNewEnt = EgtGetFirstInGroup( tFlushPull.geom) -- ottengo la prima geometria + + while nNewEnt do + sKeepBSNote = EgtGetInfo( nNewEnt, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + -- se geometria su lato wide, risetto la nota opportuna + if ( string.lower(DGD.FACE) == 'secure' and bPushDr) or + ( string.lower(DGD.FACE) == 'keyway' and not bPushDr) then + EgtSetInfo( nNewEnt, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + else -- altrimenti è sul lato narrow + EgtSetInfo( nNewEnt, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narrow + end + end + nNewEnt = EgtGetNext(nNewEnt) + end + InsertProbeGeom( tFlushPull.geom, ptPos) +end + +----------------------------------------------- +-- *** Geometric subgeom processing : HINGE *** +----------------------------------------------- +local function MoveSubGeomHinge( nSubHingeId, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoor and sSideDoor == 'upper' then + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + if bPushDr then + EgtSetInfo( nSubHingeId, 'SideDoor', 'secure') + sSideDoor = 'secure' + else + EgtSetInfo( nSubHingeId, 'SideDoor', 'keyway') + sSideDoor = 'keyway' + end + else + EgtSetInfo( nSubHingeId, 'SideDoor', 'keyway') + sSideDoor = 'keyway' + end + nUpperToDelete = nSubHingeId + end + + -- se non ha nota o ha la nota hinge + if not sSideDoor or string.lower( sSideDoor) == 'hinge' then + + EgtRotate( nSubHingeId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubHingeId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubHingeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubHingeId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubHingeId, ptPos - ORIG()) + elseif sSideDoor == 'locklh' or sSideDoor == 'sidelh' then -- se posizionamento serratura tipo cerniera + + if sSideDoor == 'locklh' then + nExtraAngle = 0 + end + + EgtRotate( nSubHingeId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubHingeId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubHingeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubHingeId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubHingeId, ptPos - ORIG()) + elseif sSideDoor == 'keyway' or sSideDoor == 'secure' then + + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubHingeId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubHingeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubHingeId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + if sSideDoor == 'keyway' then + EgtMove( nSubHingeId, ptPosUpGeom - ORIG()) + elseif sSideDoor == 'secure' then + EgtMove( nSubHingeId, ptPosDwGeom - ORIG()) + end + else + + EgtRotate( nSubHingeId, ORIG(), X_AX(), 90 ) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubHingeId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubHingeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubHingeId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubHingeId, ptPos - ORIG()) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubHingeId), nSubHingeId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubHingeId), EgtGetParent(nSubHingeId)) + end + + return nUpperToDelete +end + +--------------------------------------------- +-- *** Geometric subgeom processing : EPT *** +--------------------------------------------- +local function MoveSubGeomEpt( nSubEptId, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle) + + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoor and sSideDoor == 'upper' then + if DGD.Dws then -- se disposizione frame su lato wide + EgtSetInfo( nSubEptId, 'SideDoor', 'keyway') + sSideDoor = 'keyway' + end + nUpperToDelete = nSubEptId + end + + -- se geometria sul fianco + if sSideDoor == 'lock' or sSideDoor == 'side' then + +-- if bPushDr then +-- nExtraAngle = - nExtraAngle +-- end + + if sSideDoor == 'lock' then + nExtraAngle = 0 + end + + EgtRotate( nSubEptId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + EgtRotate( nSubEptId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubEptId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubEptId, ptPos - ORIG()) + + elseif sSideDoor == 'locklh' or sSideDoor == 'sidelh' then -- se posizionamento serratura tipo cerniera + + -- cambio di segno ancora un'altra volta + if bPushDr then + nExtraAngle = - nExtraAngle + end + + if sSideDoor == 'locklh' then + nExtraAngle = 0 + end + + EgtRotate( nSubEptId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubEptId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubEptId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubEptId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubEptId, ptPos - ORIG()) + elseif sSideDoor == 'keyway' or sSideDoor == 'secure' then + + if DGD.Dws then -- se disposizione frame su lato wide + + EgtRotate( nSubEptId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubEptId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubEptId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubEptId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubEptId, ptPos - ORIG()) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubEptId), nSubEptId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubEptId), EgtGetParent(nSubEptId)) + end + + return nUpperToDelete +end + +----------------------------------------------------------------------- +-- *** Geometric processing : common functions for hinge and Ept *** +----------------------------------------------------------------------- +local function MoveGeometryHng( sTypeGeom, nGeomId, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + + if not nGeomId then return end + + -- se profilo lato cerniere è bevel setto il supplemento di rotazione + local nIdGeomType + local sSideDoorToMove + local sMessageErr = '' + + if nExtraAngle > 0 and sTypeGeom == 'ept' then + if bPushDr then + nExtraAngle = - nExtraAngle + end + end + + -- ottengo la prima geometria + nIdGeomType = EgtGetFirstInGroup( nGeomId) + local nErr = 0 + + while nIdGeomType do + + sSideDoorToMove = EgtGetInfo( nIdGeomType, 'SideDoor') + local nUpperToDelete + + if sSideDoorToMove and sTypeGeom == 'ept' then + + -- Controllo se la nota è corretta + local sSideDoor = string.lower(sSideDoorToMove) + + -- lock: senza rotazione angolo profilo; side: con rotazione angolo profilo; keyway e Secure: no rotazione angolo profilo; + -- SideLH: con rotazione angolo profilo e disposizione come cerniera ( suffisso LH: like hinge), cioè senza effettuare mirror; + -- LockLH: senza rotazione agolo profilo e disposizione come cerniera ( suffisso LH: like hinge), cioè senza effettuare mirror + -- attenzione! la geometria con nota SideLH DEVE ESSERE SIMMETRICA sulla X e Y locale + -- attenzione! la geometria con nota LockLH DEVE ESSERE SIMMETRICA sulla X e Y locale + if sSideDoor == 'lock' or sSideDoor == 'side' or sSideDoor == 'sidelh' or sSideDoor == 'locklh' or sSideDoor == 'upper' then + nUpperToDelete = MoveSubGeomEpt( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[413],nIdGeomType,'Ept',nGeomId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1019 + end + else + -- messaggio di errore in base al tipo di pezzo + if sTypeGeom == 'ept' then + sMessageErr = string.format( EgtDoorsMsg[414],nIdGeomType,'Ept',nEdgePId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1020 + else -- altrimenti è hinge + + local sSideDoor + -- Acquisisco la nota + if sSideDoorToMove then + sSideDoor = string.lower(sSideDoorToMove) + end + + -- SideLH: con rotazione angolo profilo e disposizione come cerniera ( suffisso LH: like hinge), cioè senza effettuare mirror; + -- LockLH: senza rotazione agolo profilo e disposizione come cerniera ( suffisso LH: like hinge), cioè senza effettuare mirror + nUpperToDelete = MoveSubGeomHinge( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + end + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + end + end + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +----------------------------------------------------------------- +-- *** Geometric processing : HINGES *** +----------------------------------------------------------------- +local function MoveHinge( tHinge, sSideLk, bPushDr) + + if not tHinge then return end + if not tHinge.geom then return end + + local dDeltaPos = 0 + local sDeltaPos = EgtGetInfo( tHinge.geom, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + local ptPos + local ptRef + local ptProbe + local ptFromExt + local dZedPos = EgtIf( bPushDr, 0, DGD.dT) + local ptPosUpGeom + local ptPosDwGeom + + if sSideLk == 'L' then -- se serratura a sinistra + if DGD.sFrame then + ptPos = Point3d( DGD.dW - DGD.dZedExtFrame, ( DGD.dH - tHinge.position - dDeltaPos), dZedPos) + ptProbe = Point3d( DGD.dW - DGD.DPR, ( DGD.dH - tHinge.position - dDeltaPos), 0) + else + if bRemake then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+((tHinge.position + dDeltaPos)*cos(DGD.A7)), ptRef:getY()+((tHinge.position + dDeltaPos)*sin(DGD.A7)) , dZedPos) + else + ptPos = Point3d( DGD.dW, ( DGD.dH - tHinge.position - dDeltaPos), dZedPos) + ptProbe = Point3d( DGD.dW - DGD.DPR, ( DGD.dH - tHinge.position - dDeltaPos), 0) + ptFromExt = Point3d( DGD.dW, ( DGD.dH - tHinge.position - dDeltaPos), 0) + end + end + else -- serratura a destra + if DGD.sFrame then + ptPos = Point3d( DGD.dZedExtFrame, ( DGD.dH - tHinge.position - dDeltaPos), dZedPos) + ptProbe = Point3d( DGD.DPR, ( DGD.dH - tHinge.position - dDeltaPos), 0) + ptFromExt = Point3d( 0, ( DGD.dH - tHinge.position - dDeltaPos), 0) + else + if bRemake then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+((tHinge.position + dDeltaPos)*cos(DGD.A4)), ptRef:getY()+((tHinge.position + dDeltaPos)*sin(DGD.A4)) , dZedPos) + else + ptPos = Point3d( 0, ( DGD.dH - tHinge.position - dDeltaPos), dZedPos) + ptProbe = Point3d( DGD.DPR, ( DGD.dH - tHinge.position - dDeltaPos), 0) + ptFromExt = Point3d( 0, ( DGD.dH - tHinge.position - dDeltaPos), 0) + end + end + end + + -- setto i punti sulle facce per le geometrie di ingombro + ptPosUpGeom = Point3d( ptPos:getX(), ptPos:getY() , DGD.dT) + ptPosDwGeom = Point3d( ptPos:getX(), ptPos:getY() , 0) + + -- se profilo lato cerniera è bevel setto il supplemento di rotazione + local nExtraAngle = 0 + 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 + nExtraAngle = 3 + end + + MoveGeometryHng( 'hinge', tHinge.geom, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + + if bRemake then + EgtRotate( tHinge.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A8, DGD.A3)-90)) + end + InsertProbeGeom( tHinge.geom, ptProbe, ptFromExt, 5, 1) +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : LOCKS *** +----------------------------------------------------------------- +local function MoveSubGeomLock( nSubLockId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nExtraAngle, ptPosBox) + + local sKeepBSNote + local nUpperToDelete + + -- se geometria sul fianco + if sSideDoor == 'lock' or sSideDoor == 'side' then + + if sSideDoor == 'lock' or ( DGD.SIDE and DGD.SIDE ~= 'lock_top' and DGD.SIDE ~= 'lock_bottom') then + nExtraAngle = 0 + end + + EgtRotate( nSubLockId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + + EgtRotate( nSubLockId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif DGD.SIDE == 'top' then + + if not DGD.sFrame then + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + if sSideLk == 'L' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), EgtIf( sSideLk == 'L', DGD.A5, ( DGD.A6-180))) + end + else -- frame inferiore (ha il side opposto) + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + if DGD.OTHERD then + EgtMirror( nSubLockId, ORIG(), X_AX()) + end + EgtMirror( nSubLockId, Point3d( 0,DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + end + elseif DGD.SIDE == 'bottom' then + + if not DGD.sFrame then + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), EgtIf( sSideLk == 'L', DGD.A2, ( DGD.A1-180))) + end + else -- frame superiore ( ha il side opposto) + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + if sSideLk == 'L' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + if DGD.OTHERD then + EgtMirror( nSubLockId, ORIG(), X_AX()) + end + EgtMirror( nSubLockId, Point3d( 0,-DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + end + end + elseif ( sSideDoor == 'sidelh') then -- se posizionamento serratura tipo cerniera + + -- si presume che sia su bordo SQ ( non BV) + EgtRotate( nSubLockId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale senza angolo + + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubLockId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubLockId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubLockId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif DGD.SIDE == 'top' then + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + + if sSideLk == 'L' then -- se serratura a sinistra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubLockId, ORIG(), Y_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), EgtIf( sSideLk == 'L', DGD.A5, ( DGD.A6-180))) + end + elseif DGD.SIDE == 'bottom' then + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubLockId, ORIG(), Y_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubLockId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPos, Z_AX(), EgtIf( sSideLk == 'L', DGD.A2, ( DGD.A1-180))) + end + end + elseif ( sSideDoor == 'keyway') then + + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + EgtRotate( nSubLockId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosUpGeom = Point3d( ptPosBox:getX(), ptPosUpGeom:getY() , ptPosUpGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosUpGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif DGD.SIDE == 'top' then + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + + if sSideLk == 'L' then -- se serratura a sinistra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosUpGeom = Point3d( ptPosBox:getX(), ptPosUpGeom:getY() , ptPosUpGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosUpGeom, Z_AX(), EgtIf( sSideLk == 'L', DGD.A5, ( DGD.A6-180))) + end + elseif DGD.SIDE == 'bottom' then + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosUpGeom = Point3d( ptPosBox:getX(), ptPosUpGeom:getY() , ptPosUpGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosUpGeom, Z_AX(), EgtIf( sSideLk == 'L', DGD.A2, ( DGD.A1-180))) + end + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubLockId), nSubLockId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubLockId), EgtGetParent(nSubLockId)) + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubLockId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato narrow + EgtSetInfo( nSubLockId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + else -- atrimenti è sul lato wide + EgtSetInfo( nSubLockId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + end + end + elseif ( sSideDoor == 'secure') then + + EgtRotate( nSubLockId, ORIG(), X_AX(), 180 ) -- ruoto su faccia inferiore + + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + EgtRotate( nSubLockId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosDwGeom:getY() , ptPosDwGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosDwGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosDwGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif DGD.SIDE == 'top' then + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + + if sSideLk == 'L' then -- se serratura a sinistra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosDwGeom:getY() , ptPosDwGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosDwGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosDwGeom, Z_AX(), EgtIf( sSideLk == 'L', DGD.A5, ( DGD.A6-180))) + end + elseif DGD.SIDE == 'bottom' then + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubLockId, 'ReferHw', 'b') or false + if bReference then + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosDwGeom:getY() , ptPosDwGeom:getZ()) + end + + EgtMove( nSubLockId, ptPosDwGeom - ORIG()) + if bRemake then + EgtRotate( nSubLockId, ptPosDwGeom, Z_AX(), EgtIf( sSideLk == 'L', DGD.A2, ( DGD.A1-180))) + end + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubLockId), nSubLockId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubLockId), EgtGetParent(nSubLockId)) + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubLockId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato wide + EgtSetInfo( nSubLockId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + else -- atrimenti è sul lato narrow + EgtSetInfo( nSubLockId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + end + end + elseif ( sSideDoor == 'upper') then + + EgtRotate( nSubLockId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + + EgtRotate( nSubLockId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + EgtMove( nSubLockId, ptPos - ORIG()) + elseif DGD.SIDE == 'top' then + + if not DGD.sFrame then + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + if sSideLk == 'L' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubLockId, Point3d( 0,-DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + else -- frame inferiore (ha il side opposto) + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + if DGD.OTHERD then + EgtMirror( nSubLockId, ORIG(), X_AX()) + end + EgtMirror( nSubLockId, Point3d( 0,DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + end + elseif DGD.SIDE == 'bottom' then + + if not DGD.sFrame then + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubLockId, Point3d( 0,DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + else -- frame superiore ( ha il side opposto) + EgtRotate( nSubLockId, ORIG(), Z_AX(), 180 ) -- ruoto su faccia superiore (già pronta per serratura lato destro) + if sSideLk == 'L' then -- se serratura a destra + EgtMirror( nSubLockId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + if DGD.OTHERD then + EgtMirror( nSubLockId, ORIG(), X_AX()) + end + EgtMirror( nSubLockId, Point3d( 0,-DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + EgtMove( nSubLockId, ptPos - ORIG()) + end + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubLockId), nSubLockId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubLockId), EgtGetParent(nSubLockId)) + nUpperToDelete = nSubLockId + end + + return nUpperToDelete +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : FLUSHBOLTS *** +----------------------------------------------------------------- +local function MoveSubGeomFlushBolt( nSubFlushBId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosHead, ptPosHeadExt, nExtraAngle, dPosXHead, ptPosBox, ptPosUpGeom, ptPosDwGeom) + + local nUpperToDelete + + -- se geometria sul fianco + if sSideDoor == 'lock' or sSideDoor == 'side' then + + if sSideDoor == 'lock' then + nExtraAngle = 0 + else + -- se geometria sotto inverto il lato di rotazione + if DGD.SIDE == 'bottom' then + nExtraAngle = - nExtraAngle + end + end + + -- se sono in remake sposto le geometrie della testa prima nel loro zero originale + if bRemake then + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' and string.lower(DGD.TYPE) == 'extension' then + EgtMove( nSubFlushBId, Point3d(DGD.POSITION,0,dPosXHead) - ORIG()) + end + end + + EgtRotate( nSubFlushBId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if DGD.sFrame then + + if ( string.lower(DGD.SIDE) == 'bottom') then + EgtRotate( nSubFlushBId, ORIG(), X_AX(), 180 ) -- ribalto in Y + end + + if ( string.lower(DGD.SIDE) == 'top') then + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubFlushBId, ORIG(), Y_AX()) -- faccio il mirror su asse Y + else + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubFlushBId, Point3d( 0,DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + end + else + + if ( string.lower(DGD.SIDE) == 'bottom') then + EgtRotate( nSubFlushBId, ORIG(), X_AX(), 180 ) -- ribalto in Y + end + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + end + + if bRemake then + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' then + if string.lower(DGD.TYPE) == 'extension' then + EgtMove( nSubFlushBId, ptPosHeadExt - ORIG()) + EgtRotate( nSubFlushBId, ptPosHeadExt, Z_AX(), EgtIf( DGD.SIDE == 'top', DGD.A5, DGD.A2)) + else + EgtMove( nSubFlushBId, ptPosHead - ORIG()) + EgtRotate( nSubFlushBId, ptPosHead, Z_AX(), EgtIf( DGD.SIDE == 'top', DGD.A5, DGD.A2)) + end + else + EgtMove( nSubFlushBId, ptPos - ORIG()) + EgtRotate( nSubFlushBId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + else + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' and DGC.Bwd and DGC.Bwd >= 1 then + EgtMove( nSubFlushBId, Point3d( ptPosBox:getX(), ptPos:getY(), ptPos:getZ()) - ORIG()) + else + EgtMove( nSubFlushBId, ptPos - ORIG()) + end + end + elseif ( sSideDoor == 'sidelh') then -- se posizionamento serratura tipo cerniera + + -- cambio di segno ancora un'altra volta + if bPushDr then + nExtraAngle = - nExtraAngle + end + + -- se sono in remake sposto le geometrie della testa prima nel loro zero originale + if bRemake then + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' and string.lower(DGD.TYPE) == 'extension' then + EgtMove( nSubFlushBId, Point3d(DGD.POSITION,0,dPosXHead) - ORIG()) + end + end + + EgtRotate( nSubFlushBId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubFlushBId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + if bRemake then + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' then + if string.lower(DGD.TYPE) == 'extension' then + EgtMove( nSubFlushBId, ptPosHeadExt - ORIG()) + EgtRotate( nSubFlushBId, ptPosHeadExt, Z_AX(), EgtIf( DGD.SIDE == 'top', DGD.A5, DGD.A2)) + else + EgtMove( nSubFlushBId, ptPosHead - ORIG()) + EgtRotate( nSubFlushBId, ptPosHead, Z_AX(), EgtIf( DGD.SIDE == 'top', DGD.A5, DGD.A2)) + end + else + EgtMove( nSubFlushBId, ptPos - ORIG()) + EgtRotate( nSubFlushBId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + else + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' and DGC.Bwd and DGC.Bwd >= 1 then + EgtMove( nSubFlushBId, Point3d( ptPosBox:getX(), ptPos:getY(), ptPos:getZ()) - ORIG()) + else + EgtMove( nSubFlushBId, ptPos - ORIG()) + end + end + elseif ( sSideDoor == 'keyway') then + + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubFlushBId, 'ReferHw', 'b') or false + if bReference then + ptPosUpGeom = Point3d( ptPosBox:getX(), ptPosUpGeom:getY() , ptPosUpGeom:getZ()) + end + + EgtMove( nSubFlushBId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubFlushBId, ptPosUpGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubFlushBId), nSubFlushBId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubFlushBId), EgtGetParent(nSubFlushBId)) + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubFlushBId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato narrow + EgtSetInfo( nSubFlushBId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + else -- atrimenti è sul lato wide + EgtSetInfo( nSubFlushBId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + end + end + elseif ( sSideDoor == 'secure') then + + EgtRotate( nSubFlushBId, ORIG(), X_AX(), 180 ) -- ruoto su faccia inferiore + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubFlushBId, 'ReferHw', 'b') or false + if bReference then + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosDwGeom:getY() , ptPosDwGeom:getZ()) + end + + EgtMove( nSubFlushBId, ptPosDwGeom - ORIG()) + if bRemake then + EgtRotate( nSubFlushBId, ptPosDwGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubFlushBId), nSubFlushBId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubFlushBId), EgtGetParent(nSubFlushBId)) + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubFlushBId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato wide + EgtSetInfo( nSubFlushBId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + else -- atrimenti è sul lato narrow + EgtSetInfo( nSubFlushBId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + end + end + elseif ( sSideDoor == 'upper') then + + EgtRotate( nSubFlushBId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale + EgtRotate( nSubFlushBId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if ( string.lower(DGD.SIDE) == 'bottom') then + EgtRotate( nSubFlushBId, ORIG(), X_AX(), 180 ) -- ribalto in Y + end + + if ( string.lower(DGD.SIDE) == 'top') then + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubFlushBId, ORIG(), Y_AX()) -- faccio il mirror su asse Y + else + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubFlushBId, ORIG(), X_AX()) -- faccio il mirror su asse X + end + EgtMirror( nSubFlushBId, Point3d( 0,DGD.dH/2,0), Y_AX()) -- faccio il mirror su asse Y + end + + sSideDoorHead = EgtGetInfo( nSubFlushBId, 'HeadSide') + if sSideDoorHead == 'head' and DGC.Bwd and DGC.Bwd >= 1 then + EgtMove( nSubFlushBId, Point3d( ptPosBox:getX(), ptPos:getY(), ptPos:getZ()) - ORIG()) + else + EgtMove( nSubFlushBId, ptPos - ORIG()) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubFlushBId), nSubFlushBId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubFlushBId), EgtGetParent(nSubFlushBId)) + nUpperToDelete = nSubFlushBId + end + + return nUpperToDelete +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : EDGEPULLS *** +----------------------------------------------------------------- +local function MoveSubGeomEdgePull( nSubEdgePId, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoor == 'upper' then + if not DGD.Dws then + if bPushDr then + EgtSetInfo( nSubEdgePId, 'SideDoor', 'secure') + sSideDoor = 'secure' + else + EgtSetInfo( nSubEdgePId, 'SideDoor', 'keyway') + sSideDoor = 'keyway' + end + else + EgtSetInfo( nSubEdgePId, 'SideDoor', 'keyway') + sSideDoor = 'keyway' + end + nUpperToDelete = nSubEdgePId + end + + -- se geometria sul fianco + if sSideDoor == 'lock' or sSideDoor == 'side' then + + if sSideDoor == 'lock' then + nExtraAngle = 0 + end + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubEdgePId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubEdgePId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubEdgePId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif sSideDoor == 'sidelh' then -- se posizionamento serratura tipo cerniera + + -- cambio di segno ancora un'altra volta + if bPushDr then + nExtraAngle = - nExtraAngle + end + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + + EgtMove( nSubEdgePId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubEdgePId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif sSideDoor == 'keyway' then + + if DGD.Dws == nil and nUpperToDelete then -- se disposizione frame su porta + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + EgtMove( nSubEdgePId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubEdgePId, ptPosUpGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif not DGD.Dws then -- se disposizione frame su lato narrow + + if nUpperToDelete then -- se non è una geometria di ingombro/box + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + else + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + end + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubEdgePId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubEdgePId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubEdgePId, ptPosUpGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + else + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubEdgePId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubEdgePId, ptPos - ORIG()) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubEdgePId), nSubEdgePId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubEdgePId), EgtGetParent(nSubEdgePId)) + + if not nUpperToDelete then -- se non è una geometria di ingombro/box + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubEdgePId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato narrow + EgtSetInfo( nSubEdgePId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + else -- atrimenti è sul lato wide + EgtSetInfo( nSubEdgePId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + end + end + end + elseif sSideDoor == 'secure' then + + if DGD.Dws == nil and nUpperToDelete then -- se disposizione frame su porta + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + EgtMove( nSubEdgePId, ptPos - ORIG()) + else + + EgtRotate( nSubEdgePId, ORIG(), X_AX(), 180 ) -- ruoto su faccia inferiore + EgtRotate( nSubEdgePId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubEdgePId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + EgtMove( nSubEdgePId, ptPosDwGeom - ORIG()) + end + + if bRemake then + EgtRotate( nSubEdgePId, ptPosDwGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubEdgePId), nSubEdgePId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubEdgePId), EgtGetParent(nSubEdgePId)) + + if not nUpperToDelete then -- se non è una geometria di ingombro/box + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubEdgePId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato wide + EgtSetInfo( nSubEdgePId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + else -- atrimenti è sul lato narrow + EgtSetInfo( nSubEdgePId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + end + end + end + end + + return nUpperToDelete +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : STRIKES *** +----------------------------------------------------------------- +local function MoveSubGeomStrike( nSubStrikeId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nExtraAngle, ptPosBox) + + local sKeepBSNote + -- Controllo se la nota è corretta + local sLikeStrike = EgtGetInfo( nSubStrikeId, 'LikeStrike') + local nUpperToDelete + + -- se geometria sul fianco + if sSideDoor == 'lock' or sSideDoor == 'side' then + + -- cambio di segno ancora un'altra volta + if bPushDr then + nExtraAngle = - nExtraAngle + end + + if sSideDoor == 'lock' then + nExtraAngle = 0 + end + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra RHR(I) e LHR(I) + + if bPushDr and not sLikeStrike then -- se apertura a spingere RH(I) LH(I) + EgtMirror( nSubStrikeId, ORIG(), Z_AX()) + end + + if sSideLk == 'R' then -- se serratura a destra LH(I) LHR(I) + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubStrikeId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubStrikeId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif ( sSideDoor == 'sidelh') then -- se posizionamento serratura tipo cerniera + + if not sLikeStrike then + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra RHR(I) e LHR(I) + + if bPushDr then -- se apertura a spingere RH(I) LH(I) + EgtMirror( nSubStrikeId, ORIG(), Z_AX()) + end + + if sSideLk == 'R' then -- se serratura a destra LH(I) LHR(I) + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + else + + -- cambio di segno ancora un'altra volta + if bPushDr then + nExtraAngle = - nExtraAngle + end + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), ( 90 + nExtraAngle)) -- ruoto su faccia frontale con angolo + + if sSideLk == 'L' then -- se serratura a sinistra + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + else + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + end + + if bPushDr then -- se apertura a spingere + EgtRotate( nSubStrikeId, ORIG(), X_AX(), 180 ) -- ruoto attorno a X per capovolgere la cerniera + end + end + + EgtMove( nSubStrikeId, ptPos - ORIG()) + if bRemake then + EgtRotate( nSubStrikeId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + elseif ( sSideDoor == 'keyway') then + + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubStrikeId, 'ReferHw', 'b') or false + if bReference then + ptPosUpGeom = Point3d( ptPosBox:getX(), ptPosUpGeom:getY() , ptPosUpGeom:getZ()) + end + + EgtMove( nSubStrikeId, ptPosUpGeom - ORIG()) + if bRemake then + EgtRotate( nSubStrikeId, ptPosUpGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubStrikeId), nSubStrikeId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubStrikeId), EgtGetParent(nSubStrikeId)) + + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubStrikeId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato narrow + EgtSetInfo( nSubStrikeId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + else -- atrimenti è sul lato wide + EgtSetInfo( nSubStrikeId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + end + end + elseif ( sSideDoor == 'secure') then + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), 180 ) -- ruoto su faccia inferiore + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + local bReference = EgtGetInfo( nSubStrikeId, 'ReferHw', 'b') or false + if bReference then + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosDwGeom:getY() , ptPosDwGeom:getZ()) + end + + EgtMove( nSubStrikeId, ptPosDwGeom - ORIG()) + if bRemake then + EgtRotate( nSubStrikeId, ptPosDwGeom, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubStrikeId), nSubStrikeId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubStrikeId), EgtGetParent(nSubStrikeId)) + + -- se c'è la nota per mantenere la posizione con il probe + sKeepBSNote = EgtGetInfo( nSubStrikeId, 'KeepBackSet') + if sKeepBSNote == 'x' then -- se ha la nota la modifico in funzione a dove è stata piazzata + if bPushDr then -- se porta a spingere allora la geometrie è sul lato wide + EgtSetInfo( nSubStrikeId, 'KeepBackSet', 'w') -- setto 'w' perché la profondità non passante è applicata sul lato wide + else -- atrimenti è sul lato narrow + EgtSetInfo( nSubStrikeId, 'KeepBackSet', 'n') -- setto 'n' perché la profondità non passante è applicata sul lato narroe + end + end + elseif ( sSideDoor == 'upper') then + + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra RHR(I) e LHR(I) + + if bPushDr and not sLikeStrike then -- se apertura a spingere RH(I) LH(I) + EgtMirror( nSubStrikeId, ORIG(), Z_AX()) + end + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubStrikeId, ptPos - ORIG()) + + else + + EgtRotate( nSubStrikeId, ORIG(), X_AX(), 90) -- ruoto su faccia frontale + EgtRotate( nSubStrikeId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra RHR(I) e LHR(I) + + if bPushDr and not sLikeStrike then -- se apertura a spingere RH(I) LH(I) + EgtMirror( nSubStrikeId, ORIG(), Z_AX()) + end + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubStrikeId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + EgtMove( nSubStrikeId, ptPos - ORIG()) + end + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubStrikeId), nSubStrikeId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubStrikeId), EgtGetParent(nSubStrikeId)) +-- nUpperToDelete = nSubStrikeId + end + + return nUpperToDelete +end + +----------------------------------------------------------------------------------------------- +-- *** Geometric processing : common functions for locks, flushbolts, edgepulls, strikes *** +----------------------------------------------------------------------------------------------- +local function MoveGeometryLck( sTypeGeom, nGeomId, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, dPosXHead, ptPosBox, ptPosUpGeomFB, ptPosDwGeomFB) + + if not nGeomId then return end + + -- se profilo lato serratura è bevel setto il supplemento di rotazione + local nExtraAngle + local nIdGeomType + local sSideDoorToMove + local sMessageErr = '' + + -- stabilisco l'angolo extra di inclinazione in base al profilo e alla direzione di apertura porta ( Push o Pull) + if DGD.tProfs.lockedge.trimming == 'BD' or DGD.tProfs.lockedge.trimming == 'BU' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then + + nExtraAngle = 3 + + if bPushDr then + nExtraAngle = - nExtraAngle + end + + -- se è un lato senza maniglia e abilitazione inversione profilo, re-inverto l'angolo + if ( DGD.sSwing == 'LHI' or DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI' or DGD.sSwing == 'LHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + nExtraAngle = - nExtraAngle + end + else + nExtraAngle = 0 + end + + -- devo ottenere tutte le geometrie della serratura + nIdGeomType = EgtGetFirstInGroup( nGeomId) -- ottengo la prima geometria + local nErr = 0 + local nUpperToDelete + + while nIdGeomType do + + sSideDoorToMove = EgtGetInfo( nIdGeomType, 'SideDoor') + + if sSideDoorToMove then + + -- Controllo se la nota è corretta + local sSideDoor = string.lower(sSideDoorToMove) + + -- lock: senza rotazione angolo profilo; side: con rotazione angolo profilo; keyway e Secure: no rotazione angolo profilo; + -- SideLH: senza rotazione angolo profilo e disposizione come cerniera ( suffisso LH: like hinge), cioè senza effettuare mirror + -- attenzione! la geometria con nota SideLH DEVE ESSERE SIMMETRICA sulla X e Y locale + if sTypeGeom == 'lock' then + if sSideDoor == 'lock' or sSideDoor == 'side' or sSideDoor == 'sidelh' or + sSideDoor == 'keyway' or sSideDoor == 'secure' or sSideDoor == 'upper' then + if DGD.sFrame and DGD.nTypePz == 5 then + DGD.SIDE = 'bottom' + elseif DGD.sFrame and DGD.nTypePz == 6 then + DGD.SIDE = 'top' + end + nUpperToDelete = MoveSubGeomLock( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nExtraAngle, ptPosBox) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[413],nIdGeomType,'Lock',nGeomId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1001 + end + elseif sTypeGeom == 'flushbolt' then + if sSideDoor == 'lock' or sSideDoor == 'side' or sSideDoor == 'sidelh' or + sSideDoor == 'keyway' or sSideDoor == 'secure' or sSideDoor == 'upper' then + nUpperToDelete = MoveSubGeomFlushBolt( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nExtraAngle, dPosXHead, ptPosBox, ptPosUpGeomFB, ptPosDwGeomFB) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[413],nIdGeomType,'Flush Bolt',nGeomId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1003 + end + elseif sTypeGeom == 'edgepull' then + if sSideDoor == 'lock' or sSideDoor == 'side' or sSideDoor == 'sidelh' or + sSideDoor == 'keyway' or sSideDoor == 'secure' or sSideDoor == 'upper' then + nUpperToDelete = MoveSubGeomEdgePull( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, nExtraAngle, ptPosUpGeom, ptPosDwGeom) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[413],nIdGeomType,'Edge Pull',nGeomId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1005 + end + elseif sTypeGeom == 'strike' then + if sSideDoor == 'lock' or sSideDoor == 'side' or sSideDoor == 'sidelh' or + sSideDoor == 'keyway' or sSideDoor == 'secure' or sSideDoor == 'upper' then + nUpperToDelete = MoveSubGeomStrike( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nExtraAngle, ptPosBox) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[413],nIdGeomType,'Strike',nGeomId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1017 + end + end + else + -- messaggio di errore in base al tipo di pezzo + if sTypeGeom == 'lock' then + sMessageErr = string.format( EgtDoorsMsg[414],nIdGeomType,'Lock',nGeomId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1002 + elseif sTypeGeom == 'flushbolt' then + sMessageErr = string.format( EgtDoorsMsg[414],nIdGeomType,'Flush Bolt',nGeomId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1004 + elseif sTypeGeom == 'edgepull' then + sMessageErr = string.format( EgtDoorsMsg[414],nIdGeomType,'Edge Pull',nEdgePId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1006 + elseif sTypeGeom == 'strike' then + sMessageErr = string.format( EgtDoorsMsg[414],nIdGeomType,'Strike',nEdgePId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1018 + end + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + nUpperToDelete = nil + end + end + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +------------------------------------------------------------------------------- +-- *** Geometric main processing : LOCKS, FLUSHBOLTS, EDGEPULLS, STRIKES *** +------------------------------------------------------------------------------- +local function MoveLock( tLock, sSideLk, bPushDr) + + local ptPos + local ptPosBox + local ptRef + local ptFromExt + local ptPosUpGeom + local ptPosDwGeom + local dPosX + local dPosXUpDw + local dPosZ + local dDeltaX + local dZedPos = 0 + local nAngleBase + local nRadBase + local nRadBaseBox + local nAngleBaseUpDw + local nRadBaseUpDw + local nSideApplied = 3 + + if tLock.offset and tLock.offset > 0 then + dDeltaX = tLock.offset * TAN3 + dPosZ = tLock.offset + else + dDeltaX = (DGD.dT/2) * TAN3 + dPosZ = (DGD.dT/2) + end + + if ( DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BD' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB') and + ( not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom') then -- se profilo bevel su lato lock + dPosX = dDeltaX + dPosXUpDw = dDeltaX + else + dPosX = 0 + dPosXUpDw = 0 + end + + -- by DGC.Bwd setting set to 0 the dPosXUpDw and dPosX parameters + if DGC.Bwd and DGC.Bwd >= 1 then + dPosXUpDw = 0 + if DGC.Bwd == 2 then + dPosX = 0 + end + end + + if DGD.sFrame then + if ( DGD.nTypePz == 3 or DGD.nTypePz == 4) then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + if DGD.nTypePz == 5 then + tLock.side = 'bottom' + elseif DGD.nTypePz == 6 then + tLock.side = 'top' + end + end + + if bRemake then + nAngleBase = atan(dPosX/tLock.position) + nRadBase = sqrt((dPosX*dPosX)+(tLock.position*tLock.position)) + nRadBaseBox = tLock.position + nAngleBaseUpDw = atan((dPosXUpDw+tLock.back_set)/tLock.position) + nRadBaseUpDw = sqrt(((dPosXUpDw+tLock.back_set)*(dPosXUpDw+tLock.back_set))+(tLock.position*tLock.position)) + end + + if bPushDr then + dZedPos = dPosZ + else + dZedPos = (DGD.dT - dPosZ) + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + if not DGD.SIDE or DGD.SIDE == 'lock_top' then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A4)), ptRef:getY()+(nRadBaseBox*sin(DGD.A4)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A4+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A4+nAngleBaseUpDw)) , DGD.dT) + elseif DGD.SIDE == 'lock_bottom' then + ptRef = DGD.PminBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A3-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A3-nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A3)), ptRef:getY()+(nRadBaseBox*sin(DGD.A3)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A3-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A3-nAngleBaseUpDw)) , DGD.dT) + elseif DGD.SIDE == 'top' then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A5+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A5+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A5)), ptRef:getY()+(nRadBaseBox*sin(DGD.A5)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A5-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A5-nAngleBaseUpDw)) , DGD.dT) + nSideApplied = 2 + elseif DGD.SIDE == 'bottom' then + ptRef = DGD.PminBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A2+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A2+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A2)), ptRef:getY()+(nRadBaseBox*sin(DGD.A2)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A2+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A2+nAngleBaseUpDw)) , DGD.dT) + nSideApplied = 4 + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + if not DGD.SIDE or DGD.SIDE == 'lock_top' then + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tLock.position) , dZedPos) + ptPosBox = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tLock.position) , dZedPos) + ptPosUpGeom = Point3d( ( dPosXUpDw + tLock.back_set + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tLock.position) , DGD.dT) + ptFromExt = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tLock.position) , DGD.dT) + elseif DGD.SIDE == 'lock_bottom' then + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), tLock.position , dZedPos) + ptPosBox = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), tLock.position , dZedPos) + ptPosUpGeom = Point3d( ( dPosXUpDw + tLock.back_set + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), tLock.position , DGD.dT) + ptFromExt = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), tLock.position , DGD.dT) + elseif DGD.SIDE == 'top' then + ptPos = Point3d( tLock.position, DGD.dH, dZedPos) + ptPosBox = Point3d( tLock.position, DGD.dH, dZedPos) + ptPosUpGeom = Point3d( tLock.position, ( DGD.dH - tLock.back_set) , DGD.dT) + ptFromExt = Point3d( tLock.position, DGD.dH , DGD.dT) + nSideApplied = 2 + elseif DGD.SIDE == 'bottom' then + ptPos = Point3d( tLock.position, 0, dZedPos) + ptPosBox = Point3d( tLock.position, 0, dZedPos) + ptPosUpGeom = Point3d( tLock.position, tLock.back_set , DGD.dT) + ptFromExt = Point3d( tLock.position, 0 , DGD.dT) + nSideApplied = 4 + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + else -- serratura a destra + if bRemake then + if not DGD.SIDE or DGD.SIDE == 'lock_top' then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A7)), ptRef:getY()+(nRadBaseBox*sin(DGD.A7)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A7-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A7-nAngleBaseUpDw)) , DGD.dT) + elseif DGD.SIDE == 'lock_bottom' then + ptRef = DGD.PmaxBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A8+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A8+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A8)), ptRef:getY()+(nRadBaseBox*sin(DGD.A8)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A8+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A8+nAngleBaseUpDw)) , DGD.dT) + elseif DGD.SIDE == 'top' then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A6-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A6-nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A6)), ptRef:getY()+(nRadBaseBox*sin(DGD.A6)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A6+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A6+nAngleBaseUpDw)) , DGD.dT) + nSideApplied = 2 + elseif DGD.SIDE == 'bottom' then + ptRef = DGD.PmaxBot + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A1+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A1+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A1)), ptRef:getY()+(nRadBaseBox*sin(DGD.A1)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A1-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A1-nAngleBaseUpDw)) , DGD.dT) + nSideApplied = 4 + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + if not DGD.SIDE or DGD.SIDE == 'lock_top' then + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tLock.position) , dZedPos) + ptPosBox = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tLock.position) , dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - dPosXUpDw - tLock.back_set - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tLock.position) , DGD.dT) + ptFromExt = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tLock.position) , DGD.dT) + elseif DGD.SIDE == 'lock_bottom' then + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), tLock.position , dZedPos) + ptPosBox = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), tLock.position , dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - dPosXUpDw - tLock.back_set - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), tLock.position , DGD.dT) + ptFromExt = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), tLock.position , DGD.dT) + elseif DGD.SIDE == 'top' then + ptPos = Point3d( ( DGD.dW - tLock.position), DGD.dH, dZedPos) + ptPosBox = Point3d( ( DGD.dW - tLock.position), DGD.dH, dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - tLock.position), ( DGD.dH - tLock.back_set) , DGD.dT) + ptFromExt = Point3d( ( DGD.dW - tLock.position), DGD.dH , DGD.dT) + nSideApplied = 2 + elseif DGD.SIDE == 'bottom' then + ptPos = Point3d( ( DGD.dW - tLock.position), 0, dZedPos) + ptPosBox = Point3d( ( DGD.dW - tLock.position), 0, dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - tLock.position), tLock.back_set , DGD.dT) + ptFromExt = Point3d( ( DGD.dW - tLock.position), 0 , DGD.dT) + nSideApplied = 4 + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + end + + MoveGeometryLck( 'lock', tLock.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nil, ptPosBox) + InsertProbeGeom( tLock.geom, ptPosUpGeom, ptFromExt, 3, nSideApplied) +end + +----------------------------------------------------------------- +local function MoveFlushBolt( tFlushB, sSideLk, bPushDr) + + local ptPos + local ptPosBox + local ptRef + local ptPosHead + local ptPosHeadExt + local ptPosUpGeom + local ptPosDwGeom + local ptDummy = Point3d{0,0,0} + local dPosY + local dPosYBox + local dPosYUpDw + local dPosYHead + local dPosYHeadExt + local dPosYProbe + local dPosX + local dPosXUpDw + local dPosXHead + local dPosXProbe + local dPosZ + local dXFromExt + local dYFromExt + local dDeltaX + local dZedPos = 0 + local nAngleBase + local nRadBase + local nRadBaseBox + local nAngleBaseUpDw + local nRadBaseUpDw + + if DGD.OFFSET and DGD.OFFSET > 0 then + dDeltaX = DGD.OFFSET * TAN3 + dPosZ = DGD.OFFSET + else + dDeltaX = (DGD.dT/2) * TAN3 + dPosZ = (DGD.dT/2) + end + + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BD' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- se profilo bevel + dPosX = dDeltaX + dPosXUpDw = dDeltaX + else + dPosX = 0 + dPosXUpDw = 0 + end + + -- by DGC.Bwd setting set to 0 the dPosXUpDw and dPosX parameters + if DGC.Bwd and DGC.Bwd >= 1 then + dPosXUpDw = 0 + if DGC.Bwd == 2 then + dPosX = 0 + end + end + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + if not tFlushB.position then + tFlushB.position = 100 + end + if not tFlushB.back_set then + tFlushB.back_set = 0 + end + + if bRemake then + nAngleBase = atan(dPosX,tFlushB.position) + nRadBase = sqrt((dPosX*dPosX)+(tFlushB.position*tFlushB.position)) + nRadBaseBox = tFlushB.position + if tFlushB.back_set then + nAngleBaseUpDw = atan((dPosXUpDw+tFlushB.back_set)/tFlushB.position) + nRadBaseUpDw = sqrt(((dPosXUpDw+tFlushB.back_set)*(dPosXUpDw+tFlushB.back_set))+(tFlushB.position*tFlushB.position)) + end + end + + -- se è extension + if string.lower(tFlushB.type) == 'extension' then + + if DGD.sFrame and ( DGD.nTypePz == 5 or DGD.nTypePz == 6) then + dPosY = 0 + DGD.dZedExtFrame + dPosYUpDw = dPosY + bPushDr = not bPushDr + else + if bRemake then + -- ricavo nota spostamento cava di testa + dPosXHead = EgtGetInfo( tFlushB.geom, 'DB_X', 'd') or 0 + + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tFlushB.side) == 'top' then + ptRef = EgtIf( sSideLk == 'L', DGD.PminTop, DGD.PmaxTop) + if sSideLk == 'L' then -- se serratura a sinistra + dPosY = ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) + dPosYBox = ptRef:getY()+(nRadBaseBox*sin(DGD.A4)) + dPosYUpDw = ptRef:getY()+(nRadBaseUpDw*sin(DGD.A4+nAngleBaseUpDw)) + dPosYHeadExt = ptRef:getY()+(dPosXHead*sin(DGD.A5)) + else + dPosY = ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) + dPosYBox = ptRef:getY()+(nRadBaseBox*sin(DGD.A7)) + dPosYUpDw = ptRef:getY()+(nRadBaseUpDw*sin(DGD.A7-nAngleBaseUpDw)) + dPosYHeadExt = ptRef:getY()+(dPosXHead*sin(DGD.A6)) + end + else + ptRef = EgtIf( sSideLk == 'L', DGD.PminBot, DGD.PmaxBot) + if sSideLk == 'L' then -- se serratura a sinistra + dPosY = ptRef:getY()+(nRadBase*sin(DGD.A3-nAngleBase)) + dPosYBox = ptRef:getY()+(nRadBaseBox*sin(DGD.A3)) + dPosYUpDw = ptRef:getY()+(nRadBaseUpDw*sin(DGD.A3-nAngleBaseUpDw)) + dPosYHeadExt = ptRef:getY()+(dPosXHead*sin(DGD.A2)) + else + dPosY = ptRef:getY()+(nRadBase*sin(DGD.A8+nAngleBase)) + dPosYBox = ptRef:getY()+(nRadBaseBox*sin(DGD.A8)) + dPosYUpDw = ptRef:getY()+(nRadBaseUpDw*sin(DGD.A8+nAngleBaseUpDw)) + dPosYHeadExt = ptRef:getY()+(dPosXHead*sin(DGD.A1)) + end + end + dPosYHead = ptRef:getY() + else + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tFlushB.side) == 'top' then + dPosY = DGD.dH - tFlushB.position + dPosYUpDw = DGD.dH - tFlushB.position + else + dPosY = tFlushB.position + dPosYUpDw = tFlushB.position + end + end + end + dPosYProbe = dPosY + dYFromExt = dPosY + else -- altrimenti tipo corner + + if DGD.sFrame and ( DGD.nTypePz == 5 or DGD.nTypePz == 6) then + dPosY = 0 + DGD.dZedExtFrame + dPosYUpDw = dPosY + bPushDr = not bPushDr + else + if bRemake then + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tFlushB.side) == 'top' then + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PminTop + dPosY = ptRef:getY()+(dPosX*cos(DGD.A4)) + else + ptRef = DGD.PmaxTop + dPosY = ptRef:getY()+(dPosX*cos(DGD.A8)) + end + dPosYProbe = dPosY - DGD.DPR + dYFromExt = dPosY - DGD.DPR + else + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PminBot + dPosY = ptRef:getY()+(dPosX*cos(DGD.A4)) + else + ptRef = DGD.PmaxBot + dPosY = ptRef:getY()+(dPosX*cos(DGD.A8)) + end + dPosYProbe = dPosY + DGD.DPR + dYFromExt = dPosY + DGD.DPR + end + dPosYHead = ptRef:getY() + else + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tFlushB.side) == 'top' then + dPosY = DGD.dH + dPosYProbe = dPosY - DGD.DPR + dYFromExt = dPosY - DGD.DPR + else + dPosY = 0 + dPosYProbe = DGD.DPR + dYFromExt = dPosY + DGD.DPR + end + end + end + dPosYUpDw = dPosY + end + + if bPushDr then + dZedPos = dPosZ + else + dZedPos = (DGD.dT - dPosZ) + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + if string.lower(tFlushB.type) == 'extension' then + if string.lower(tFlushB.side) == 'top' then + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), dPosY , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A4)), dPosYBox , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A4+nAngleBaseUpDw)),dPosYUpDw , DGD.dT) + ptPosHeadExt = Point3d( ptRef:getX()+(dPosXHead*cos(DGD.A5)), dPosYHeadExt , dZedPos) + else + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A3-nAngleBase)), dPosY , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A3)), dPosYBox , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A3-nAngleBaseUpDw)), dPosYUpDw , DGD.dT) + ptPosHeadExt = Point3d( ptRef:getX()+(dPosXHead*cos(DGD.A2)), dPosYHeadExt , dZedPos) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPos = Point3d( ptRef:getX()+(dPosX*sin(DGD.A3)), dPosY , dZedPos) + end + ptPosHead = Point3d( ptRef:getX(), dPosYHead , dZedPos) + dPosXProbe = ptPos:getX() + DGD.DPR + dXFromExt = ptPos:getX() + else + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0), dPosY , dZedPos) + ptPosBox = Point3d( EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0), dPosY , dZedPos) + dPosXProbe = dPosX + DGD.DPR + dXFromExt = 0 + if tFlushB.back_set then + ptPosUpGeom = Point3d( ( dPosXUpDw + tFlushB.back_set + EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0)), dPosYUpDw , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + end + else -- serratura a destra + if bRemake then + if string.lower(tFlushB.type) == 'extension' then + if string.lower(tFlushB.side) == 'top' then + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), dPosY , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A7)), dPosYBox , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A7-nAngleBaseUpDw)), dPosYUpDw , DGD.dT) + ptPosHeadExt = Point3d( ptRef:getX()+(dPosXHead*cos(DGD.A6)), dPosYHeadExt , dZedPos) + else + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A8+nAngleBase)), dPosY , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A8)), dPosYBox , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A8+nAngleBaseUpDw)), dPosYUpDw , DGD.dT) + ptPosHeadExt = Point3d( ptRef:getX()+(dPosXHead*cos(DGD.A1)), dPosYHeadExt , dZedPos) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPos = Point3d( ptRef:getX()+(dPosX*sin(DGD.A7)), dPosY , dZedPos) + end + ptPosHead = Point3d( ptRef:getX(), dPosYHead , dZedPos) + dPosXProbe = ptPos:getX() - DGD.DPR + dXFromExt = ptPos:getX() + else + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0)), dPosY , dZedPos) + ptPosBox = Point3d( DGD.dW - EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0), dPosY , dZedPos) + dPosXProbe = DGD.dW - dPosX - DGD.DPR + dXFromExt = DGD.dW + if tFlushB.back_set then + ptPosUpGeom = Point3d( ( DGD.dW - dPosXUpDw - tFlushB.back_set - EgtIf( DGD.sFrame, DGD.dSideExtFrame, 0)), dPosYUpDw , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + end + end + + MoveGeometryLck( 'flushbolt', tFlushB.geom, sSideLk, bPushDr, ptPos, ptPosHead, ptPosHeadExt, dPosXHead, ptPosBox, ptPosUpGeom, ptPosDwGeom) + InsertProbeGeom( tFlushB.geom, Point3d(dPosXProbe,dPosYProbe,0), Point3d(dXFromExt,dYFromExt,0), 11, 3) +end + +----------------------------------------------------------------- +local function MoveEdgePull( tEdgeP, sSideLk, bPushDr) + + local dPosX + local dPosZ + local ptPos + local ptRef + local ptPosUpGeom + local ptPosDwGeom + local dPosXProbe + local dXFromExt + local dYFromExt + local dDeltaX + local dZedPos = 0 + local nAngleBase + local nRadBase + local ptDummy = Point3d{0,0,0} + + if DGD.OFFSET and DGD.OFFSET > 0 then + dDeltaX = DGD.OFFSET * TAN3 + dPosZ = DGD.OFFSET + else + dDeltaX = (DGD.dT/2) * TAN3 + dPosZ = (DGD.dT/2) + end + + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BD' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- se profilo bevel + dPosX = dDeltaX + else + dPosX = 0 + end + + -- by DGC.Bwd setting set to 0 the dPosX parameter + if DGC.Bwd and DGC.Bwd == 2 then + dPosX = 0 + end + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + if bRemake then + nAngleBase = atan(dPosX/tEdgeP.position) + nRadBase = sqrt((dPosX*dPosX)+(tEdgeP.position*tEdgeP.position)) + end + + if bPushDr then + dZedPos = dPosZ + else + dZedPos = (DGD.dT - dPosZ) + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(tEdgeP.position*cos(DGD.A4)), ptRef:getY()+(tEdgeP.position*sin(DGD.A4)) , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tEdgeP.position) , dZedPos) + ptPosUpGeom = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tEdgeP.position) , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + dPosXProbe = dPosX + DGD.DPR + dXFromExt = 0 + dYFromExt = ptPos:getY() + else -- serratura a destra + if bRemake then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(tEdgeP.position*cos(DGD.A7)), ptRef:getY()+(tEdgeP.position*sin(DGD.A7)) , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tEdgeP.position) , dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tEdgeP.position) , DGD.dT) + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + end + dPosXProbe = DGD.dW - dPosX - DGD.DPR + dXFromExt = DGD.dW + dYFromExt = ptPos:getY() + end + + MoveGeometryLck( 'edgepull', tEdgeP.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom) + InsertProbeGeom( tEdgeP.geom, Point3d(dPosXProbe,ptPos:getY(),0), Point3d(dXFromExt,dYFromExt,0), 10, 3) +end + +----------------------------------------------------------------- +local function MoveStrike( tStrike, sSideLk, bPushDr) + + local dPosX + local dPosXUpDw + local dPosZ + local ptPos + local ptPosBox + local ptRef + local ptFromExt + local ptPosUpGeom + local ptPosDwGeom + local dDeltaX + local dZedPos = 0 + local nAngleBase + local nRadBase + local nAngleBaseUpDw + local nRadBaseUpDw + + if DGD.OFFSET and DGD.OFFSET > 0 then + dDeltaX = DGD.OFFSET * TAN3 + dPosZ = DGD.OFFSET + else + dDeltaX = (DGD.dT/2) * TAN3 + dPosZ = (DGD.dT/2) + end + + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BD' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- se profilo bevel + dPosX = dDeltaX + dPosXUpDw = dDeltaX + else + dPosX = 0 + dPosXUpDw = 0 + end + + -- by DGC.Bwd setting set to 0 the dPosXUpDw and dPosX parameters + if DGC.Bwd and DGC.Bwd >= 1 then + dPosXUpDw = 0 + if DGC.Bwd == 2 then + dPosX = 0 + end + end + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + if bRemake then + nAngleBase = atan(dPosX/tStrike.position) + nRadBase = sqrt((dPosX*dPosX)+(tStrike.position*tStrike.position)) + nRadBaseBox = tStrike.position + nAngleBaseUpDw = atan((dPosXUpDw+tStrike.back_set)/tStrike.position) + nRadBaseUpDw = sqrt(((dPosXUpDw+tStrike.back_set)*(dPosXUpDw+tStrike.back_set))+(tStrike.position*tStrike.position)) + end + + if bPushDr then + dZedPos = dPosZ + else + dZedPos = (DGD.dT - dPosZ) + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A4)), ptRef:getY()+(nRadBaseBox*sin(DGD.A4)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A4+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A4+nAngleBaseUpDw)) , DGD.dT) + ptPosDwGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A4+nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A4+nAngleBaseUpDw)) , 0) + ptFromExt = ptPosUpGeom + else + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tStrike.position) , dZedPos) + ptPosBox = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tStrike.position) , dZedPos) + ptPosUpGeom = Point3d( ( dPosXUpDw + tStrike.back_set + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , DGD.dT) + ptPosDwGeom = Point3d( ( dPosXUpDw + tStrike.back_set + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , 0) + ptFromExt = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tStrike.position) , DGD.dT) + end + else -- serratura a destra + if bRemake then + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dZedPos) + ptPosBox = Point3d( ptRef:getX()+(nRadBaseBox*cos(DGD.A7)), ptRef:getY()+(nRadBaseBox*sin(DGD.A7)) , dZedPos) + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A7-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A7-nAngleBaseUpDw)) , DGD.dT) + ptPosDwGeom = Point3d( ptRef:getX()+(nRadBaseUpDw*cos(DGD.A7-nAngleBaseUpDw)), ptRef:getY()+(nRadBaseUpDw*sin(DGD.A7-nAngleBaseUpDw)) , 0) + ptFromExt = ptPosUpGeom + else + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , dZedPos) + ptPosBox = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , dZedPos) + ptPosUpGeom = Point3d( ( DGD.dW - dPosXUpDw - tStrike.back_set - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , DGD.dT) + ptPosDwGeom = Point3d( ( DGD.dW - dPosXUpDw - tStrike.back_set - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , 0) + ptFromExt = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tStrike.position) , DGD.dT) + end + end + + MoveGeometryLck( 'strike', tStrike.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom, ptPosDwGeom, nil, ptPosBox) + InsertProbeGeom( tStrike.geom, ptPosUpGeom, ptFromExt, 14, 3) +end + +----------------------------------------------------------------- +-- *** Geometric processing : VIEWERS *** +----------------------------------------------------------------- +local function MoveSubGeomViewer( nSubViewerId, sSideDoor, sSideLk, ptPosUpGeom, ptPosDwGeom) + + if ( sSideDoor == 'secure') then + EgtRotate( nSubViewerId, ORIG(), X_AX(), 180 ) -- ruoto su faccia inferiore + end + + EgtRotate( nSubViewerId, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra + + if sSideLk == 'R' then -- se serratura a destra + EgtMirror( nSubViewerId, ORIG(), X_AX()) -- faccio il mirror su asse Y + end + + if ( sSideDoor == 'secure') then + EgtMove( nSubViewerId, ptPosDwGeom - ORIG()) + else + EgtMove( nSubViewerId, ptPosUpGeom - ORIG()) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nSubViewerId), nSubViewerId, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nSubViewerId), EgtGetParent(nSubViewerId)) +end + +----------------------------------------------------------------- +local function MoveGeomViewer( nViewerId, sSideLk, ptPosUpGeom, ptPosDwGeom) + + if not nViewerId then return end + + local nIdGeomViewer + local sSideDoorToMove + local sMessageErr = '' + + -- devo ottenere tutte le geometrie dello spioncino + nIdGeomViewer = EgtGetFirstInGroup( nViewerId) -- ottengo la prima geometria + local nErr = 0 + + while nIdGeomViewer do + + sSideDoorToMove = EgtGetInfo( nIdGeomViewer, 'SideDoor') + + if sSideDoorToMove then + + -- Controllo se la nota è corretta + local sSideDoor = string.lower(sSideDoorToMove) + + -- keyway e secure: no rotazione angolo profilo; + if sSideDoor == 'keyway' or sSideDoor == 'secure' then + MoveSubGeomViewer( nIdGeomViewer, sSideDoor, sSideLk, ptPosUpGeom, ptPosDwGeom) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[418],nIdGeomViewer,nViewerId, sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1007 + end + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[419],nIdGeomViewer,nViewerId, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1008 + end + + nIdGeomViewer = EgtGetNext(nIdGeomViewer) + end + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +----------------------------------------------------------------- +local function MoveViewer( tViewer, sSideLk, bPushDr) + + local ptPosUpGeom + local ptPosDwGeom + local ptRef + local dZedPos = 0 + local nAngleBase + local nRadBase + local dPosY + local dPosX + + if bRemake then + dPosX = EgtIf( sSideLk == 'L', ( DGD.dW / 2) + tViewer.delta_center, ( DGD.dW / 2) - tViewer.delta_center) + nAngleBase = atan(dPosX,tViewer.bottom_rail) + nRadBase = sqrt((dPosX*dPosX)+(tViewer.bottom_rail*tViewer.bottom_rail)) + end + + local dPosY = EgtIf( tViewer.side and tViewer.side == 'top', ( DGD.dH - tViewer.bottom_rail), tViewer.bottom_rail) + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + if tViewer.side and tViewer.side == 'top' then + ptRef = DGD.PminTop + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , DGD.dT) + else + ptRef = DGD.PminBot + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A3-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A3-nAngleBase)) , DGD.dT) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPosUpGeom = Point3d( ( ( DGD.dW / 2) + tViewer.delta_center), dPosY , DGD.dT) + ptPosDwGeom = Point3d( ( ( DGD.dW / 2) + tViewer.delta_center), dPosY , 0) + end + else -- serratura a destra + if bRemake then + if tViewer.side and tViewer.side == 'top' then + ptRef = DGD.PmaxTop + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , DGD.dT) + else + ptRef = DGD.PmaxBot + ptPosUpGeom = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A8+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A8+nAngleBase)) , DGD.dT) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + else + ptPosUpGeom = Point3d( ( ( DGD.dW / 2) - tViewer.delta_center), dPosY , DGD.dT) + ptPosDwGeom = Point3d( ( ( DGD.dW / 2) - tViewer.delta_center), dPosY , 0) + end + end + + MoveGeomViewer( tViewer.geom, sSideLk, ptPosUpGeom, ptPosDwGeom) + if bRemake then + local dAngleLoc + dAngleLoc = (DGD.A3 + DGD.A8) / 2 + EgtRotate( tViewer.geom, ptPosUpGeom, Z_AX(), ( dAngleLoc-90)) + end + + InsertProbeGeom( tViewer.geom, ptPosDwGeom) +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : ROLLERLATCHS *** +----------------------------------------------------------------- +local function ApplyDispRollerLatch( nIdGeomType, nExtraAngle, sSideLk, bPushDr, sSideDoor, ptPosUpGeom, ptPos) + + EgtRotate( nIdGeomType, ORIG(), X_AX(), -( 90 + nExtraAngle)) -- ruoto su faccia dietro + + if DGD.SIDE == 'lock' then + if sSideLk == 'L' then -- se serratura a destra + EgtRotate( nIdGeomType, ORIG(), Z_AX(), 90 ) -- ruoto su faccia sinistra + else + EgtRotate( nIdGeomType, ORIG(), Z_AX(), -90 ) -- ruoto su faccia destra + end + end + + if bPushDr then -- se apertura a spingere + EgtMirror( nIdGeomType, ORIG(), Z_AX()) + end + + if DGD.sFrame then + if string.lower(DGD.SIDE) == 'bottom' then -- frame superiore ( ha il side opposto) + if DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + else + EgtMirror( nIdGeomType, ORIG(), X_AX()) + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + elseif string.lower(DGD.SIDE) == 'top' then -- frame inferiore (ha il side opposto) + if not DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), X_AX()) + end + end + else + if string.lower(DGD.SIDE) == 'bottom' then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + end + + -- se geometria sul fianco + if sSideDoor == 'edge' then -- se spostamento sul bordo + EgtMove( nIdGeomType, ptPosUpGeom - ORIG()) + elseif ( sSideDoor == 'center') then -- se posizionamento in centro spessore + EgtMove( nIdGeomType, ptPos - ORIG()) + end +end + +local function MoveSubGeomRollerLatch( nSubRollerLatchId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, nExtraAngle, ptPosDwGeom) + + -- ciclo sulle geometrie singole invece di modificare il layer + local nIdGeomType + + nIdGeomType = EgtGetFirstInGroup( nSubRollerLatchId) -- ottengo la prima geometria + + while nIdGeomType do + + local sSideDoorBox = EgtGetInfo( nIdGeomType, 'SideDoor') + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoorBox and sSideDoorBox == 'upper' then + if not DGD.Dws then + if bPushDr then + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'secure') + sSideDoorBox = 'secure' + end + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + nUpperToDelete = nIdGeomType + end + + if sSideDoorBox == 'keyway' or sSideDoorBox == 'secure' then + + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + + EgtRotate( nIdGeomType, ORIG(), X_AX(), 180) + + if DGD.SIDE == 'lock' then + if sSideLk == 'L' then -- se serratura a destra + EgtRotate( nIdGeomType, ORIG(), Z_AX(), 90 ) -- ruoto su faccia sinistra + else + EgtRotate( nIdGeomType, ORIG(), Z_AX(), -90 ) -- ruoto su faccia destra + end + end + + if bPushDr then -- se apertura a spingere + EgtMirror( nIdGeomType, ORIG(), Z_AX()) + end + + if DGD.sFrame then + if string.lower(DGD.SIDE) == 'bottom' then -- frame superiore ( ha il side opposto) + if DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + else + EgtMirror( nIdGeomType, ORIG(), X_AX()) + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + elseif string.lower(DGD.SIDE) == 'top' then -- frame inferiore (ha il side opposto) + if not DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), X_AX()) + end + end + else + if string.lower(DGD.SIDE) == 'bottom' then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + end + + EgtMove( nIdGeomType, ptPosDwGeom - ORIG()) + else + ApplyDispRollerLatch( nIdGeomType, nExtraAngle, sSideLk, bPushDr, sSideDoor, ptPosUpGeom, ptPos) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + else + if sSideDoorBox and string.lower(sSideDoorBox) == 'locklh' then + nExtraAngle = 0 + end + ApplyDispRollerLatch( nIdGeomType, nExtraAngle, sSideLk, bPushDr, sSideDoor, ptPosUpGeom, ptPos) + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + end + end +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : PIVOTS *** +----------------------------------------------------------------- +local function ApplyDispPivot( nIdGeomType, nLocAngle, bPushDr, sSideLk, sSideDoor, ptPosUpGeom, ptPos) + + EgtRotate( nIdGeomType, ORIG(), X_AX(), ( 90 + nLocAngle), GDB_RT.GLOB) -- ruoto su faccia frontale per RHR e LHR + EgtRotate( nIdGeomType, ORIG(), Z_AX(), 90, GDB_RT.GLOB) -- ruoto su faccia destra RHR e LHR + + if bPushDr then -- se apertura a spingere RH LH + EgtMirror( nIdGeomType, ORIG(), Z_AX(), GDB_RT.GLOB) + end + + if sSideLk == 'R' then -- se serratura a destra LH LHR + EgtMirror( nIdGeomType, ORIG(), X_AX(), GDB_RT.GLOB) + end + + if sSideDoor == 'edge' then -- se spostamento sul bordo + EgtMove( nIdGeomType, ptPosUpGeom - ORIG(), GDB_RT.GLOB) + elseif ( sSideDoor == 'center') then -- se posizionamento in centro spessore + EgtMove( nIdGeomType, ptPos - ORIG(), GDB_RT.GLOB) + end +end + +local function MoveSubGeomPivot( nSubPivotId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUpGeom, nExtraAngle, ptPosDwGeom) + + if string.lower(DGD.TYPE) ~= 'offsetintermediate' then + + EgtRotate( nSubPivotId, ORIG(), X_AX(), -90) -- ruoto su faccia dietro + + if DGD.sFrame then + if DGD.nTypePz == 5 then + -- se serratura a destra: LH, LHR, ... e non è sulla seconda anta + if ( sSideLk == 'R' and not DGD.OTHERD) or + ( sSideLk == 'L' and DGD.OTHERD) then + EgtMirror( nSubPivotId, ORIG(), X_AX()) + end + elseif DGD.nTypePz == 6 then + -- se serratura a destra: LH, LHR, ... e non è sulla seconda anta + if ( sSideLk == 'R' and DGD.OTHERD) or + ( sSideLk == 'L' and not DGD.OTHERD) then + EgtMirror( nSubPivotId, ORIG(), X_AX()) + end + end + + if not bPushDr then -- se apertura a tirare + EgtMirror( nSubPivotId, ORIG(), Z_AX()) + end + else + if sSideLk == 'R' then -- se serratura a destra: LH, LHR, ... + EgtMirror( nSubPivotId, ORIG(), X_AX()) + end + + if not bPushDr then -- se apertura a tirare + EgtMirror( nSubPivotId, ORIG(), Z_AX()) + end + end + + if ( string.lower(DGD.SIDE) == 'bottom') then + EgtMirror( nSubPivotId, ORIG(), Y_AX()) + elseif DGD.sFrame and ( string.lower(DGD.SIDE) == 'top') then + EgtMirror( nSubPivotId, ORIG(), X_AX()) + end + + if sSideDoor == 'edge' then -- se spostamento sul bordo + EgtMove( nSubPivotId, ptPosUpGeom - ORIG()) + elseif ( sSideDoor == 'center') then -- se posizionamento in centro spessore + EgtMove( nSubPivotId, ptPos - ORIG()) + end + + -- gestione percorsi upper + local nIdGeomType = EgtGetFirstInGroup( nSubPivotId) -- ottengo la prima geometria + local sSideDoorBox + + while nIdGeomType do + + sSideDoorBox = EgtGetInfo( nIdGeomType, 'SideDoor') + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoorBox and sSideDoorBox == 'upper' then + if not DGD.Dws then + if bPushDr then + EgtSetInfo( nIdGeomType, 'SideDoor', 'secure') + sSideDoorBox = 'secure' + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + nUpperToDelete = nIdGeomType + end + + if sSideDoorBox == 'keyway' or sSideDoorBox == 'secure' then + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + end + end + else -- altimrnti è offset intermediate + + local nLocAngle = nExtraAngle + local sSideDoorBox + local nIdGeomType = EgtGetFirstInGroup( nSubPivotId) -- ottengo la prima geometria + + while nIdGeomType do + + sSideDoorBox = EgtGetInfo( nIdGeomType, 'SideDoor') + local nUpperToDelete + + if sSideDoorBox and string.lower(sSideDoorBox) == 'locklh' then + nLocAngle = 0 + end + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoorBox and sSideDoorBox == 'upper' then + if not DGD.Dws then + if bPushDr then + EgtSetInfo( nIdGeomType, 'SideDoor', 'secure') + sSideDoorBox = 'secure' + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + nUpperToDelete = nIdGeomType + end + + if sSideDoorBox == 'keyway' or sSideDoorBox == 'secure' then + + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + +-- if DGD.SIDE == 'hinge' then +-- if sSideLk == 'L' then -- se serratura a sinistra +-- EgtRotate( nIdGeomType, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra +-- else +-- EgtRotate( nIdGeomType, ORIG(), Z_AX(), -90 ) -- ruoto su faccia sinistra +-- end +-- end + + EgtRotate( nIdGeomType, ORIG(), Z_AX(), 90 ) -- ruoto su faccia destra + + if bPushDr then -- se apertura a spingere + EgtMirror( nIdGeomType, ORIG(), Z_AX()) + end + + if sSideLk == 'R' then -- se serratura a destra LH LHR + EgtMirror( nIdGeomType, ORIG(), X_AX(), GDB_RT.GLOB) + end + + if DGD.sFrame then + if string.lower(DGD.SIDE) == 'bottom' then -- frame superiore ( ha il side opposto) + if DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + else + EgtMirror( nIdGeomType, ORIG(), X_AX()) + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + elseif string.lower(DGD.SIDE) == 'top' then -- frame inferiore (ha il side opposto) + if not DGD.OTHERD then + EgtMirror( nIdGeomType, ORIG(), X_AX()) + end + end + else +-- if string.lower(DGD.SIDE) == 'bottom' then +-- EgtMirror( nIdGeomType, ORIG(), Y_AX()) +-- end + end + + EgtMove( nIdGeomType, ptPosDwGeom - ORIG()) + else + ApplyDispPivot( nIdGeomType, nLocAngle, bPushDr, sSideLk, sSideDoor, ptPosUpGeom, ptPos) + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + else + + ApplyDispPivot( nIdGeomType, nLocAngle, bPushDr, sSideLk, sSideDoor, ptPosUpGeom, ptPos) + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + end + end + end +end + +----------------------------------------------------------------- +-- *** Geometric subgeom processing : STOPSANDCLOSERS *** +----------------------------------------------------------------- +local function MoveSubGeomStopAndCloser( nSubtStopAndCloserId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUp, nBoxGeom, ptPosUpGeom, ptPosDwGeom) + + local dDeltaPos = 0 + local sDeltaPos + local psDelta + -- ciclo sulle geometrie singole invece di modificare il layer + local nIdGeomType + + -- se devo muovere le singole geometrie dell' OverHead o il layer dello stop&closer e la geometria di ingombro presente nello Stop&Closer + if not nBoxGeom or nBoxGeom == 0 then + + nIdGeomType = nSubtStopAndCloserId + + -- se geometria sul fianco + if sSideDoor == 'edge' then -- se spostamento sul bordo + + sDeltaPos = EgtGetInfo( nIdGeomType, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + EgtRotate( nIdGeomType, ORIG(), X_AX(), -90 ) -- ruoto su faccia dietro + + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + + if bPushDr then -- se apertura a spingere + EgtMirror( nIdGeomType, ORIG(), Z_AX()) -- faccio il mirror su asse Z per ribaltare l'uscita in alto + EgtMirror( nIdGeomType, ORIG(), X_AX()) -- faccio il mirror su asse X per risistemare la direzione percorso + EgtMove( nIdGeomType, Point3d( -dDeltaPos, 0, 0) - ORIG()) -- riposiziono per il ribaltamento del mirror in X + end + + if DGD.sFrame then + if ( sSideLk == 'R' and DGD.OTHERD) or + ( sSideLk == 'L' and not DGD.OTHERD) then + dDeltaPos = 0 + end + else + if sSideLk == 'L' then -- se serratura a sinistra + dDeltaPos = 0 + end + end + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + psDelta = Point3d( ( dDeltaPos * cos(DGD.A2)), ( dDeltaPos * sin(DGD.A2)), 0) + else + psDelta = Point3d( ( dDeltaPos * cos(DGD.A5)), ( dDeltaPos * sin(DGD.A5)), 0) + end + else + psDelta = Point3d( dDeltaPos, 0, 0) + end + + EgtMove( nIdGeomType, ( ptPosUp + psDelta) - ORIG()) + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtRotate( nIdGeomType, ( ptPosUp + psDelta), Z_AX(), DGD.A2) + else + EgtRotate( nIdGeomType, ( ptPosUp + psDelta), Z_AX(), DGD.A5) + end + end + elseif ( sSideDoor == 'center') then -- se posizionamento in centro spessore + + sDeltaPos = EgtGetInfo( nIdGeomType, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + EgtRotate( nIdGeomType, ORIG(), X_AX(), -90, GDB_RT.GLOB) -- ruoto su faccia dietro su coordinate globali + + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + + if DGD.sFrame then + if ( sSideLk == 'R' and DGD.OTHERD) or + ( sSideLk == 'L' and not DGD.OTHERD) then + dDeltaPos = 0 + end + else + if sSideLk == 'L' then -- se serratura a sinistra + dDeltaPos = 0 + end + end + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + psDelta = Point3d( ( dDeltaPos * cos(DGD.A2)), ( dDeltaPos * sin(DGD.A2)), 0) + else + psDelta = Point3d( ( dDeltaPos * cos(DGD.A5)), ( dDeltaPos * sin(DGD.A5)), 0) + end + else + psDelta = Point3d( dDeltaPos, 0, 0) + end + EgtMove( nIdGeomType, ( ptPos + psDelta) - ORIG()) + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtRotate( nIdGeomType, ( ptPos + psDelta), Z_AX(), DGD.A2) + else + EgtRotate( nIdGeomType, ( ptPos + psDelta), Z_AX(), DGD.A5) + end + end + end + + -- cerco nel layer la geometria di ingombro presente nello Stop&Closer + if nBoxGeom then + + nIdGeomType = EgtGetFirstInGroup( nSubtStopAndCloserId) -- ottengo la prima geometria + + while nIdGeomType do + + local sSideDoorBox = EgtGetInfo( nIdGeomType, 'SideDoor') + local nUpperToDelete + + -- rinomino eventuali geometrie che descrivono solo la sezione + if sSideDoorBox and sSideDoorBox == 'upper' then + if not DGD.Dws then + if bPushDr then + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'secure') + sSideDoorBox = 'secure' + end + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + end + nUpperToDelete = nIdGeomType + end + + if sSideDoorBox == 'keyway' or sSideDoorBox == 'secure' then + + if not DGD.Dws then -- se disposizione frame su lato narrow o porta + EgtRotate( nIdGeomType, ORIG(), X_AX(), -90 ) -- ruoto su faccia dietro + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + elseif sSideDoorBox == 'Keyway' then -- geometria originale + if not DGD.Dws then + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + end + elseif sSideDoorBox == 'Secure' then -- geometria originale + if not DGD.Dws then + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + end + end + + nIdGeomType = EgtGetNext(nIdGeomType) + -- cancello il percorso 'upper' + if nUpperToDelete then + EgtErase( nUpperToDelete) + end + end + end + elseif nBoxGeom == 1 then -- se singolo persorso di ingombro dell'OverHead + + nIdGeomType = nSubtStopAndCloserId + + if bPushDr then + EgtSetInfo( nIdGeomType, 'SideDoor', 'keyway') + sSideDoorBox = 'keyway' + else + EgtSetInfo( nIdGeomType, 'SideDoor', 'secure') + sSideDoorBox = 'secure' + end + + -- le geometrie di ingombro sono posizionate sempre sul bordo, quindi tipo 'edge' + sDeltaPos = EgtGetInfo( nIdGeomType, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + EgtRotate( nIdGeomType, ORIG(), X_AX(), 180 ) -- ruoto su faccia dietro + + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtMirror( nIdGeomType, ORIG(), Y_AX()) + end + + if bPushDr then -- se apertura a spingere + EgtMirror( nIdGeomType, ORIG(), Z_AX()) -- faccio il mirror su asse Z per ribaltare l'uscita in alto + EgtMirror( nIdGeomType, ORIG(), X_AX()) -- faccio il mirror su asse X per risistemare la direzione percorso + EgtMove( nIdGeomType, Point3d( -dDeltaPos, 0, 0) - ORIG()) -- riposiziono per il ribaltamento del mirror in X + end + + if DGD.sFrame then + -- se serratura a destra: LH, LHR, ... e non è sulla seconda anta + if ( sSideLk == 'R' and not DGD.OTHERD) or + ( sSideLk == 'L' and DGD.OTHERD) then + EgtMirror( nSubPivotId, ORIG(), X_AX()) + end + if sSideLk == 'L' then -- se serratura a sinistra + dDeltaPos = 0 + end + else + if sSideLk == 'L' then -- se serratura a sinistra + dDeltaPos = 0 + end + end + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + psDelta = Point3d( ( dDeltaPos * cos(DGD.A2)), ( dDeltaPos * sin(DGD.A2)), 0) + else + psDelta = Point3d( ( dDeltaPos * cos(DGD.A5)), ( dDeltaPos * sin(DGD.A5)), 0) + end + else + psDelta = Point3d( dDeltaPos, 0, 0) + end + + EgtMove( nIdGeomType, ( ptPosUp + psDelta) - ORIG()) + + if bRemake then + if DGD.SIDE and string.lower(DGD.SIDE) == 'bottom' then + EgtRotate( nIdGeomType, ( ptPosUp + psDelta), Z_AX(), DGD.A2) + else + EgtRotate( nIdGeomType, ( ptPosUp + psDelta), Z_AX(), DGD.A5) + end + end + + -- creo estrusi e superfici piane delle geometrie passanti + AddSurfTmByExtrusion( EgtGetParent(nIdGeomType), nIdGeomType, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( EgtGetParent(nIdGeomType), EgtGetParent(nIdGeomType)) + -- cancello il percorso 'upper' + EgtErase( nUpperToDelete) + end +end + +----------------------------------------------------------------------------------------- +-- *** Geometric processing : common functions for rollerlatch, pivot, stopandcloser *** +----------------------------------------------------------------------------------------- +local function MoveGeometryTopDwHSide( sTypeGeom, nGeomId, sSideLk, bPushDr, ptPos, ptPosUp, nExtraAngle, ptPosDw, ptPosUpGeom, ptPosDwGeom) + + if not nGeomId then return end + + local sSideDoorToMove + local sMessageErr = '' + + sSideDoorToMove = EgtGetInfo( nGeomId, 'InserPoint') + local nErr = 0 + + if DGD.sFrame and DGD.nTypePz == 5 then + DGD.SIDE = 'bottom' + elseif DGD.sFrame and DGD.nTypePz == 6 then + DGD.SIDE = 'top' + end + + if sSideDoorToMove then + + -- Controllo se la nota è corretta + local sSideDoor = string.lower(sSideDoorToMove) + + if sTypeGeom == 'rollerlatch' then + -- Edge: sullo spigolo della porta; Centre: in centro allo spessore + if sSideDoor == 'edge' or sSideDoor == 'center' then + MoveSubGeomRollerLatch( nGeomId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUp, nExtraAngle, ptPosDw) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[415],nGeomId,'RollerLatch',sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1009 + end + elseif sTypeGeom == 'pivot' then + -- Edge: sullo spigolo della porta; Centre: in centro allo spessore + if sSideDoor == 'edge' or sSideDoor == 'center' then + MoveSubGeomPivot( nGeomId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUp, nExtraAngle, ptPosDw) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[415],nGeomId,'Pivot',sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1011 + end + elseif sTypeGeom == 'stopandcloser' then + -- Edge: sullo spigolo della porta; Centre: in centro allo spessore + if sSideDoor == 'edge' or sSideDoor == 'center' then + local nBoxGeom = 0 + MoveSubGeomStopAndCloser( nGeomId, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUp, nBoxGeom, ptPosUpGeom, ptPosDwGeom) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[415],nGeomId,'StopAndCloser',sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1013 + end + end + else + -- messaggio di errore in base al tipo di pezzo + if sTypeGeom == 'rollerlatch' then + sMessageErr = string.format( EgtDoorsMsg[416],nGeomId,'RollerLatch', DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1010 + elseif sTypeGeom == 'pivot' then + sMessageErr = string.format( EgtDoorsMsg[416],nPivotId,'Pivot', DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1012 + elseif sTypeGeom == 'stopandcloser' then + sMessageErr = string.format( EgtDoorsMsg[416],nStopAndCloserId,'StopAndCloser', DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1014 + end + end + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +---------------------------------------------------------------------- +-- *** Geometric processing : ROLLERLATCH, PIVOTS, STOPSANDCLOSERS *** +---------------------------------------------------------------------- +local function MoveRollerLatch( tRollerLatch, sSideLk, bPushDr) + + local ptPos + local ptPosBox + local ptRef + local ptPosUpGeom + local ptPosDwGeom + local dPosX + local dPosY + local dPosXProbe + local dPosYProbe + local dPosZ + local dPosZup + local dXFromExt + local dYFromExt + local dDeltaX + local nAngleBase + local nRadBase + local nExtraAngle = 0 + local nSideApplied = 2 + + if DGD.sFrame and DGD.nTypePz == 5 then + tRollerLatch.side = 'bottom' + bPushDr = not bPushDr + elseif DGD.sFrame and DGD.nTypePz == 6 then + tRollerLatch.side = 'top' + bPushDr = not bPushDr + end + + if DGD.OFFSET and DGD.OFFSET > 0 then + dDeltaX = DGD.OFFSET * TAN3 + dPosZ = DGD.OFFSET + else + dDeltaX = (DGD.dT/2) * TAN3 + dPosZ = (DGD.dT/2) + end + + -- se latch face ricalcolo il delta + if DGD.LSREF then + dDeltaX = DGD.dT * TAN3 + end + + if bPushDr then + dPosZup = DGD.dT + else + dPosZ = (DGD.dT - dPosZ) + dPosZup = 0 + end + + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tRollerLatch.side) == 'bottom' then + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PminBot + dLocAngle = DGD.A2 + else + ptRef = DGD.PmaxBot + dLocAngle = DGD.A1 + end + dPosY = ptRef:getY()+((tRollerLatch.position)*sin(dLocAngle)) + else + dPosY = EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + end + dPosYProbe = dPosY + DGD.DPR + dYFromExt = dPosY + nSideApplied = 4 + elseif string.lower(tRollerLatch.side) == 'lock' then + + if DGD.tProfs.lockedge.trimming == 'BU' or DGD.tProfs.lockedge.trimming == 'BD' or + DGD.tProfs.lockedge.trimming == 'BDEB' or DGD.tProfs.lockedge.trimming == 'BUEB' then -- se profilo bevel su lato lock + dPosX = dDeltaX + -- se non è presente il blocco rotazione su bevel + if not DGD.NOBVROT then + nExtraAngle = 3 + end + else + dPosX = 0 + end + + -- by DGC.Bwd setting set to 0 the dPosX parameter + if DGC.Bwd and DGC.Bwd == 2 then + dPosX = 0 + end + + if bRemake then + nAngleBase = atan(dPosX/tRollerLatch.position) + nRadBase = sqrt((dPosX*dPosX)+(tRollerLatch.position*tRollerLatch.position)) + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PminTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A4+nAngleBase)) , dPosZ) + ptPosBox = Point3d( ptRef:getX()+(tRollerLatch.position*cos(DGD.A4)), ptRef:getY()+(tRollerLatch.position*sin(DGD.A4)) , dPosZ) + dPosXProbe = ptRef:getX() + DGD.DPR + dXFromExt = ptRef:getX() + dPosYProbe = ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)) + DGD.DPR -- setto la X invece della Y + dYFromExt = dPosYProbe + else + ptRef = DGD.PmaxTop + ptPos = Point3d( ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)), ptRef:getY()+(nRadBase*sin(DGD.A7-nAngleBase)) , dPosZ) + ptPosBox = Point3d( ptRef:getX()+(tRollerLatch.position*cos(DGD.A7)), ptRef:getY()+(tRollerLatch.position*sin(DGD.A7)) , dPosZ) + dPosXProbe = ptRef:getX() - DGD.DPR + dXFromExt = ptRef:getX() + dPosYProbe = ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)) - DGD.DPR -- setto la X invece della Y + dYFromExt = dPosYProbe + end + else + if sSideLk == 'L' then -- se serratura a sinistra + ptPos = Point3d( dPosX + EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tRollerLatch.position) , dPosZ) + ptPosBox = Point3d( EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0), ( DGD.dH - tRollerLatch.position) , dPosZ) + dPosXProbe = ptPos:getX() + DGD.DPR + dXFromExt = EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + else + ptPos = Point3d( ( DGD.dW - dPosX - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tRollerLatch.position) , dPosZ) + ptPosBox = Point3d( ( DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0)), ( DGD.dH - tRollerLatch.position) , dPosZ) + dPosXProbe = ptPos:getX() - DGD.DPR + dXFromExt = DGD.dW - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + end + dPosYProbe = DGD.dH - tRollerLatch.position + dYFromExt = dPosYProbe + end + + ptPosUpGeom = Point3d( ptPos:getX(), ptPos:getY(), dPosZup) + ptPosDwGeom = Point3d( ptPosBox:getX(), ptPosBox:getY(), dPosZup) + nSideApplied = 3 + else + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PminTop + dLocAngle = DGD.A5 + else + ptRef = DGD.PmaxTop + dLocAngle = DGD.A6 + end + dPosY = ptRef:getY()+((tRollerLatch.position)*sin(dLocAngle)) + else + dPosY = DGD.dH - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + end + dPosYProbe = dPosY - DGD.DPR + dYFromExt = dPosY + end + + if string.lower(tRollerLatch.side) ~= 'lock' then + if sSideLk == 'R' then -- se serratura a destra + if bRemake then + if string.lower(tRollerLatch.side) == 'top' then + dPosX = ptRef:getX()+(tRollerLatch.position*cos(DGD.A6)) + else + dPosX = ptRef:getX()+(tRollerLatch.position*cos(DGD.A1)) + end + else + dPosX = DGD.dW - tRollerLatch.position + end + dPosXProbe = dPosX + dXFromExt = dPosX + else -- serratura a sinistra + if bRemake then + if string.lower(tRollerLatch.side) == 'top' then + dPosX = ptRef:getX()+(tRollerLatch.position*cos(DGD.A5)) + else + dPosX = ptRef:getX()+(tRollerLatch.position*cos(DGD.A2)) + end + else + dPosX = tRollerLatch.position + end + dPosXProbe = dPosX + dXFromExt = dPosX + end + + ptPos = Point3d( dPosX, dPosY, dPosZ) + ptPosUpGeom = Point3d( dPosX, dPosY, dPosZup) + ptPosDwGeom = ptPosUpGeom + end + + MoveGeometryTopDwHSide( 'rollerlatch', tRollerLatch.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom, nExtraAngle, ptPosDwGeom) + + if bRemake then + if string.lower(tRollerLatch.side) == 'top' then + EgtRotate( tRollerLatch.geom, ptPos, Z_AX(), DGD.A5) + elseif string.lower(tRollerLatch.side) == 'bottom' then + EgtRotate( tRollerLatch.geom, ptPos, Z_AX(), DGD.A2) + else + EgtRotate( tRollerLatch.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end + end + InsertProbeGeom( tRollerLatch.geom, Point3d(dPosXProbe,dPosYProbe,0), Point3d(dXFromExt,dYFromExt,0), 9, nSideApplied) +end + +----------------------------------------------------------------- +local function MovePivot( tPivot, sSideLk, bPushDr) + + local ptPos + local ptPosProbe + local ptPosUpGeom + local ptPosDwGeom + local ptRef + local ptFromExt + local dPosX + local dPosXProbe + local dPosY + local dPosYProbe + local dPosZ = (DGD.dT/2) + local dPosZup + local dPosZReg + local dXFromExt + local dYFromExt + local dDeltaPos = 0 + local sDeltaPos + local nDeltaX = 0 + local nExtraAngle = 0 + local nAngleBase + local nRadBase + local nErr = 0 + local nHardwareType = 12 + local nSideApplied = 1 + + -- se non è offsetintermediate ( quindi offset o centerhung) + if string.lower(tPivot.type) ~= 'offsetintermediate' then + + if string.lower(tPivot.side) == 'hinge' then + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[594], tPivot.type..' Pivot', tPivot.side) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1021 + end + + if DGD.sFrame and DGD.nTypePz == 5 then + tPivot.side = 'bottom' + elseif DGD.sFrame and DGD.nTypePz == 6 then + tPivot.side = 'top' + end + + if string.lower(tPivot.type) == 'offset' then + sDeltaPos = EgtGetInfo( tPivot.geom, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + end + + -- se applicato a lato top o bottom cambio la coordinata in Y + if string.lower(tPivot.side) == 'top' then + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxTop + dLocAngle = DGD.A6 + else + ptRef = DGD.PminTop + dLocAngle = DGD.A5 + end + dPosY = ptRef:getY()+((tPivot.position+dDeltaPos)*sin(dLocAngle)) + else + dPosY = DGD.dH - EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + end + dPosYProbe = dPosY - DGD.DPR + dYFromExt = dPosY + nSideApplied = 2 + else + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxBot + dLocAngle = DGD.A1 + else + ptRef = DGD.PminBot + dLocAngle = DGD.A2 + end + dPosY = ptRef:getY()+((tPivot.position+dDeltaPos)*sin(dLocAngle)) + else + dPosY = EgtIf( DGD.sFrame, DGD.dZedExtFrame, 0) + end + dPosYProbe = dPosY + DGD.DPR + dYFromExt = dPosY + nSideApplied = 4 + end + + if DGD.OFFSET and DGD.OFFSET > 0 then + dPosZ = DGD.OFFSET + else + dPosZ = (DGD.dT/2) + end + + if sSideLk == 'L' then -- se serratura a sinistra: RH, RHR, ... + if bRemake then + if string.lower(tPivot.side) == 'top' then + dPosX = ptRef:getX()+((tPivot.position+dDeltaPos)*cos(DGD.A6)) + else + dPosX = ptRef:getX()+((tPivot.position+dDeltaPos)*cos(DGD.A1)) + end + else + dPosX = DGD.dW - tPivot.position - dDeltaPos + end + else -- serratura a destra + if bRemake then + if string.lower(tPivot.side) == 'top' then + dPosX = ptRef:getX()+((tPivot.position+dDeltaPos)*cos(DGD.A5)) + else + dPosX = ptRef:getX()+((tPivot.position+dDeltaPos)*cos(DGD.A2)) + end + else + dPosX = tPivot.position + dDeltaPos + end + end + dPosXProbe = dPosX + dXFromExt = dPosX + + if bPushDr then + dPosZup = DGD.BACK_SET + dPosZReg = 0 + else + dPosZ = (DGD.dT - dPosZ) + dPosZup = DGD.dT - DGD.BACK_SET + dPosZReg = DGD.dT + end + else -- altrimenti tipo offsetintermediate + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + if string.lower(tPivot.side) ~= 'hinge' then + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[593], tPivot.type..' Pivot', 'hinge') + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = -1022 + end + + -- incremento il contatore di cerniere e pivot ( disposti su lato hinges) + nNumHingePivot = nNumHingePivot + 1 + + 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 + nExtraAngle = 3 + nDeltaX = (tPivot.back_set * sin(nExtraAngle)) + end + + -- by DGC.Bwd setting set to 0 the nDeltaX parameter + if DGC.Bwd and DGC.Bwd == 2 then + nDeltaX = 0 + end + + sDeltaPos = EgtGetInfo( tPivot.geom, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + if bRemake then + local dLocAngle + nAngleBase = atan(nDeltaX/(tPivot.position+dDeltaPos)) + nRadBase = sqrt((nDeltaX*nDeltaX)+((tPivot.position+dDeltaPos)*(tPivot.position+dDeltaPos))) + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxTop + dLocAngle = DGD.A7 + else + ptRef = DGD.PminTop + dLocAngle = DGD.A4 + end + dPosY = ptRef:getY()+((tPivot.position+dDeltaPos)*sin(dLocAngle)) + dPosYProbe = dPosY + dYFromExt = dPosY + else + dPosY = DGD.dH - tPivot.position - dDeltaPos + dPosYProbe = dPosY + dYFromExt = dPosY + end + + if sSideLk == 'L' then -- se serratura a sinistra: RH, RHR, ... + if DGD.sFrame then + dPosX = DGD.dW - nDeltaX - DGD.dZedExtFrame + dXFromExt = DGD.dW - DGD.dZedExtFrame + else + if bRemake then + dPosX = ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)) + dXFromExt = dPosX + else + dPosX = DGD.dW - nDeltaX + dXFromExt = DGD.dW + end + end + dPosXProbe = dPosX - DGD.DPR + else -- serratura a destra + if DGD.sFrame then + dPosX = nDeltaX + DGD.dZedExtFrame + dXFromExt = DGD.dZedExtFrame + else + if bRemake then + dPosX = ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)) + dXFromExt = dPosX + else + dPosX = nDeltaX + dXFromExt = 0 + end + end + dPosXProbe = dPosX + DGD.DPR + end + + if bPushDr then + dPosZup = DGD.BACK_SET + dPosZReg = 0 + else + dPosZup = DGD.dT - DGD.BACK_SET + dPosZReg = DGD.dT + end + -- assegno il tipo hardware come una hinge perchè viene applicato su quel lato + nHardwareType = 5 + end + + ptPos = Point3d( dPosX, dPosY, dPosZ) + ptPosUpGeom = Point3d( dPosX, dPosY, dPosZup) + ptPosDwGeom = Point3d( dPosX, dPosY, dPosZReg) + ptPosProbe = Point3d( dPosXProbe, dPosYProbe, 0) + ptFromExt = Point3d( dXFromExt, dYFromExt, 0) + + MoveGeometryTopDwHSide( 'pivot', tPivot.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom, nExtraAngle, ptPosDwGeom) + if bRemake then + if string.lower(tPivot.type) == 'offsetintermediate' then + EgtRotate( tPivot.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A8, DGD.A3)-90)) + else + EgtRotate( tPivot.geom, ptPos, Z_AX(), EgtIf( string.lower(tPivot.side) == 'top', DGD.A5, DGD.A2)) + end + end + InsertProbeGeom( tPivot.geom, ptPosProbe, ptFromExt, nHardwareType, nSideApplied) + + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +----------------------------------------------------------------- +local function MoveStopAndCloser( tStopAndCloser, sSideLk, bPushDr) + + local ptPos + local ptPosUp + local ptPosUpGeom + local ptPosDwGeom + local ptRef + local dPosY + local dPosZ + local dPosZup + local dPosProbe + local ptFromExt + + if DGD.sFrame and ( DGD.nTypePz == 5 or DGD.nTypePz == 6) then + dPosY = 0 + DGD.dZedExtFrame + bPushDr = not bPushDr + else + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxTop + dLocAngle = DGD.A6 + else + ptRef = DGD.PminTop + dLocAngle = DGD.A5 + end + dPosY = ptRef:getY()+((tStopAndCloser.position)*sin(dLocAngle)) + else + dPosY = DGD.dH + end + end + + if DGD.POCKET_OFFSET and DGD.POCKET_OFFSET > 0 then + dPosZ = EgtIf( bPushDr, DGD.POCKET_OFFSET, (DGD.dT - DGD.POCKET_OFFSET)) + else + dPosZ = DGD.dT/2 + end + dPosZup = EgtIf( bPushDr, DGD.dT, 0) + + if sSideLk == 'R' then -- se serratura a destra + if bRemake then + ptPos = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A5)), dPosY, dPosZ) + ptPosUp = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A5)), dPosY, dPosZup) + dPosProbe = Point3d( ptRef:getX()+(EgtIf( abs(tStopAndCloser.position) < DGD.DPR, (DGD.dW/4), tStopAndCloser.position)*cos(DGD.A5)), dPosY, dPosZup) + ptPosUpGeom = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A5)), dPosY, DGD.dT) + else + ptPos = Point3d( tStopAndCloser.position, dPosY, dPosZ) + ptPosUp = Point3d( tStopAndCloser.position, dPosY, dPosZup) + dPosProbe = Point3d( EgtIf( abs(tStopAndCloser.position) < DGD.DPR, (DGD.dW/4), tStopAndCloser.position), dPosY, dPosZup) + ptPosUpGeom = Point3d( tStopAndCloser.position, dPosY, DGD.dT) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + ptFromExt = dPosProbe + else -- serratura a sinistra + if bRemake then + ptPos = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A6)), dPosY, dPosZ) + ptPosUp = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A6)), dPosY, dPosZup) + dPosProbe = Point3d( ptRef:getX()+(EgtIf( abs(tStopAndCloser.position) < DGD.DPR, (DGD.dW/4), tStopAndCloser.position)*cos(DGD.A6)), dPosY, dPosZup) + ptPosUpGeom = Point3d( ptRef:getX()+(tStopAndCloser.position*cos(DGD.A6)), dPosY, DGD.dT) + else + ptPos = Point3d( ( DGD.dW - tStopAndCloser.position), dPosY, dPosZ) + ptPosUp = Point3d( ( DGD.dW - tStopAndCloser.position), dPosY, dPosZup) + dPosProbe = Point3d( ( DGD.dW - EgtIf( abs(tStopAndCloser.position) < DGD.DPR, (DGD.dW/4), tStopAndCloser.position)), dPosY, dPosZup) + ptPosUpGeom = Point3d( ( DGD.dW - tStopAndCloser.position), dPosY, DGD.dT) + end + ptPosDwGeom = Point3d( ptPosUpGeom:getX(), ptPosUpGeom:getY() , 0) + ptFromExt = dPosProbe + end + + MoveGeometryTopDwHSide( 'stopandcloser', tStopAndCloser.geom, sSideLk, bPushDr, ptPos, ptPosUp, nil, nil, ptPosUpGeom, ptPosDwGeom) + InsertProbeGeom( tStopAndCloser.geom, Point3d(dPosProbe:getX(),dPosProbe:getY()-DGD.DPR,0), Point3d(ptFromExt:getX(),ptFromExt:getY(),0), 4, 2) +end + +----------------------------------------------------------------------------------------- +-- *** Geometric processing : functions for overhead *** +----------------------------------------------------------------------------------------- +local function MoveGeometryOverHead( sTypeGeom, nGeomId, sSideLk, bPushDr, ptPos, ptPosUp) + + if not nGeomId then return end + + local nIdGeomType + local sSideDoorToMove + local sMessageErr = '' + local nBoxGeom = 1 + + -- devo ottenere tutte le geometrie del over head + nIdGeomType = EgtGetFirstInGroup( nGeomId) -- ottengo la prima geometria + local nErr = 0 + + while nIdGeomType do + + local sSideDoorBox = EgtGetInfo( nIdGeomType, 'SideDoor') + + -- se geometrie che descrivono la sezione + if sSideDoorBox and sSideDoorBox == 'upper' then + MoveSubGeomStopAndCloser( nIdGeomType, sSideDoorBox, sSideLk, bPushDr, ptPos, ptPosUp, nBoxGeom) + else + + sSideDoorToMove = EgtGetInfo( nIdGeomType, 'InserPoint') + + if sSideDoorToMove then + + -- Controllo se la nota è corretta + local sSideDoor = string.lower(sSideDoorToMove) + + if sTypeGeom == 'overhead' then + -- Edge: sullo spigolo della porta; Centre: in centro allo spessore + if sSideDoor == 'edge' or sSideDoor == 'center' then + MoveSubGeomStopAndCloser( nIdGeomType, sSideDoor, sSideLk, bPushDr, ptPos, ptPosUp) + else + -- messaggio di errore + sMessageErr = string.format( EgtDoorsMsg[415], nIdGeomType,'OverHead',sSideDoor, DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1015 + end + end + else + -- messaggio di errore in base al tipo di pezzo + if sTypeGeom == 'overhead' then + sMessageErr = string.format( EgtDoorsMsg[416], nIdGeomType,'OverHead', DGD.FILE) + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + nErr = 1016 + end + end + end + + nIdGeomType = EgtGetNext(nIdGeomType) + end + -- assegno codice errore se ancora non fatto + if DGD.ERR == 0 then DGD.ERR = nErr end +end + +----------------------------------------------------------------- +local function MoveOverHead( tOverHead, sSideLk, bPushDr) + + local ptPos + local ptPosUpGeom + local ptFromExt + local ptRef + local dPosY + local dPosYUp + local dPosZ + local dPosZup + + if DGD.sFrame and ( DGD.nTypePz == 5 or DGD.nTypePz == 6) then + dPosY = 0 + DGD.dZedExtFrame + DGD.SIDE = 'bottom' + bPushDr = not bPushDr + else + if bRemake then + local dLocAngle + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxTop + dLocAngle = DGD.A6 + else + ptRef = DGD.PminTop + dLocAngle = DGD.A5 + end + dPosY = ptRef:getY()+((tOverHead.pockpos)*sin(dLocAngle)) + dPosYUp = ptRef:getY()+((tOverHead.armpos)*sin(dLocAngle)) + else + dPosY = DGD.dH + end + end + + if DGD.POCKET_OFFSET and DGD.POCKET_OFFSET > 0 then + dPosZ = EgtIf( bPushDr, DGD.POCKET_OFFSET, (DGD.dT - DGD.POCKET_OFFSET)) + else + dPosZ = DGD.dT/2 + end + dPosZup = EgtIf( bPushDr, DGD.dT, 0) + + if sSideLk == 'R' then -- se serratura a destra + if bRemake then + ptPos = Point3d( ptRef:getX()+(tOverHead.pockpos*cos(DGD.A5)), dPosY, dPosZ) + ptPosUpGeom = Point3d( ptRef:getX()+(tOverHead.armpos*cos(DGD.A5)), dPosYUp, dPosZup) + else + ptPos = Point3d( tOverHead.pockpos, dPosY, dPosZ) + ptPosUpGeom = Point3d( tOverHead.armpos, dPosY, dPosZup) + end + else -- serratura a sinistra + if bRemake then + ptPos = Point3d( ptRef:getX()+(tOverHead.pockpos*cos(DGD.A6)), dPosY, dPosZ) + ptPosUpGeom = Point3d( ptRef:getX()+(tOverHead.armpos*cos(DGD.A6)), dPosYUp, dPosZup) + else + ptPos = Point3d( ( DGD.dW - tOverHead.pockpos), dPosY, dPosZ) + ptPosUpGeom = Point3d( ( DGD.dW - tOverHead.armpos), dPosY, dPosZup) + end + end + ptFromExt = ptPosUpGeom + + MoveGeometryOverHead( 'overhead', tOverHead.geom, sSideLk, bPushDr, ptPos, ptPosUpGeom) + InsertProbeGeom( tOverHead.geom, Point3d(ptPosUpGeom:getX(),ptPosUpGeom:getY()-DGD.DPR,0), Point3d(ptFromExt:getX(),ptFromExt:getY(),0), 13, 2) +end + +----------------------------------------------------------------------------------------- +-- *** Geometric processing : functions for GROOVE *** +----------------------------------------------------------------------------------------- +local function MoveGeomGroove( nGrooveId, sSideLk, ptPos, sSide, bPushDr, dTopAngleDoor) + + if sSide and ( sSide == 'top' or sSide == 'top_flat' or sSide == 'top_angle') then + if DGD.GRS then + EgtRotate( nGrooveId, ORIG(), X_AX(), 90 ) -- ruoto su faccia frontale ( faccia sotto della porta) + EgtMirror( nGrooveId, ORIG(), Y_AX()) -- faccio mirror in Y + else + EgtRotate( nGrooveId, ORIG(), X_AX(), -90 ) -- ruoto su faccia dietro ( faccia sopra della porta) + end + else + EgtRotate( nGrooveId, ORIG(), X_AX(), 90 ) -- ruoto su faccia frontale ( faccia sotto della porta) + end + + if not sSide or ( sSide == 'top' or sSide == 'top_flat' or sSide == 'top_angle') or sSide == 'bottom' then + if sSideLk == 'R' and not DGD.GRS then -- se serratura a destra + EgtRotate( nGrooveId, ORIG(), Y_AX(), 180 ) -- ruoto per portare l'eventuale uscita dalla parte delle cerniere + end + + if not bPushDr and DGD.GRS then -- se è una bevel dn + EgtRotate( nGrooveId, ORIG(), Y_AX(), 180 ) -- ruoto per portare lo scasso in basso sul lato narrow + end + + if sSide == 'top_angle' and dTopAngleDoor and abs(dTopAngleDoor) > 0 then + EgtRotate( nGrooveId, ORIG(), Z_AX(), dTopAngleDoor) -- ruoto sull'angolo inclinato lato top + end + else -- se piazzamento sui fianchi + if not bPushDr and DGD.GRS then -- se è una bevel dn + EgtRotate( nGrooveId, ORIG(), Y_AX(), 180 ) -- ruoto per portare lo scasso in basso sul lato narrow + end + + if sSide == 'hinge' then + if sSideLk == 'R' then + EgtRotate( nGrooveId, ORIG(), Z_AX(), -90 ) + else + EgtRotate( nGrooveId, ORIG(), Z_AX(), 90 ) + end + else + if sSideLk == 'R' then + EgtRotate( nGrooveId, ORIG(), Z_AX(), 90 ) + else + EgtRotate( nGrooveId, ORIG(), Z_AX(), -90 ) + end + end + end + + EgtMove( nGrooveId, ptPos - ORIG()) +end + +----------------------------------------------------------------- +local function MoveGroove( tGroove, sSideLk, bPushDr) + + local ptPos + local ptRef + local dPosX = DGD.dW / 2 + local dPosY = 0 + + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + -- se è ad angoolo ricalcolo la posizione + if DGD.Tpa then + -- se è applicato su lato dritto piatto + if tGroove.side == 'top_flat' then + -- se lunghezza lato dritto esiste + if DGD.tProfs.top.xdeltapos > 0 then + -- se parte angolata sulla parte sinistra + if DGD.tProfs.top.angle > 0 then + dPosX = DGD.dW - ( DGD.tProfs.top.xdeltapos / 2) + -- altrimenti parte angolata sulla parte destra + else + dPosX = ( DGD.tProfs.top.xdeltapos / 2) + end + else + dPosX = DGD.dW / 2 + end + -- altrimenti se applicato sul lato inclinato + elseif tGroove.side == 'top_angle' then + -- se lunghezza lato inclinato esiste + if ( DGD.dW - DGD.tProfs.top.xdeltapos) > 0 then + -- se parte angolata sulla parte sinistra + if DGD.tProfs.top.angle > 0 then + dPosX = ( DGD.dW - DGD.tProfs.top.xdeltapos) / 2 + -- altrimenti parte angolata sulla parte destra + else + dPosX = DGD.dW - ( ( DGD.dW - DGD.tProfs.top.xdeltapos) / 2) + end + else + dPosX = DGD.dW / 2 + end + else + dPosX = DGD.dW / 2 + end + else + dPosX = DGD.dW / 2 + end + -- se è ad angoolo e deve essere applicato sul lato inclinato + if DGD.Tpa and tGroove.side == 'top_angle' then + -- se lunghezza lato inclinato esiste + if ( DGD.dW - DGD.tProfs.top.xdeltapos) > 0 then + dPosY = DGD.dH - ( ( ( DGD.dW - DGD.tProfs.top.xdeltapos) / 2) * tan( abs( DGD.tProfs.top.angle))) + else + dPosY = DGD.dH + end + -- inserisco nota nella porta con id geometria se il groove è effettivamente applicato sul lato inclinato + if dPosY < DGD.dH then + -- verifico se la nota esiste già + local sAngGrooveNote = EgtGetInfo( DGD.PZ, 'GrooveOnAngle', 's') + -- se non è presente aggiungo + if not sAngGrooveNote then + sAngGrooveNote = EgtNumToString( tGroove.geom, 0) + else + sAngGrooveNote = sAngGrooveNote .. ',' .. EgtNumToString( tGroove.geom, 0) + end + EgtSetInfo( DGD.PZ, 'GrooveOnAngle', sAngGrooveNote) + end + else + dPosY = DGD.dH + end + elseif tGroove.side and tGroove.side == 'hinge' then + dPosY = DGD.dH/2 + if sSideLk == 'R' then -- se serratura a destra + dPosX = 0 + else + dPosX = DGD.dW + end + elseif tGroove.side and tGroove.side == 'lock' then + dPosY = DGD.dH/2 + if sSideLk == 'R' then -- se serratura a destra + dPosX = DGD.dW + else + dPosX = 0 + end + else + dPosX = DGD.dW / 2 + dPosY = 0 + end + + if bPushDr then -- se è una bevel up + if tGroove.groove_offset then + if DGD.GRS then + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_angle' or tGroove.side == 'top_flat') then + ptRef = EgtMP(nDoorTopTop) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftTop) + else + ptRef = EgtMP(nDoorRightTop) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightTop) + else + ptRef = EgtMP(nDoorLeftTop) + end + else + ptRef = EgtMP(nDoorBotTop) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , DGD.dT) + end + else + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTopMid) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftMid) + else + ptRef = EgtMP(nDoorRightMid) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightMid) + else + ptRef = EgtMP(nDoorLeftMid) + end + else + ptRef = EgtMP(nDoorBotMid) + end + ptPos = Point3d( EgtMP:getX(ptRef), EgtMP:getY(ptRef) , tGroove.groove_offset) + else + ptPos = Point3d( dPosX, dPosY , tGroove.groove_offset) + end + end + else + if DGD.GRS then + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTopTop) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftTop) + else + ptRef = EgtMP(nDoorRightTop) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightTop) + else + ptRef = EgtMP(nDoorLeftTop) + end + else + ptRef = EgtMP(nDoorBotTop) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY, DGD.dT) + end + else + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTopMid) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftMid) + else + ptRef = EgtMP(nDoorRightMid) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightMid) + else + ptRef = EgtMP(nDoorLeftMid) + end + else + ptRef = EgtMP(nDoorBotMid) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , (DGD.dT/2)) + end + end + end + else -- se è bevel dw + if tGroove.groove_offset then + if DGD.GRS then + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTop) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeft) + else + ptRef = EgtMP(nDoorRight) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRight) + else + ptRef = EgtMP(nDoorLeft) + end + else + ptRef = EgtMP(nDoorBot) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , 0) + end + else + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTopMid) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftMid) + else + ptRef = EgtMP(nDoorRightMid) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightMid) + else + ptRef = EgtMP(nDoorLeftMid) + end + else + ptRef = EgtMP(nDoorBotMid) + end + ptPos = Point3d( EgtMP:getX(ptRef), EgtMP:getY(ptRef) , tGroove.groove_offset) + else + ptPos = Point3d( dPosX, dPosY , ( DGD.dT - tGroove.groove_offset)) + end + end + else + if DGD.GRS then + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTop) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeft) + else + ptRef = EgtMP(nDoorRight) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRight) + else + ptRef = EgtMP(nDoorLeft) + end + else + ptRef = EgtMP(nDoorBot) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , 0) + end + else + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + ptRef = EgtMP(nDoorTopMid) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorLeftMid) + else + ptRef = EgtMP(nDoorRightMid) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + ptRef = EgtMP(nDoorRightMid) + else + ptRef = EgtMP(nDoorLeftMid) + end + else + ptRef = EgtMP(nDoorBotMid) + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , (DGD.dT/2)) + end + end + end + end + + MoveGeomGroove( tGroove.geom, sSideLk, ptPos, tGroove.side, bPushDr, DGD.tProfs.top.angle) + if bRemake then + if tGroove.side and ( tGroove.side == 'top' or tGroove.side == 'top_flat' or tGroove.side == 'top_angle') then + EgtRotate( tGroove.geom, ptPos, Z_AX(), DGD.A5) + elseif tGroove.side and tGroove.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + EgtRotate( tGroove.geom, ptPos, Z_AX(), (DGD.A3-90)) + else + EgtRotate( tGroove.geom, ptPos, Z_AX(), (DGD.A8-90)) + end + elseif tGroove.side and tGroove.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + EgtRotate( tGroove.geom, ptPos, Z_AX(), (DGD.A8-90)) + else + EgtRotate( tGroove.geom, ptPos, Z_AX(), (DGD.A3-90)) + end + else + EgtRotate( tGroove.geom, ptPos, Z_AX(), DGD.A2) + end + end + -- creo estrusi e superfici piane delle geometrie passanti + local nGId = EgtGetFirstNameInGroup( tGroove.geom, 'BOXGROOVE') + if nGId then + AddSurfTmByExtrusion( tGroove.geom, nGId, true, nil, true) + -- sposto gli estrusi e le superfici piane nel layer solid + AddFlatSurf( tGroove.geom, tGroove.geom) + EgtErase(nGId) + end +end + +----------------------------------------------------------------------------------------- +-- *** Geometric processing : functions for RABBET *** +----------------------------------------------------------------------------------------- +local function MoveGeomRabbet( nRabbetId, sSideLk, bPushDr, ptPos) + + local nRotX + local nRotY + local nRotZ + + if DGD.sFrame then + -- se frame lock or frame hinge on left + if (( DGD.sFrame == 'L' or DGD.sFrame == 'LE') and sSideLk == 'L') or + (( DGD.sFrame == 'H' or DGD.sFrame == 'HE') and sSideLk == 'R') then + + EgtRotate( nRabbetId, ORIG(), Y_AX(), 90 ) + + if DGD.SIDE == 'top' then + nRotX = 0 + elseif DGD.SIDE == 'bottom' then + nRotX = 180 + else + if bPushDr then + nRotX = -90 + else + nRotX = 90 + end + end + + if nRotX ~= 0 then + EgtRotate( nRabbetId, ORIG(), X_AX(), nRotX) + end + -- se frame lock or frame hinge on right + elseif (( DGD.sFrame == 'L' or DGD.sFrame == 'LE') and sSideLk == 'R') or + (( DGD.sFrame == 'H' or DGD.sFrame == 'HE') and sSideLk == 'L') then + + EgtRotate( nRabbetId, ORIG(), Y_AX(), -90 ) + + if DGD.SIDE == 'top' then + nRotX = 0 + elseif DGD.SIDE == 'bottom' then + nRotX = 180 + else + if bPushDr then + nRotX = -90 + else + nRotX = 90 + end + end + + if nRotX ~= 0 then + EgtRotate( nRabbetId, ORIG(), X_AX(), nRotX) + end + -- se frame top + elseif DGD.nTypePz == 5 then + + EgtRotate( nRabbetId, ORIG(), X_AX(), 90 ) + + if DGD.SIDE == 'top' then + nRotY = 90 + elseif DGD.SIDE == 'bottom' then + nRotY = -90 + else + if bPushDr then + nRotY = 180 + else + nRotY = 0 + end + end + + if nRotY ~= 0 then + EgtRotate( nRabbetId, ORIG(), Y_AX(), nRotY) + end + -- frame bottom + else + + EgtRotate( nRabbetId, ORIG(), X_AX(), -90 ) + + if DGD.SIDE == 'top' then + nRotY = -90 + elseif DGD.SIDE == 'bottom' then + nRotY = 90 + else + if bPushDr then + nRotY = 0 + else + nRotY = 180 + end + end + + if nRotY ~= 0 then + EgtRotate( nRabbetId, ORIG(), Y_AX(), nRotY) + end + end + else + -- se porta a tirare il rabbet va sotto + if not bPushDr then + EgtRotate( nRabbetId, ORIG(), Y_AX(), 180 ) + end + + if DGD.SIDE == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + nRotZ = 90 + else + nRotZ = -90 + end + elseif DGD.SIDE == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + nRotZ = -90 + else + nRotZ = 90 + end + elseif DGD.SIDE == 'bottom' then + nRotZ = 180 + elseif DGD.SIDE == 'top' then + nRotZ = 0 + end + + if nRotZ ~= 0 then + EgtRotate( nRabbetId, ORIG(), Z_AX(), nRotZ ) + end + end + + EgtMove( nRabbetId, ptPos - ORIG()) +end + +----------------------------------------------------------------- +local function CalcCommonFramePos( sSideLk, bPushDr) + + local dPosX, dPosY, dPosZ + + if DGD.sFrame == 'L' or DGD.sFrame == 'LE' then -- se frame lock + if sSideLk == 'L' then -- se lock a sx + dPosX = DGD.dW + else + dPosX = 0 + end + dPosY = DGD.dH/2 + elseif DGD.sFrame == 'H' or DGD.sFrame == 'HE' then -- se frame hinge + if sSideLk == 'L' then -- se lock a sx + dPosX = 0 + else + dPosX = DGD.dW + end + dPosY = DGD.dH/2 + else -- se frame top o bottom + dPosX = DGD.dW / 2 + if DGD.nTypePz == 5 then -- se frame top + dPosY = 0 + else + dPosY = DGD.dH + end + end + + if bPushDr then + dPosZ = 0 + else + dPosZ = DGD.dT + end + + return dPosX, dPosY, dPosZ +end + +----------------------------------------------------------------- +local function MoveRabbet( tRabbet, sSideLk, bPushDr) + + local ptPos + local ptRef + local dPosX + local dPosY + local dPosZ + + -- per i frame la posizione della rabbet sia su lato hinge che lock portano sempre allo spesso lato + if tRabbet.side == 'hinge' then + if DGD.sFrame then + dPosX,dPosY,dPosZ = CalcCommonFramePos( sSideLk, bPushDr) + else + if sSideLk == 'R' then -- se serratura a destra + dPosX = 0 + else + dPosX = DGD.dW + end + dPosY = DGD.dH/2 + end + elseif tRabbet.side == 'lock' then + if DGD.sFrame then + dPosX,dPosY,dPosZ = CalcCommonFramePos( sSideLk, bPushDr) + else + if sSideLk == 'R' then -- se serratura a destra + dPosX = DGD.dW + else + dPosX = 0 + end + dPosY = DGD.dH/2 + end + elseif tRabbet.side == 'top' then + if DGD.sFrame then + if DGD.sFrame == 'L' or DGD.sFrame == 'LE' then -- se frame lock + if sSideLk == 'L' then -- se lock a sx + dPosX = DGD.dW + else + dPosX = 0 + end + dPosY = DGD.dH + elseif DGD.sFrame == 'H' or DGD.sFrame == 'HE' then -- se frame hinge + if sSideLk == 'L' then -- se lock a sx + dPosX = 0 + else + dPosX = DGD.dW + end + dPosY = DGD.dH + elseif DGD.nTypePz == 5 then -- se frame top + dPosX = DGD.dW + dPosY = 0 + else -- frame bottom + dPosX = DGD.dW + dPosY = DGD.dH + end + dPosZ = DGD.dT / 2 + else + dPosX = DGD.dW/2 + dPosY = DGD.dH + end + elseif tRabbet.side == 'bottom' then + if DGD.sFrame then + if DGD.sFrame == 'L' or DGD.sFrame == 'LE' then -- se frame lock + if sSideLk == 'L' then -- se lock a sx + dPosX = DGD.dW + else + dPosX = 0 + end + dPosY = 0 + elseif DGD.sFrame == 'H' or DGD.sFrame == 'HE' then -- se frame hinge + if sSideLk == 'L' then -- se lock a sx + dPosX = 0 + else + dPosX = DGD.dW + end + dPosY = 0 + elseif DGD.nTypePz == 5 then -- se frame top + dPosX = 0 + dPosY = 0 + else + dPosX = 0 + dPosY = DGD.dH + end + dPosZ = DGD.dT / 2 + else + dPosX = DGD.dW/2 + dPosY = 0 + end + end + + if not DGD.sFrame then + if bPushDr then + if tRabbet.oppo and tRabbet.oppo == 1 then + dPosZ = 0 + else + dPosZ = DGD.dT + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + dPosZ = DGD.dT + else + dPosZ = 0 + end + end + end + + if bRemake then + if bPushDr then -- se è una bevel up + if tRabbet.side and tRabbet.side == 'top' then + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorTop) + else + ptRef = EgtMP(nDoorTopTop) + end + elseif tRabbet.side and tRabbet.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorLeft) + else + ptRef = EgtMP(nDoorLeftTop) + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorRight) + else + ptRef = EgtMP(nDoorRightTop) + end + end + elseif tRabbet.side and tRabbet.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorRight) + else + ptRef = EgtMP(nDoorRightTop) + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorLeft) + else + ptRef = EgtMP(nDoorLeftTop) + end + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorBot) + else + ptRef = EgtMP(nDoorBotTop) + end + end + else -- se è bevel dw + if tRabbet.side and tRabbet.side == 'top' then + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorTopTop) + else + ptRef = EgtMP(nDoorTop) + end + elseif tRabbet.side and tRabbet.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorLeftTop) + else + ptRef = EgtMP(nDoorLeft) + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorRightTop) + else + ptRef = EgtMP(nDoorRight) + end + end + elseif tRabbet.side and tRabbet.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorRightTop) + else + ptRef = EgtMP(nDoorRight) + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorLeftTop) + else + ptRef = EgtMP(nDoorLeft) + end + end + else + if tRabbet.oppo and tRabbet.oppo == 1 then + ptRef = EgtMP(nDoorBotTop) + else + ptRef = EgtMP(nDoorBot) + end + end + end + ptPos = ptRef + else + ptPos = Point3d( dPosX, dPosY , dPosZ) + end + MoveGeomRabbet( tRabbet.geom, sSideLk, bPushDr, ptPos) + if bRemake then + if tRabbet.side and tRabbet.side == 'top' then + EgtRotate( tRabbet.geom, ptPos, Z_AX(), DGD.A5) + elseif tRabbet.side and tRabbet.side == 'hinge' then + if sSideLk == 'R' then -- se serratura a destra + EgtRotate( tRabbet.geom, ptPos, Z_AX(), (DGD.A3-90)) + else + EgtRotate( tRabbet.geom, ptPos, Z_AX(), (DGD.A8-90)) + end + elseif tRabbet.side and tRabbet.side == 'lock' then + if sSideLk == 'R' then -- se serratura a destra + EgtRotate( tRabbet.geom, ptPos, Z_AX(), (DGD.A8-90)) + else + EgtRotate( tRabbet.geom, ptPos, Z_AX(), (DGD.A3-90)) + end + else + EgtRotate( tRabbet.geom, ptPos, Z_AX(), DGD.A2) + end + end +end + +----------------------------------------------------------------- +local function MoveEPT( tEPT, sSideLk, bPushDr) + + local ptPos + local ptProbe + local ptFromExt + local ptRef + local dPosX + local dPosXProbe + local dXFromExt + local dPosY + local dPosZ = 0 + local dDeltaPos = 0 + local sDeltaPos + local nDeltaX = 0 + local nExtraAngle = 0 + local nAngleBase + local nRadBase + + if DGD.sFrame then + sSideLk = EgtIf( sSideLk == 'L', 'R', 'L') + end + + if DGD.tProfs.hingeedge.trimming == 'BD' or DGD.tProfs.hingeedge.trimming == 'BU' or + DGD.tProfs.hingeedge.trimming == 'BDEB' or DGD.tProfs.hingeedge.trimming == 'BUEB' then + nExtraAngle = 3 + nDeltaX = tEPT.back_set * TAN3 + end + + -- by DGC.Bwd setting set to 0 the nDeltaX parameter + if DGC.Bwd and DGC.Bwd == 2 then + nDeltaX = 0 + end + + sDeltaPos = EgtGetInfo( tEPT.geom, 'DeltaPos') + if sDeltaPos then + dDeltaPos = tonumber( sDeltaPos) + end + + if bRemake then + nAngleBase = atan(nDeltaX/(tEPT.position+dDeltaPos)) + nRadBase = sqrt((nDeltaX*nDeltaX)+((tEPT.position+dDeltaPos)*(tEPT.position+dDeltaPos))) + if sSideLk == 'L' then -- se serratura a sinistra + ptRef = DGD.PmaxTop + dPosY = ptRef:getY()+((tEPT.position+dDeltaPos)*sin(DGD.A7)) + else + ptRef = DGD.PminTop + dPosY = ptRef:getY()+((tEPT.position+dDeltaPos)*sin(DGD.A4)) + end + else + dPosY = DGD.dH - tEPT.position - dDeltaPos + end + + if sSideLk == 'L' then -- se serratura a sinistra: RH, RHR, ... + if DGD.sFrame then + dPosX = DGD.dW - nDeltaX - DGD.dZedExtFrame + dXFromExt = DGD.dW - DGD.dZedExtFrame + else + if bRemake then + dPosX = ptRef:getX()+(nRadBase*cos(DGD.A7-nAngleBase)) + dXFromExt = dPosX + else + dPosX = DGD.dW - nDeltaX + dXFromExt = DGD.dW + end + end + dPosXProbe = dPosX - DGD.DPR + else -- serratura a destra + if DGD.sFrame then + dPosX = nDeltaX + DGD.dZedExtFrame + dXFromExt = DGD.dZedExtFrame + else + if bRemake then + dPosX = ptRef:getX()+(nRadBase*cos(DGD.A4+nAngleBase)) + dXFromExt = dPosX + else + dPosX = nDeltaX + dXFromExt = 0 + end + end + dPosXProbe = dPosX + DGD.DPR + end + + if bPushDr then + dPosZ = tEPT.back_set + else + dPosZ = DGD.dT - tEPT.back_set + end + + ptPos = Point3d( dPosX, dPosY, dPosZ) + ptProbe = Point3d( dPosXProbe, dPosY, 0) + ptFromExt = Point3d( dXFromExt, dPosY, 0) + + MoveGeometryHng( 'ept', tEPT.geom, sSideLk, bPushDr, ptPos, nExtraAngle) + + if bRemake then + EgtRotate( tEPT.geom, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A8, DGD.A3)-90)) + end + InsertProbeGeom( tEPT.geom, ptProbe, ptFromExt, 17, 1) +end + +----------------------------------------------------------------------------------------- +-- *** Geometric processing : functions for FACE DECORATION *** +----------------------------------------------------------------------------------------- +local function MoveGeomDecoration( nGeomId, sFace, sSideLk) + + local ptPos + local ptRef + local dZedPos = 0 + local nNewEnt + + if string.lower(sFace) == 'keyway' then -- se specificato face su lato keyway (davanti) + dZedPos = DGD.dT + elseif string.lower(sFace) == 'secure' then -- se specificato face su lato secure (dietro) + -- faccio il mirror di tutte le geometrie su asse Z + nNewEnt = EgtGetFirstInGroup( nGeomId) -- ottengo nuova entità + while nNewEnt do + EgtMirror( nNewEnt, ORIG(), Z_AX()) -- faccio il mirror su asse Z + nNewEnt = EgtGetNext(nNewEnt) + end + end + + if sSideLk == 'L' then -- se serratura a sinistra + if bRemake then + ptRef = DGD.PminBot + ptPos = Point3d( ptRef:getX(), ptRef:getY(), dZedPos) + else + ptPos = Point3d( 0, 0, dZedPos) + end + else -- serratura a destra + if bRemake then + ptRef = DGD.PmaxBot + ptPos = Point3d( ptRef:getX(), ptRef:getY(), dZedPos) + else + ptPos = Point3d( DGD.dW, 0, dZedPos) + end + -- faccio il mirror di tutte le geometrie in X + nNewEnt = EgtGetFirstInGroup( nGeomId) -- ottengo nuova entità + while nNewEnt do + EgtMirror( nNewEnt, ORIG(), X_AX()) -- faccio il mirror in X + nNewEnt = EgtGetNext(nNewEnt) + end + end + + EgtMove( nGeomId, ptPos - ORIG()) + + if bRemake then + EgtRotate( nGeomId, ptPos, Z_AX(), ( EgtIf( sSideLk == 'L', DGD.A3, DGD.A8)-90)) + end +end + +----------------------------------------------------------------- +local function MoveCopyDecoration( tDecoration, sSideLk, bPushDr, bImport) + + if not tDecoration then return end + if not tDecoration.geom then return end + + local tCopyDec + + if bImport then -- se importato + -- determino posizione della decorazione + local b3Box = EgtGetBBoxGlob( tDecoration.geom, GDB_BB.STANDARD) + local dX = 0 + local dY = DGD.dH + if DGD.DFL then + dX = 0 + DGD.DFL + elseif DGD.DFH then + dX = DGD.dW - DGD.WIDTH - DGD.DFH + end + if DGD.DFT then + dY = DGD.dH - DGD.DFT + else + dY = 0 + DGD.LENGTH + DGD.DFB + end + local ptRef = Point3d( b3Box:getMin():getX(), b3Box:getMax():getY(), 0) + local ptPos = Point3d( dX, dY, 0) + -- muovo entità + local nNewEnt = EgtGetFirstInGroup( tDecoration.geom) + while nNewEnt do + EgtMove( nNewEnt, ptPos - ptRef) + -- sistemo lo spessore (negativo) + if tDecoration.depth then -- se ho spessore da ddf + EgtModifyCurveThickness( nNewEnt, -tDecoration.depth) + else -- non ho spessore + local dTh = EgtCurveThickness( nNewEnt) -- leggo spessore locale + if abs( dTh) > DGD.dT then -- se maggiore di spessore porta lo annullo + dTh = 0 + end + EgtModifyCurveThickness( nNewEnt, -abs(dTh)) + end + nNewEnt = EgtGetNext( nNewEnt) + end + -- eseguo trim con rettangolo porta aumentato di un poco + local dOffs = 20 + local frRef = Frame3d( -dOffs, -dOffs, -dOffs) + local vtDiag = Vector3d( DGD.dW + 2 * dOffs, DGD.dH + 2 * dOffs, 2 * dOffs) + nNewEnt = EgtGetFirstInGroup( tDecoration.geom) + while nNewEnt do + local nNextEnt = EgtGetNext( nNewEnt) + local nCrvId, nCnt = EgtTrimFlatCurveWithBox( nNewEnt, frRef, vtDiag, true, true, GDB_RT.GLOB) + if nCnt > 1 then + for i = 2, nCnt do + local ptStart = EgtSP( nCrvId + i - 1, nCrvId) + EgtAddCurveCompoLine( nCrvId, ptStart, true, GDB_RT.LOC) + EgtAddCurveCompoCurve( nCrvId, nCrvId + i - 1, true, true) + end + end + EgtCloseCurveCompo( nCrvId) + nNewEnt = nNextEnt + end + end + + if string.lower(DGD.FACE) == 'both' then -- se specificato su entrambe i lati faccio la copia + tCopyDec = EgtCopyGlob( tDecoration.geom, DGD.PZ) + MoveGeomDecoration( tDecoration.geom, 'secure', sSideLk) + if tCopyDec then + MoveGeomDecoration( tCopyDec, 'keyway', sSideLk) + end + else + MoveGeomDecoration( tDecoration.geom, DGD.FACE, sSideLk) + end +end + +----------------------------------------------------------------- +-- *** General Geometric Processing *** +----------------------------------------------------------------- +local function InsertSize( nTypeGeom, sSideLock, ptMedArc, dPosXHead, dAggrXPos, + dAggrYPos, dAggrBackSet, dAggrOffset, bRefXFromDoor, bRefYFromDoor, + nNumGeom) + + -- se si disegnano anche le geometrie di lavorazione esco + if DGD.MachEn > 0 then + return + end + + local dXPos + local dXPosRef + local dYPos + local dYPosRef + local dDeltaXPos + local dExtraXPos + local dExtraYPos + local dDeltaXValue + local bRigth + local bTop + local bCenter + local dBack + local dPosition + local nUp + local nRigth + + -- tipo door + if nTypeGeom == 0 then + local DoorLayerDim + if DGD.tProfs.top.radius then + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(DGD.dW,0,0), Point3d(DGD.dW,DGD.dH,0), DGD.dH, false, 0, 1, BLACK()) + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(0,0,0), Point3d(DGD.dW,0,0), DGD.dW, true, 0, 0, BLACK()) + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra), ptMedArc, DGD.tProfs.top.radius, false, 0, 0, BLACK(), true) + elseif DGD.tProfs.top.angle then + if DGD.tProfs.top.angle > 0 then + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(DGD.dW,0,0), Point3d(DGD.dW,DGD.dH,0), DGD.dH, false, 0, 1, BLACK()) + if DGD.tProfs.top.xdeltapos > 0 then + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d((DGD.dW-DGD.tProfs.top.xdeltapos),DGD.dH,0), Point3d(DGD.dW,DGD.dH,0), DGD.tProfs.top.xdeltapos, true, 1, 0, BLACK()) + end + -- quoto angolo +-- DGD.DIM_DOOR = true -- per abilitare le quote nell'EgtCam5 + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d((DGD.dW-DGD.tProfs.top.xdeltapos),DGD.dH,0), 180, DGD.tProfs.top.angle, true, 0, 1, BLACK(), false, '°', true) +-- DGD.DIM_DOOR = nil -- per abilitare le quote nell'EgtCam5 + else + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(0,0,0), Point3d(0,DGD.dH,0), DGD.dH, false, 0, 0, BLACK()) + if DGD.tProfs.top.xdeltapos > 0 then + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(0,DGD.dH,0), Point3d(DGD.tProfs.top.xdeltapos,DGD.dH,0), DGD.tProfs.top.xdeltapos, true, 1, 0, BLACK()) + end + -- quoto angolo +-- DGD.DIM_DOOR = true -- per abilitare le quote nell'EgtCam5 + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(DGD.tProfs.top.xdeltapos,DGD.dH,0), 0, DGD.tProfs.top.angle, true, 0, 1, BLACK(), false, '°', true) +-- DGD.DIM_DOOR = nil -- per abilitare le quote nell'EgtCam5 + end + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(0,0,0), Point3d(DGD.dW,0,0), DGD.dW, true, 0, 0, BLACK()) + else +-- DGD.DIM_DOOR = true -- per abilitare le quote nell'EgtCam5 + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(DGD.dW,0,0), Point3d(DGD.dW,DGD.dH,0), DGD.dH, false, 0, 1, BLACK()) + DoorLayerDim = AssignSize( DGD.PZ, DoorLayerDim, nTypePiece, 0, Point3d(0,0,0), Point3d(DGD.dW,0,0), DGD.dW, true, 0, 0, BLACK()) +-- DGD.DIM_DOOR = nil -- per abilitare le quote nell'EgtCam5 + --debug +-- if nTypePiece == 5 then +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) +-- end + end + -- tipo vision + elseif nTypeGeom == 1 then + dXPos = 0 + dYPos = EgtIf( DGD.TOP_RAIL, DGD.TOP_RAIL, DGD.CENTER_FROM_TOP) or 0 + dDeltaXPos = EgtIf( DGD.LOCK_STYLE, DGD.LOCK_STYLE, DGD.CENTER_FROM_LOCK) or 0 + nRigth = 0 + dBack = 1 + bCenter = DGD.POINTAPP == 'center' + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + dXPosRef = dXPos + if bCenter then + dXPos = DGD.dW / 2 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPosRef,DGD.dH,0), Point3d((dXPos+(dDeltaXPos*dBack)),(DGD.dH-dYPos),0), dYPos, false, 0, nRigth, GREEN()) + -- quota lock stile + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d((dXPos+(dDeltaXPos*dBack)),(DGD.dH-dYPos),0), dDeltaXPos, true, 1, nRigth, GREEN()) + elseif nTypeGeom == 2 then -- tipo louver + dXPos = 0 + dYPos = DGD.BOTTOM_RAIL + dDeltaXPos = DGD.LOCK_STYLE + nRigth = 0 + dBack = 1 + bCenter = DGD.POINTAPP == 'center' + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + dXPosRef = dXPos + if bCenter then + dXPos = DGD.dW / 2 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPosRef,0,0), Point3d((dXPos+(dDeltaXPos*dBack)),dYPos,0), dYPos, false, 0, nRigth, GREEN()) + -- quota lock stile + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,0,0), Point3d((dXPos+(dDeltaXPos*dBack)),dYPos,0), dDeltaXPos, true, 0, nRigth, GREEN()) + elseif nTypeGeom == 3 then -- tipo lock +-- DGD.DIM_LOCK = true -- per abilitare le quote nell'EgtCam5 + if not DGD.SIDE or DGD.SIDE == 'lock_top' or DGD.SIDE == 'lock_bottom' then + dXPos = 0 + nUp = 1 + nRigth = 0 + dYPos = DGD.dH + dExtraYPos = dAggrYPos or 0 + dBack = 1 + dPosition = DGD.POSITION + dAggrXPos = dAggrXPos or 0 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + if DGD.SIDE == 'lock_bottom' then + nUp = 0 + dYPos = 0 + if bRefYFromDoor then + dPosition = 0 + else + dPosition = -DGD.POSITION + end + elseif DGD.SIDE == 'lock_top' and bRefYFromDoor then + dExtraYPos = -dAggrYPos or 0 + dPosition = 0 + end + if not nNumGeom or nNumGeom == 1 then + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d(dXPos,dYPos-dPosition,0), DGD.POSITION, false, nUp, nRigth, RED()) + end + -- quota backset + local dLocBackSet = DGD.BACK_SET + if dAggrBackSet then + dLocBackSet = dAggrBackSet + end + -- se offset Y presente + if abs(dExtraYPos) > 0 then + local dOffsPoint = 0 + if abs(dAggrXPos) > 0 then + -- se riferimengo globale in X quoto + if bRefXFromDoor then + dOffsPoint = dAggrXPos * EgtIf( sSideLock ~= 'L', 1, -1) + else + dOffsPoint = (dAggrXPos + dLocBackSet) * EgtIf( sSideLock ~= 'L', 1, -1) + end + end + -- se riferito a lato top-bottom + if bRefYFromDoor then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d(dXPos-dOffsPoint,dYPos+dExtraYPos,0), abs(dExtraYPos), false, nUp, nRigth, Color3d(64,128,128)) + else + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos-dPosition,0), Point3d(dXPos-dOffsPoint,dYPos-dPosition+dExtraYPos,0), abs(dExtraYPos), false, nUp, nRigth, Color3d(64,128,128)) + end + end + -- se riferimengo globale in X quoto + if bRefXFromDoor then + -- se offset esistente + if abs(dAggrXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos-dPosition+dExtraYPos,0), Point3d((dXPos+(dAggrXPos*dBack)), dYPos-dPosition+dExtraYPos,0), abs(dAggrXPos), true, -1, nRigth, Color3d(64,128,128), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + end + else + if dLocBackSet and dLocBackSet > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos-dPosition+dExtraYPos,0), Point3d((dXPos+(dLocBackSet*dBack)), dYPos-dPosition+dExtraYPos,0), dLocBackSet, true, -1, nRigth, RED(), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + end + -- se offset esistente + if abs(dAggrXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d((dXPos+(dLocBackSet*dBack)),dYPos-dPosition+dExtraYPos,0), Point3d((dXPos+((dLocBackSet+dAggrXPos)*dBack)), dYPos-dPosition+dExtraYPos,0), abs(dAggrXPos), true, -1, nRigth, Color3d(64,128,128), nil, EgtIf( not dLocBackSet or dLocBackSet == 0, '*', nil)) + end + end + elseif DGD.SIDE == 'top' then + dXPos = 0 + nUp = 1 + nRigth = 0 + dYPos = DGD.dH + dExtraXPos = dAggrXPos + dPosition = DGD.POSITION + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dPosition = -DGD.POSITION + dExtraXPos = -dAggrXPos + dBack = -1 + end + if not nNumGeom or nNumGeom == 1 then + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dPosition),dYPos,0), DGD.POSITION, true, nUp, false, RED()) + end + -- quota backset + local dLocBackSet = DGD.BACK_SET + if dAggrBackSet then + dLocBackSet = dAggrBackSet + end + -- se offset X presente + if dExtraXPos and abs(dExtraXPos) > 0 then + local dOffsPoint = 0 + if dAggrYPos and abs(dAggrYPos) > 0 then + -- se riferimengo globale in Y quoto + if bRefYFromDoor then + dOffsPoint = -dAggrYPos + else + dOffsPoint = -dLocBackSet+dAggrYPos + end + end + -- se riferito a lato lock + if bRefXFromDoor then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dExtraXPos),dYPos+dOffsPoint,0), abs(dExtraXPos), true, nUp, false, Color3d(64,128,128), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + else + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+dPosition,dYPos,0), Point3d((dXPos+dPosition+dExtraXPos),dYPos+dOffsPoint,0), abs(dExtraXPos), true, nUp, false, Color3d(64,128,128)) + end + end + -- riassegno la posizione in base al flag di riferimento posizione globale in X + if bRefXFromDoor then + dPosition = 0 + else + dPosition = DGD.POSITION + end + -- se riferimengo globale in Y quoto + if bRefYFromDoor then + -- se offset esistente + if dExtraXPos and abs(dExtraXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos-dAggrYPos,0), abs(dAggrYPos), false, -1, -1, Color3d(64,128,128)) + end + else + -- se quota backset maggiore di 0 + if dLocBackSet and dLocBackSet > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos-dLocBackSet,0), dLocBackSet, false, -1, -1, RED()) + end + -- se offset esistente + if dExtraXPos and abs(dExtraXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos-dLocBackSet,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos-dLocBackSet+dAggrYPos,0), abs(dAggrYPos), false, -1, -1, Color3d(64,128,128)) + end + end + -- quota offset (solo sui frame) + local dLocOffset = DGD.OFFSET + if dAggrOffset then + dLocOffset = dAggrOffset + end + if dLocOffset and dLocOffset > 0 and nTypePiece > 2 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(DGD.POSITION*dBack), 0, -DGD.dH), Point3d(dXPos+(DGD.POSITION*dBack), dLocOffset, -DGD.dH), dLocOffset, false, -1, -1, RED(), nil, nil, nil, GDB_FR.FRONT) + end + elseif DGD.SIDE == 'bottom' then + dXPos = 0 + nUp = 0 + nRigth = 0 + dYPos = 0 + dExtraXPos = dAggrXPos + dPosition = DGD.POSITION + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dPosition = -DGD.POSITION + dExtraXPos = -dAggrXPos + dBack = -1 + end + if not nNumGeom or nNumGeom == 1 then + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dPosition),dYPos,0), DGD.POSITION, true, nUp, false, RED()) + end + -- quota backset + local dLocBackSet = DGD.BACK_SET + if dAggrBackSet then + dLocBackSet = dAggrBackSet + end + -- se offset X presente + if dExtraXPos and abs(dExtraXPos) > 0 then + local dOffsPoint = 0 + if dAggrYPos and abs(dAggrYPos) > 0 then + -- se riferimengo globale in Y quoto + if bRefYFromDoor then + dOffsPoint = dAggrYPos + else + dOffsPoint = dLocBackSet+dAggrYPos + end + end + -- se riferito a lato lock + if bRefXFromDoor then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dExtraXPos),dYPos+dOffsPoint,0), abs(dExtraXPos), true, nUp, false, Color3d(64,128,128), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + else + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+dPosition,dYPos,0), Point3d((dXPos+dPosition+dExtraXPos),dYPos+dOffsPoint,0), abs(dExtraXPos), true, nUp, false, Color3d(64,128,128)) + end + end + -- riassegno la posizione in base al flag di riferimento posizione globale in X + if bRefXFromDoor then + dPosition = 0 + else + dPosition = DGD.POSITION + end + -- se riferimengo globale in Y quoto + if bRefYFromDoor then + -- se offset esistente + if dExtraXPos and abs(dExtraXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos+dAggrYPos,0), abs(dAggrYPos), false, -1, -1, Color3d(64,128,128)) + end + else + -- se quota backset maggiore di 0 + if dLocBackSet and dLocBackSet > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos+dLocBackSet,0), dLocBackSet, false, -1, -1, RED()) + end + -- se quota esistente + if dExtraXPos and abs(dExtraXPos) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos+dLocBackSet,0), Point3d(dXPos+(dPosition*dBack)+dExtraXPos,dYPos+dLocBackSet+dAggrYPos,0), abs(dAggrYPos), false, -1, -1, Color3d(64,128,128)) + end + end + -- quota offset (solo sui frame) + local dLocOffset = DGD.OFFSET + if dAggrOffset then + dLocOffset = dAggrOffset + end + if dLocOffset and dLocOffset > 0 and nTypePiece > 2 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos+(DGD.POSITION*dBack),dYPos,0), Point3d(dXPos+(DGD.POSITION*dBack),dYPos+dLocOffset,0), dLocOffset, false, -1, -1, RED(), nil, nil, nil, GDB_FR.FRONT) + end + end +-- DGD.DIM_LOCK = nil -- per abilitare le quote nell'EgtCam5 + --debug +-- if nTypePiece == 5 then +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) +-- end + elseif nTypeGeom == 5 then -- tipo hinge + dXPos = 0 + nRigth = 0 + if sSideLock == 'L' then + dXPos = DGD.dW + nRigth = 1 + end + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.POSITION,0), DGD.POSITION, false, 0, nRigth, BLUE()) + elseif nTypeGeom == 6 then -- tipo mail_slot + dXPos = DGD.dW + dYPos = DGD.BOTTOM_RAIL + dDeltaXPos = DGD.DELTA_CENTER + dDeltaXValue = DGD.DELTA_CENTER + nRigth = 1 + dBack = 1 + if sSideLock ~= 'L' then + dXPos = 0 + dDeltaXPos = -DGD.DELTA_CENTER + nRigth = 0 + dBack = -1 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,0,0), Point3d(((DGD.dW/2)+dDeltaXPos),dYPos,0), dYPos, false, 0, nRigth, GREEN()) + -- quota delta_center + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d((DGD.dW/2),0,0), Point3d(((DGD.dW/2)+dDeltaXPos),dYPos,0), dDeltaXValue, true, 0, nRigth, GREEN()) + elseif nTypeGeom == 7 then -- tipo flush_pull + dXPos = 0 + nRigth = 0 + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.POSITION,0), DGD.POSITION, false, 0, nRigth, {221,0,0,100}) + -- quota backset + if DGD.BACK_SET and DGD.BACK_SET > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH-DGD.POSITION,0), Point3d((dXPos+(DGD.BACK_SET*dBack)),DGD.dH-DGD.POSITION,0), DGD.BACK_SET, true, -1, bRigth, {221,0,0,100}) + end + elseif nTypeGeom == 8 then -- tipo viewer + dXPos = DGD.dW + dYPos = DGD.BOTTOM_RAIL + dDeltaXPos = DGD.DELTA_CENTER + dDeltaXValue = DGD.DELTA_CENTER + nRigth = 1 + bTop = DGD.SIDE and DGD.SIDE == 'top' + dBack = 1 + if sSideLock ~= 'L' then + dXPos = 0 + dDeltaXPos = -DGD.DELTA_CENTER + nRigth = 0 + dBack = -1 + end + if not bTop then + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,0,0), Point3d(((DGD.dW/2)+dDeltaXPos),dYPos,0), dYPos, false, 0, nRigth, GREEN()) + -- quota delta_center + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d((DGD.dW/2),0,0), Point3d(((DGD.dW/2)+dDeltaXPos),dYPos,0), dDeltaXValue, true, 0, nRigth, GREEN()) + else + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(((DGD.dW/2)+dDeltaXPos),(DGD.dH-dYPos),0), dYPos, false, 0, nRigth, GREEN()) + -- quota delta_center + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d((DGD.dW/2),DGD.dH,0), Point3d(((DGD.dW/2)+dDeltaXPos),(DGD.dH-dYPos),0), dDeltaXValue, true, 1, nRigth, GREEN()) + end + elseif nTypeGeom == 9 then -- tipo rollerlatch + if DGD.SIDE == 'lock' then + dXPos = 0 + nUp = 0 + nRigth = 0 + dYPos = DGD.dH + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d(dXPos,dYPos-DGD.POSITION,0), DGD.POSITION, false, nUp, nRigth, {17,255,17,100}) + else + dXPos = 0 + nUp = 1 + dYPos = DGD.dH + dPosition = DGD.POSITION + if sSideLock ~= 'L' then + dXPos = DGD.dW + dPosition = -DGD.POSITION + end + if DGD.SIDE ~= 'top' then + dYPos = 0 + nUp = 0 + end + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dPosition),dYPos,0), DGD.POSITION, true, nUp, false, {17,255,17,100}) + end + elseif nTypeGeom == 10 then -- tipo edgepull + dXPos = 0 + nRigth = 0 + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.POSITION,0), DGD.POSITION, false, 0, nRigth, {193,0,0,100}) + -- quota backset + if DGD.BACK_SET and DGD.BACK_SET > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH-DGD.POSITION,0), Point3d((dXPos+(DGD.BACK_SET*dBack)),DGD.dH-DGD.POSITION,0), DGD.BACK_SET, true, -1, nRigth, RED(), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + end + elseif nTypeGeom == 11 then -- tipo flushbolt + -- quoto solo gli extension + if string.lower(DGD.TYPE) == 'extension' then + dXPos = 0 + dYPos = DGD.dH + nRigth = 0 + dBack = 1 + nUp = 1 + dPosition = DGD.POSITION + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + if DGD.SIDE ~= 'top' then + dYPos = 0 + nUp = 0 + dPosition = -DGD.POSITION + end + -- quota top/bottom position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d(dXPos,dYPos-dPosition,0), DGD.POSITION, false, 0, nRigth, {147,0,0,100}) + -- se presente cava di testa + if abs(dPosXHead) > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+(dPosXHead*dBack)),dYPos,0), dPosXHead, true, nUp, nRigth, {147,0,0,100}, nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + end + end + elseif nTypeGeom == 12 then -- tipo pivot + -- se tipo center hung o offset + if string.lower(DGD.TYPE) ~= 'offsetintermediate' then + dXPos = 0 + dYPos = DGD.dH + nUp = 1 + dPosition = DGD.POSITION + if sSideLock == 'L' then + dXPos = DGD.dW + dPosition = -DGD.POSITION + end + if DGD.SIDE ~= 'top' then + dYPos = 0 + nUp = 0 + end + -- quota top/bottom position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,dYPos,0), Point3d((dXPos+dPosition),dYPos,0), DGD.POSITION, true, nUp, false, {255,0,128,100}) + else -- tipo offsetintermediate + dXPos = 0 + nRigth = 0 + if sSideLock == 'L' then + dXPos = DGD.dW + nRigth = 1 + end + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.POSITION,0), DGD.POSITION, false, 0, nRigth, {255,0,128,100}) + end + elseif nTypeGeom == 14 then -- tipo strike + dXPos = 0 + nRigth = 0 + dBack = 1 + if sSideLock ~= 'L' then + dXPos = DGD.dW + nRigth = 1 + dBack = -1 + end + -- quota position + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.POSITION,0), DGD.POSITION, false, 0, nRigth, RED()) + -- quota backset + if DGD.BACK_SET and DGD.BACK_SET > 0 then + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH-DGD.POSITION,0), Point3d((dXPos+(DGD.BACK_SET*dBack)),DGD.dH-DGD.POSITION,0), DGD.BACK_SET, true, -1, nRigth, RED(), nil, EgtIf( not DGC.Bwd or DGC.Bwd == 0, '*', nil)) + end + elseif nTypeGeom == 17 then -- tipo ept + dXPos = 0 + nRigth = 0 + if sSideLock == 'L' then + dXPos = DGD.dW + nRigth = 1 + end + DGD.tSizeLayer[nTypeGeom] = AssignSize( DGD.PZ, DGD.tSizeLayer[nTypeGeom], nTypePiece, nTypeGeom, Point3d(dXPos,DGD.dH,0), Point3d(dXPos,DGD.dH-DGD.TOPTOCL,0), DGD.TOPTOCL, false, 0, nRigth, {0,0,164,100}) + end +end + + +----------------------------------------------------------------- +local function InsertGeom( tGeometries, sSideLock, bPushDoor, sTypeGeom) + + local nCont = 1 + local sFileExt + local sFileName + local sFilePath + local nErr, sErr + local bBox + local sPathLua + local sSubPath + local nTypeGeom + local bImport + local sImportType + local nGeomId + + if not sTypeGeom then + return false + elseif string.lower(sTypeGeom) == 'vision' then + sSubPath = 'Compo\\VisionCutOuts\\' + nTypeGeom = 1 + elseif string.lower(sTypeGeom) == 'louver' then + sSubPath = 'Compo\\LouverCutOuts\\' + nTypeGeom = 2 + elseif string.lower(sTypeGeom) == 'lock' then + sSubPath = 'Compo\\Locks\\' + nTypeGeom = 3 + elseif string.lower(sTypeGeom) == 'stopandcloser' then + sSubPath = 'Compo\\StopsAndClosers\\' + nTypeGeom = 4 + elseif string.lower(sTypeGeom) == 'hinge' then + sSubPath = 'Compo\\Hinges\\' + nTypeGeom = 5 + elseif string.lower(sTypeGeom) == 'mail' then + sSubPath = 'Compo\\MailSlots\\' + nTypeGeom = 6 + elseif string.lower(sTypeGeom) == 'flush' then + sSubPath = 'Compo\\FlushPulls\\' + nTypeGeom = 7 + elseif string.lower(sTypeGeom) == 'viewer' then + sSubPath = 'Compo\\Viewers\\' + nTypeGeom = 8 + elseif string.lower(sTypeGeom) == 'rollerlatch' then + sSubPath = 'Compo\\RollerLatchs\\' + nTypeGeom = 9 + elseif string.lower(sTypeGeom) == 'edgepull' then + sSubPath = 'Compo\\EdgePulls\\' + nTypeGeom = 10 + elseif string.lower(sTypeGeom) == 'flushbolt' then + sSubPath = 'Compo\\FlushBolts\\' + nTypeGeom = 11 + elseif string.lower(sTypeGeom) == 'pivot' then + sSubPath = 'Compo\\Pivots\\' + nTypeGeom = 12 + elseif string.lower(sTypeGeom) == 'overhead' then + sSubPath = 'Compo\\OverHeads\\' + nTypeGeom = 13 + elseif string.lower(sTypeGeom) == 'strike' then + sSubPath = 'Compo\\Strikes\\' + nTypeGeom = 14 + elseif string.lower(sTypeGeom) == 'groove' then + sSubPath = 'Compo\\Groove\\' + nTypeGeom = 15 + elseif string.lower(sTypeGeom) == 'rabbet' then + sSubPath = 'Compo\\Rabbets\\' + nTypeGeom = 16 + elseif string.lower(sTypeGeom) == 'ept' then + sSubPath = 'Compo\\Epts\\' + nTypeGeom = 17 + elseif string.lower(sTypeGeom) == 'facedecoration' then + sSubPath = 'Compo\\FaceDecoration\\' + nTypeGeom = 18 + end + + while nCont <= #tGeometries do + + if nTypeGeom == 1 then -- se vision + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].shape + DGD.SPLIT = tGeometries[nCont].split + DGD.DIR = tGeometries[nCont].dir + if tGeometries[nCont].split or ( tGeometries[nCont].length and tGeometries[nCont].width) then + DGD.LENGTH = tGeometries[nCont].length + DGD.WIDTH = tGeometries[nCont].width + DGD.TOP_RAIL = tGeometries[nCont].top_rail + DGD.LOCK_STYLE = tGeometries[nCont].lock_stile + DGD.POINTAPP = tGeometries[nCont].door_center + DGD.RADIUS = tGeometries[nCont].radius + -- se split è assente + elseif tGeometries[nCont].split == nil then + -- setto anche variabili lunghezza e larghezza che sono a nil per evitare di mantenere precedenti settaggi delle stesse variabili + DGD.LENGTH = tGeometries[nCont].length + DGD.WIDTH = tGeometries[nCont].width + DGD.RADIUS = tGeometries[nCont].radius + DGD.CENTER_FROM_TOP = tGeometries[nCont].center_from_top + DGD.CENTER_FROM_LOCK = tGeometries[nCont].center_from_lock + DGD.POINTAPP = tGeometries[nCont].door_center + end + elseif nTypeGeom == 2 then -- se louver + if not tGeometries[nCont].shape then -- se non ho shape lancio il rect di default + sPathLua = sBaseDir .. sSubPath .. 'rect' -- con il louver c'è solo una forma rettangolare + else + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].shape + end + if tGeometries[nCont].length and tGeometries[nCont].width then + DGD.LENGTH = tGeometries[nCont].length + DGD.WIDTH = tGeometries[nCont].width + DGD.BOTTOM_RAIL = tGeometries[nCont].bottom_rail + DGD.LOCK_STYLE = tGeometries[nCont].lock_stile + DGD.POINTAPP = tGeometries[nCont].door_center + end + elseif nTypeGeom == 3 then -- se lock + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.POSITION = tGeometries[nCont].position + DGD.OFFSET = tGeometries[nCont].offset + DGD.SIDE = tGeometries[nCont].side + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 4 then -- se stop_and_closer + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.POSITION = tGeometries[nCont].position + DGD.POCKET_OFFSET = tGeometries[nCont].pocket_offset + DGD.SIDE = tGeometries[nCont].side + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 5 then -- se hinge + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.THICKNESS = tGeometries[nCont].thickness + DGD.POSITION = tGeometries[nCont].position + elseif nTypeGeom == 6 then -- se mail_slot + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.LENGTH = tGeometries[nCont].length + DGD.BOTTOM_RAIL = tGeometries[nCont].bottom_rail + DGD.DELTA_CENTER = tGeometries[nCont].delta_center + elseif nTypeGeom == 7 then -- se flush_pull + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.POSITION = tGeometries[nCont].position + DGD.DEPTH = tGeometries[nCont].depth + DGD.FACE = tGeometries[nCont].face + elseif nTypeGeom == 8 then -- se viewer + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.BOTTOM_RAIL = tGeometries[nCont].bottom_rail + DGD.DELTA_CENTER = tGeometries[nCont].delta_center + DGD.SIDE = tGeometries[nCont].side + elseif nTypeGeom == 9 then -- se roller_latch + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.SIDE = tGeometries[nCont].side + DGD.POSITION = tGeometries[nCont].position + DGD.OFFSET = tGeometries[nCont].offset + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 10 then -- se edge_pull + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.POSITION = tGeometries[nCont].position + DGD.OFFSET = tGeometries[nCont].offset + elseif nTypeGeom == 11 then -- se flush_bolt + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.TYPE = tGeometries[nCont].type + DGD.SIDE = tGeometries[nCont].side + DGD.POSITION = tGeometries[nCont].position + DGD.OFFSET = tGeometries[nCont].offset + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 12 then -- se pivot + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.TYPE = tGeometries[nCont].type + DGD.SIDE = tGeometries[nCont].side + DGD.RADIUS = tGeometries[nCont].radius + DGD.POSITION = tGeometries[nCont].position + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.DEPTH_F = tGeometries[nCont].depth_f + DGD.OFFSET = tGeometries[nCont].offset + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 13 then -- se overhead + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.POCKPOS = tGeometries[nCont].pockpos + DGD.POCKLENGTH = tGeometries[nCont].pocklength + DGD.POCKET_OFFSET = tGeometries[nCont].pocket_offset + DGD.ARMPOS = tGeometries[nCont].armpos + DGD.ARMLENGTH = tGeometries[nCont].armlength + DGD.SIDE = tGeometries[nCont].side + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 14 then -- se strike + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.BACK_SET = tGeometries[nCont].back_set + DGD.POSITION = tGeometries[nCont].position + DGD.OFFSET = tGeometries[nCont].offset + DGD.OTHERD = tGeometries[nCont].other_door + elseif nTypeGeom == 15 then -- se groove + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.TYPE = tGeometries[nCont].type + DGD.SIDE = tGeometries[nCont].side + DGD.FST = tGeometries[nCont].fst + DGD.HST = tGeometries[nCont].hst + DGD.LST = tGeometries[nCont].lst + if DGD.SIDE == 'hinge' or DGD.SIDE == 'lock' then + if bRemake then + if DGD.SIDE == 'lock' then + DGD.LENGTH = EgtIf( sSideLock == 'L', max(DGD.L2Top,DGD.L2), max(DGD.L4Top,DGD.L4)) + else + DGD.LENGTH = EgtIf( sSideLock == 'L', max(DGD.L4Top,DGD.L4), max(DGD.L2Top,DGD.L2)) + end + else + DGD.LENGTH = DGD.dH -- setto come altezza porta + end + if DGD.HST and DGD.LST and DGD.TYPE == 'center' then + DGD.LENGTH = DGD.LENGTH - DGD.HST - DGD.LST + end + else + if bRemake then + if DGD.SIDE == 'top' or DGD.SIDE == 'top_angle' or DGD.SIDE == 'top_flat' then + DGD.LENGTH = max(DGD.L3Top,DGD.L3) + else + DGD.LENGTH = max(DGD.L1Top,DGD.L1) + end + else + -- se lato top ed è ad angoolo ricalcolo il lato + if ( DGD.SIDE == 'top_flat' or DGD.SIDE == 'top_angle') and DGD.Tpa then + -- se devo applicare il groove su lato diritto corto + if DGD.SIDE == 'top_flat' then + -- se lunghezza lato dritto esiste + if DGD.tProfs.top.xdeltapos > 0 then + DGD.LENGTH = DGD.tProfs.top.xdeltapos + else + DGD.LENGTH = DGD.dW -- setto di base come larghezza porta + end + -- altrimenti è da applicare su lato inclinato + else + if ( DGD.dW - DGD.tProfs.top.xdeltapos) > 0 then + DGD.LENGTH = ( DGD.dW - DGD.tProfs.top.xdeltapos) / cos(abs(DGD.tProfs.top.angle)) + else + DGD.LENGTH = DGD.dW -- setto di base come larghezza porta + end + end + else + DGD.LENGTH = DGD.dW -- setto di base come larghezza porta + end + end + DGD.SIDELENGTH = DGD.LENGTH + if DGD.HST and DGD.LST then + -- se lato top ed è ad angoolo ed è presente lato piano ricalcolo il lato +-- if DGD.SIDE == 'top_flat' and DGD.Tpa and DGD.tProfs.top.xdeltapos > 0 then +-- -- se parte angolata sulla parte sinistra +-- if DGD.tProfs.top.angle > 0 then +-- -- se lato losk a sinsitra +-- if DGD.Lock == 'L' then +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.HST +-- DGD.LST = 0 +-- else +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.LST +-- DGD.HST = 0 +-- end +-- -- altrimenti parte angolata sulla parte destra +-- else +-- -- se lato losk a sinsitra +-- if DGD.Lock == 'L' then +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.LST +-- DGD.HST = 0 +-- else +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.HST +-- DGD.LST = 0 +-- end +-- end +-- elseif DGD.SIDE == 'top_angle' and DGD.Tpa and ( DGD.dW - DGD.tProfs.top.xdeltapos) > 0 then +-- -- se parte angolata sulla parte sinistra +-- if DGD.tProfs.top.angle > 0 then +-- -- se lato losk a sinsitra +-- if DGD.Lock == 'L' then +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.LST +-- DGD.HST = 0 +-- else +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.HST +-- DGD.LST = 0 +-- end +-- -- altrimenti parte angolata sulla parte destra +-- else +-- -- se lato losk a sinsitra +-- if DGD.Lock == 'L' then +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.HST +-- DGD.LST = 0 +-- else +-- -- ricalcolo il lato +-- DGD.LENGTH = DGD.LENGTH - DGD.LST +-- DGD.HST = 0 +-- end +-- end +-- else + DGD.LENGTH = DGD.LENGTH - DGD.HST - DGD.LST +-- end + end + -- se larghezza porta è large width setto flag + if DGD.Part and DGD.Part > 0 and DGD.dW > DGD.Part then + DGD.bPart = true + end + end + if DGD.FST then + tGeometries[nCont].width = DGD.dT - DGD.FST - DGD.FST + end + DGD.WIDTH = tGeometries[nCont].width + DGD.DEPTH = tGeometries[nCont].depth + DGD.GROOVE_OFFSET = tGeometries[nCont].groove_offset + elseif nTypeGeom == 16 then -- se rabbet + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.SIDE = tGeometries[nCont].side + if DGD.SIDE == 'hinge' or DGD.SIDE == 'lock' then + if bRemake then + if DGD.SIDE == 'lock' then + DGD.LENGTH = EgtIf( sSideLock == 'L', max(DGD.L2Top,DGD.L2), max(DGD.L4Top,DGD.L4)) + else + DGD.LENGTH = EgtIf( sSideLock == 'L', max(DGD.L4Top,DGD.L4), max(DGD.L2Top,DGD.L2)) + end + else + DGD.LENGTH = DGD.dH -- setto come altezza porta + end + else + if bRemake then + if DGD.SIDE == 'top' then + DGD.LENGTH = max(DGD.L3Top,DGD.L3) + else + DGD.LENGTH = max(DGD.L1Top,DGD.L1) + end + else + DGD.LENGTH = DGD.dW -- setto di base come larghezza porta + end + -- se larghezza porta è large width setto flag + if DGD.Part and DGD.Part > 0 and DGD.dW > DGD.Part then + DGD.bPart = true + end + end + DGD.WIDTH = tGeometries[nCont].width + DGD.DEPTH = tGeometries[nCont].depth + DGD.ANGLE = tGeometries[nCont].angle + DGD.OPPO = tGeometries[nCont].oppo + elseif nTypeGeom == 17 then -- se ept + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.FACETOCL = tGeometries[nCont].back_set + DGD.TOPTOCL = tGeometries[nCont].position + elseif nTypeGeom == 18 then -- se facedecoration + sPathLua = sBaseDir .. sSubPath .. tGeometries[nCont].template + DGD.TYPE = tGeometries[nCont].type + DGD.DEPTH = tGeometries[nCont].depth + DGD.DFT = tGeometries[nCont].dft + DGD.DFB = tGeometries[nCont].dfb + DGD.DFL = tGeometries[nCont].dfl + DGD.DFH = tGeometries[nCont].dfh + DGD.FACE = tGeometries[nCont].face + end + + -- Controllo se nel nome file è già presente l'estensione .nge + sFilePath,sFileName,sFileExt = EgtSplitPath( string.lower(sPathLua)) + bImport = false + + -- se trovata estensione .nge nel template + if sFileExt and sFileExt == '.nge' then + sImportType = 'nge' + else -- non contiene direttamente estensione nge + if EgtExistsFile( string.lower(sPathLua)..'.lua') then-- provo con lua + sImportType = 'lua' + elseif EgtExistsFile( string.lower(sPathLua)..'.nge') then -- provo con nge + sImportType = 'nge' + sFileExt = '.nge' + else -- altrimenti tipo non riconosciuto + sImportType = 'bad' + end + end + + -- in base al tipo lancio l'import, o il componente lua o do errore + if sImportType == 'nge' then + + local sPathNge = sBaseDir .. 'LuaLibs\\ImportNgeFile.lua' + -- compongo il parametro nomefile + sFileName = sFileName .. sFileExt + local MHgen = require('ImportNgeFile') + nErr, sErr, nGeomId = MHgen.Draw( sFilePath,sFileName) + + if nErr == 0 and nGeomId then + + -- in base al tipo ri-setto le dimensioni di ingombro della geometria importata + if nTypeGeom == 1 or nTypeGeom == 2 or nTypeGeom == 18 then -- se vision o louver o decoration + bBox = EgtGetBBox( nGeomId, 0) + tGeometries[nCont].length = bBox:getDimY(bBox) + tGeometries[nCont].width = bBox:getDimX(bBox) + DGD.LENGTH = tGeometries[nCont].length + DGD.WIDTH = tGeometries[nCont].width + elseif nTypeGeom == 6 then -- se mail slot + bBox = EgtGetBBox( nGeomId, 0) + tGeometries[nCont].length = bBox:getDimY(bBox) + DGD.LENGTH = tGeometries[nCont].length + end + bImport = true + end + elseif sImportType == 'lua' then -- componente lua + sPathLua = sPathLua .. '.lua' + nErr, sErr, nGeomId = dofile( sPathLua) + else + nErr = 1000 + sErr = string.format(EgtDoorsMsg[411],sPathLua, DGD.FILE) + end + + if nErr > 0 then + DoorOutLog( sErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sErr + if DGD.ERR <= 0 then DGD.ERR = nErr end + break + else + -- se presente messaggio di warning + if nErr < 0 then + DoorOutLog( sErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sErr + if DGD.ERR == 0 then DGD.ERR = nErr end + end + + --debug +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- posizionamento geometria + -- tipo vision + if nTypeGeom == 1 then + if DGD.SPLIT then + if DGD.LENGTH and tGeometries[nCont].length and abs( DGD.LENGTH - tGeometries[nCont].length) > GEO.EPS_SMALL then + tGeometries[nCont].length = DGD.LENGTH + end + if DGD.WIDTH and tGeometries[nCont].width and abs( DGD.WIDTH - tGeometries[nCont].width) > GEO.EPS_SMALL then + tGeometries[nCont].width = DGD.WIDTH + end + end + tGeometries[nCont].geom = nGeomId + MoveCutOuts( tGeometries[nCont], sSideLock, bPushDoor, bImport, nTypeGeom) + -- vision sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 2 then -- tipo louver + tGeometries[nCont].geom = nGeomId + MoveCutOuts( tGeometries[nCont], sSideLock, bPushDoor, bImport, nTypeGeom) + -- louver sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 3 then -- tipo lock + -- verifico se è un aggregato + local sType = type(nGeomId) + if sType == 'table' then + if #nGeomId >= 1 then + for k = 1, #nGeomId do + tGeometries[nCont].geom = nGeomId[k][1] + tGeometries[nCont].back_set = nGeomId[k][2] + tGeometries[nCont].offset = nGeomId[k][3] + MoveLock( tGeometries[nCont], sSideLock, bPushDoor) + -- lock sizing + InsertSize( nTypeGeom, sSideLock, nil, nil, nGeomId[k][4], + nGeomId[k][5], nGeomId[k][2], nGeomId[k][3], nGeomId[k][6], nGeomId[k][7], + k) + end + end + else + tGeometries[nCont].geom = nGeomId + MoveLock( tGeometries[nCont], sSideLock, bPushDoor) + -- lock sizing + InsertSize( nTypeGeom, sSideLock, nil, nil, 0, 0) + end + elseif nTypeGeom == 4 then -- tipo stop_and_closer + -- verifico se è un aggregato + local sType = type(nGeomId) + if sType == 'table' then + if #nGeomId >= 1 then + for k = 1, #nGeomId do + tGeometries[nCont].geom = nGeomId[k] + MoveStopAndCloser( tGeometries[nCont], sSideLock, bPushDoor) + end + end + else + tGeometries[nCont].geom = nGeomId + MoveStopAndCloser( tGeometries[nCont], sSideLock, bPushDoor) + end + elseif nTypeGeom == 5 then -- tipo hinge + tGeometries[nCont].geom = nGeomId + MoveHinge( tGeometries[nCont], sSideLock, bPushDoor) + -- hinge sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 6 then -- tipo mail_slot + tGeometries[nCont].geom = nGeomId + MoveCutOuts( tGeometries[nCont], sSideLock, bPushDoor, bImport, nTypeGeom) + -- mail slot sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 7 then -- tipo flush_pull + tGeometries[nCont].geom = nGeomId + MoveFlushPull( tGeometries[nCont], sSideLock, bPushDoor, bImport) + -- flush_pull sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 8 then -- tipo viewer + tGeometries[nCont].geom = nGeomId + MoveViewer( tGeometries[nCont], sSideLock, bPushDoor) + -- viewer sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 9 then -- tipo rollerlatch + tGeometries[nCont].geom = nGeomId + MoveRollerLatch( tGeometries[nCont], sSideLock, bPushDoor) + -- roller latch sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 10 then -- tipo edgepull + tGeometries[nCont].geom = nGeomId + MoveEdgePull( tGeometries[nCont], sSideLock, bPushDoor) + -- EdgePull sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 11 then -- tipo flushbolt + tGeometries[nCont].geom = nGeomId + MoveFlushBolt( tGeometries[nCont], sSideLock, bPushDoor) + -- FlushBolt sizing + local dPosHead = 0 + if string.lower(DGD.TYPE) == 'extension' then + -- ricavo nota spostamento cava di testa + dPosHead = EgtGetInfo( tGeometries[nCont].geom, 'DB_X', 'd') or 0 + end + InsertSize( nTypeGeom, sSideLock, nil, dPosHead) + elseif nTypeGeom == 12 then -- tipo pivot + tGeometries[nCont].geom = nGeomId + MovePivot( tGeometries[nCont], sSideLock, bPushDoor) + -- Pivot sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 13 then -- tipo overhead + tGeometries[nCont].geom = nGeomId + MoveOverHead( tGeometries[nCont], sSideLock, bPushDoor) + elseif nTypeGeom == 14 then -- tipo strike + tGeometries[nCont].geom = nGeomId + MoveStrike( tGeometries[nCont], sSideLock, bPushDoor) + -- Strike sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 15 then -- tipo groove + tGeometries[nCont].geom = nGeomId + MoveGroove( tGeometries[nCont], sSideLock, bPushDoor) + elseif nTypeGeom == 16 then -- tipo rabbet + tGeometries[nCont].geom = nGeomId + MoveRabbet( tGeometries[nCont], sSideLock, bPushDoor) + elseif nTypeGeom == 17 then -- tipo ept + tGeometries[nCont].geom = nGeomId + MoveEPT( tGeometries[nCont], sSideLock, bPushDoor) + -- EPT sizing + InsertSize( nTypeGeom, sSideLock) + elseif nTypeGeom == 18 then -- tipo facedecoration + tGeometries[nCont].geom = nGeomId + MoveCopyDecoration( tGeometries[nCont], sSideLock, bPushDoor, bImport) + end + end + + nCont = nCont + 1 + end +end + +----------------------------------------------------------------- +local function SubAndDeleteTempSurf( nIdLs) + + local nIdSurf + local sSurfName + local nIdSurfUp + local nIdSurfDw + local nIdSurfTmpUp + local nIdSurfTmpDw + local bFisrtUp = true + local bFisrtDw = true + + nIdSurf = EgtGetFirstInGroup( nIdLs) -- ottengo la prima superfice + + while nIdSurf do + + sSurfName = EgtGetName( nIdSurf) + local nNextId = EgtGetNext(nIdSurf) + + -- se trovata superfice up principale + if sSurfName and bFisrtUp and string.lower(sSurfName) == 'flat_up' then + nIdSurfUp = nIdSurf + bFisrtUp = false + end + + -- se trovata superfice dw principale + if sSurfName and bFisrtDw and string.lower(sSurfName) == 'flat_dw' then + nIdSurfDw = nIdSurf + bFisrtDw = false + end + + -- se superfice up temporanea la sottraggo alla principale e poi la elimino + if sSurfName and string.lower(sSurfName) == 'flat_up_tmp' then + nIdSurfTmpUp = nIdSurf + EgtSurfFrSubtract( nIdSurfUp, nIdSurfTmpUp) + EgtErase(nIdSurfTmpUp) + end + + -- se superfice dw temporanea la sottraggo alla principale e poi la elimino + if sSurfName and string.lower(sSurfName) == 'flat_dw_tmp' then + nIdSurfTmpDw = nIdSurf + EgtSurfFrSubtract( nIdSurfDw, nIdSurfTmpDw) + EgtErase(nIdSurfTmpDw) + end + + -- se superfice up temporanea speciale (da percorsi di hatching) la sommo alla principale e poi la elimino + if sSurfName and string.lower(sSurfName) == 'flat_up_tmp_sp' then + nIdSurfTmpUp = nIdSurf + EgtSurfFrAdd( nIdSurfUp, nIdSurfTmpUp) + EgtErase(nIdSurfTmpUp) + end + + -- se superfice dw temporanea speciale (da percorsi di hatching) la sommo alla principale e poi la elimino + if sSurfName and string.lower(sSurfName) == 'flat_dw_tmp_sp' then + nIdSurfTmpDw = nIdSurf + EgtSurfFrAdd( nIdSurfDw, nIdSurfTmpDw) + EgtErase(nIdSurfTmpDw) + end + + nIdSurf = nNextId + end + + return true +end + +----------------------------------------------------------------- +local function GetEdgeToMachine( sSide) + if DGD.Lock == sSide then + return DGD.tProfs.lockedge.machining + elseif sSide == 'L' or sSide == 'R' then + return DGD.tProfs.hingeedge.machining + elseif sSide == 'T' then + return DGD.tProfs.top.machining + elseif sSide == 'B' then + return DGD.tProfs.bottom.machining + end +end + +----------------------------------------------------------------- +local function GetEdgeTrimming( sSide) + if DGD.Lock == sSide then + return DGD.tProfs.lockedge.trimming + elseif sSide == 'L' or sSide == 'R' then + return DGD.tProfs.hingeedge.trimming + elseif sSide == 'T' then + return DGD.tProfs.top.trimming + elseif sSide == 'B' then + return DGD.tProfs.bottom.trimming + end +end + +----------------------------------------------------------------- +local function SetInvertEdgeTrimming( sProfile) + if sProfile == 'BD' then + sProfile = 'BU' + elseif sProfile == 'BU' then + sProfile = 'BD' + elseif sProfile == 'BDEB' then + sProfile = 'BUEB' + elseif sProfile == 'BUEB' then + sProfile = 'BDEB' + end + return sProfile +end + +----------------------------------------------------------------- +local function GetRealEdgeTrimming( sSide) + local sTrim = GetEdgeTrimming( sSide) + if not DGD.sFrame then + if sTrim == 'BD' or sTrim == 'BU' then + if DGD.Push then + sTrim = 'BU' + else + sTrim = 'BD' + end + elseif sTrim == 'BDEB' or sTrim == 'BUEB' then + if DGD.Push then + sTrim = 'BUEB' + else + sTrim = 'BDEB' + end + end + end + return sTrim +end + +----------------------------------------------------------------- +local function GetEdgeOffset( sSide) + if DGD.Lock == sSide then + return DGD.tProfs.lockedge.offset + else + return DGD.tProfs.hingeedge.offset + end +end + +----------------------------------------------------------------- +local function SetFrameThickValues( bSideLeft) + + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + if bSideLeft then + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + else + DGD.Ldt = 0 + DGD.Ldb = 0 + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + end + elseif nTypePiece == 4 then -- se frame DX + if bSideLeft then + DGD.Ldt = 0 + DGD.Ldb = 0 + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + else + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + end + elseif nTypePiece == 5 then -- se frame TOP + if bSideLeft then + DGD.Bul = 0 + DGD.Bur = 0 + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + else + DGD.Bdl = 0 + DGD.Bdr = 0 + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + end + elseif nTypePiece == 6 then -- se frame BOTTOM + if bSideLeft then + DGD.Bdl = 0 + DGD.Bdr = 0 + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + else + DGD.Bul = 0 + DGD.Bur = 0 + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + end + end + else + + if bSideLeft then + DGD.Ult = DGD.dT + DGD.Ulb = DGD.dT + DGD.Dlb = 0 + DGD.Dlt = 0 + if DGD.PROBE == 2 then + DGD.Mlb = DGD.dT/2 + DGD.Mlt = DGD.dT/2 + end + else + DGD.Urt = DGD.dT + DGD.Urb = DGD.dT + DGD.Drb = 0 + DGD.Drt = 0 + if DGD.PROBE == 2 then + DGD.Mrb = DGD.dT/2 + DGD.Mrt = DGD.dT/2 + end + end + end +end + +local function RemakeDoor( sLeftType, dRadProf, sRightType, dRadProfR) + + local nLa = EgtGroup( DGD.PZ) + EgtSetName( nLa, 'REC') + EgtSetColor( nLa, BROWN()) + local dDistToExtX = tProbeDoor.PX + (2*25.4) -- calcolo linea di estensione in X in base al settaggio nella macro + 2 Inch extra + local dDistToExtY = tProbeDoor.PY + (2*25.4) -- calcolo linea di estensione in Y in base al settaggio nella macro + 2 inch extra + + -- dichiaro le variabili dei lati + local nBase + local nBaseMid + local nBaseTop + local nRight + local nRightMid + local nRightTop + local nTop + local nTopMid + local nTopTop + local nLeft + local nLeftMid + local nLeftTop + + -- creo linee principali (in senso antiorario) + nBase = EgtLine( nLa, { tProbeDoor.P2x, tProbeDoor.P2y, 0}, { tProbeDoor.P3x, tProbeDoor.P3y, 0}, GDB_RT.LOC) -- p2 a p3 + + if not nBase then + return + end + + if DGC.Pms == 0 then -- se ricostruzione completa porta + nRight = EgtLine( nLa, { tProbeDoor.P4x, tProbeDoor.P4y, 0}, { tProbeDoor.P5x, tProbeDoor.P5y, 0}, GDB_RT.LOC) -- p4 a p5 + nTop = EgtLine( nLa, { tProbeDoor.P6x, tProbeDoor.P6y, 0}, { tProbeDoor.P7x, tProbeDoor.P7y, 0}, GDB_RT.LOC) -- p6 a p7 + nLeft = EgtLine( nLa, { tProbeDoor.P8x, tProbeDoor.P8y, 0}, { tProbeDoor.P1x, tProbeDoor.P1y, 0}, GDB_RT.LOC) -- p8 a p1 + else -- se modalità 1 (solo 4 punti probe, calcolo solo larghezza) o modalità 2 ( 5 punti probe, calcolo larghezza e lunghezza) + + -- calcolo l'angolo di rotazione + local vDirEnt = EgtSV(nBase) + local dAngRotbase = atan(vDirEnt:getY(),vDirEnt:getX()) + + -- continuo la costruzione delle linee con un solo angolo calcolato + if tProbeDoor.DD == 0 then -- se porta disposta a destra + -- linea destra calcolata sul punto più vicino alla linea di base + nRight = EgtLinePDL( nLa, { tProbeDoor.P4x, tProbeDoor.P4y, 0}, dAngRotbase+90, ( DGD.dW - (2*tProbeDoor.PY)) ,GDB_RT.LOC) -- p4 con angolo e lunghezza + -- linea top calcolata sul punto opposto in Y a P3 cioè P6 + nTop = EgtLinePDL( nLa, { tProbeDoor.P6x, tProbeDoor.P6y, 0}, dAngRotbase + 180, ( DGD.dH - (2*tProbeDoor.PX)), GDB_RT.LOC) -- p6 con angolo e lunghezza + + -- se ho il punto anche in lunghezza + if DGC.Pms == 2 then + nLeft = EgtLinePDL( nLa, { tProbeDoor.P1x, tProbeDoor.P1y, 0}, dAngRotbase+90, ( DGD.dW - (2*tProbeDoor.PY)), GDB_RT.LOC) -- p1 con angolo e lunghezza + -- inverto la direzione + EgtInvertCurve(nLeft) + elseif DGC.Pms == 1 then + -- faccio l'offset della linea alla distanza pari all'altezza della porta + nLeft = EgtOffsetCurveAdv( nRight, -DGD.dH) + -- inverto la direzione + EgtInvertCurve(nLeft) + end + else -- altrimenti disposta a sinistra + -- linea sinistra calcolata sul punto più vicino alla linea di base + nLeft = EgtLinePDL( nLa, { tProbeDoor.P1x, tProbeDoor.P1y, 0}, dAngRotbase+90, ( DGD.dW - (2*tProbeDoor.PY)) ,GDB_RT.LOC) -- p4 con angolo e lunghezza + -- inverto la direzione + EgtInvertCurve(nLeft) + -- linea top calcolata sul punto opposto in Y a P2, cioè P7 + nTop = EgtLinePDL( nLa, { tProbeDoor.P7x, tProbeDoor.P7y, 0}, dAngRotbase, ( DGD.dH - (2*tProbeDoor.PX)), GDB_RT.LOC) -- p6 con angolo e lunghezza + -- inverto la direzione + EgtInvertCurve(nTop) + + -- se ho il punto anche in lunghezza + if DGC.Pms == 2 then + nRight = EgtLinePDL( nLa, { tProbeDoor.P4x, tProbeDoor.P4y, 0}, dAngRotbase+90, ( DGD.dW - (2*tProbeDoor.PY)), GDB_RT.LOC) -- p1 con angolo e lunghezza + elseif DGC.Pms == 1 then + -- faccio l'offset della linea alla distanza pari all'altezza della porta + nRight = EgtOffsetCurveAdv( nLeft, -DGD.dH) + -- inverto la direzione + EgtInvertCurve(nRight) + end + end + end + + -- lati di riferimento della porta + local nParFlip = 1 + + if tProbeDoor.FD > 0.5 then -- se porta flippata + if tProbeDoor.TD > 0.5 then -- se top a destra + nDoorLeft = nBase + nDoorRight = nTop + nDoorTop = nRight + nDoorBot = nLeft + else + nDoorLeft = nTop + nDoorRight = nBase + nDoorTop = nLeft + nDoorBot = nRight + end + nParFlip = -1 + else -- porta non flippata + if tProbeDoor.TD > 0.5 then -- se top a destra + nDoorLeft = nTop + nDoorRight = nBase + nDoorTop = nRight + nDoorBot = nLeft + else + nDoorLeft = nBase + nDoorRight = nTop + nDoorTop = nLeft + nDoorBot = nRight + end + end + + if nBase then + if abs(tProbeDoor.DR) > 0 then -- se ho la linea probase faccio l'eventuale offset e la assegno alla variabile giusta + EgtOffsetCurve( nBase, tProbeDoor.DR) + end + -- se la base è il lato sinistro + if nDoorLeft == nBase then + nDoorLeftTop = EgtCopyGlob(nBase, nLa) + nBaseTop = nDoorLeftTop + nDoorLeftMid = EgtCopyGlob(nBase, nLa) + nBaseMid = nDoorLeftMid + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + elseif sLeftType == 'BU' or sLeftType == 'BUEB' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorLeftTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorLeftMid, -DGD.dT/2 * TAN3) + elseif sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nBase, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorLeftMid, -DGD.dT/2 * TAN3) + elseif sLeftType == '1B' or sLeftType == '2B' or sLeftType == '3B' or sLeftType == '4B' or + sLeftType == '5B' or sLeftType == '6B' or sLeftType == '7B' or sLeftType == '8B'then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nBase, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + EgtOffsetCurve( nDoorLeftTop, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + elseif sLeftType == 'CV' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorLeftMid, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + end + else + nDoorRightTop = EgtCopyGlob(nBase, nLa) + nBaseTop = nDoorRightTop + nDoorRightMid = EgtCopyGlob(nBase, nLa) + nBaseMid = nDoorRightMid + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + elseif sRightType == 'BU' or sRightType == 'BUEB' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorRightTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorRightMid, -DGD.dT/2 * TAN3) + elseif sRightType == 'BD' or sRightType == 'BDEB' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nBase, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorRightMid, -DGD.dT/2 * TAN3) + elseif sRightType == '1B' or sRightType == '2B' or sRightType == '3B' or sRightType == '4B' or + sRightType == '5B' or sRightType == '6B' or sRightType == '7B' or sRightType == '8B' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nBase, -(dRadProfR - sqrt( ( dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + EgtOffsetCurve( nDoorRightTop, -(dRadProfR - sqrt((dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + elseif sRightType == 'CV' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorRightMid, -(dRadProfR - sqrt((dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + end + end + end + if nTop then + if abs(tProbeDoor.DO) > 0 then -- se ho la linea probase faccio l'eventuale offset e la assegno alla variabile giusta + EgtOffsetCurve( nTop, tProbeDoor.DO) + end + -- se il lato top è il lato sinistro + if nDoorLeft == nTop then + nDoorLeftTop = EgtCopyGlob(nTop, nLa) + nTopTop = nDoorLeftTop + nDoorLeftMid = EgtCopyGlob(nTop, nLa) + nTopMid = nDoorLeftMid + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + elseif sLeftType == 'BU' or sLeftType == 'BUEB' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorLeftTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorLeftMid, -DGD.dT/2 * TAN3) + elseif sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorLeftMid, -DGD.dT/2 * TAN3) + elseif sLeftType == '1B' or sLeftType == '2B' or sLeftType == '3B' or sLeftType == '4B' or + sLeftType == '5B' or sLeftType == '6B' or sLeftType == '7B' or sLeftType == '8B' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nTop, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + EgtOffsetCurve( nDoorLeftTop, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + elseif sLeftType == 'CV' then + EgtMove( nDoorLeftTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorLeftMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorLeftMid, -(dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) + end + else + nDoorRightTop = EgtCopyGlob(nTop, nLa) + nTopTop = nDoorRightTop + nDoorRightMid = EgtCopyGlob(nTop, nLa) + nTopMid = nDoorRightMid + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + elseif sRightType == 'BU' or sRightType == 'BUEB' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorRightTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorRightMid, -DGD.dT/2 * TAN3) + elseif sRightType == 'BD' or sRightType == 'BDEB' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nTop, -DGD.dT * TAN3) + EgtOffsetCurve( nDoorRightMid, -DGD.dT/2 * TAN3) + elseif sRightType == '1B' or sRightType == '2B' or sRightType == '3B' or sRightType == '4B' or + sRightType == '5B' or sRightType == '6B' or sRightType == '7B' or sRightType == '8B' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nTop, -(dRadProfR - sqrt( ( dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + EgtOffsetCurve( nDoorRightTop, -(dRadProfR - sqrt((dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + elseif sRightType == 'CV' then + EgtMove( nDoorRightTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorRightMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + EgtOffsetCurve( nDoorRightMid, -(dRadProfR - sqrt((dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))))) + end + end + end + if nLeft then + -- se il lato sinistro è il top + if nDoorTop == nLeft then + nDoorTopTop = EgtCopyGlob(nLeft, nLa) + nLeftTop = nDoorTopTop + nDoorTopMid = EgtCopyGlob(nLeft, nLa) + nLeftMid = nDoorTopMid + EgtMove( nDoorTopTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorTopMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + else + nDoorBotTop = EgtCopyGlob(nLeft, nLa) + nLeftTop = nDoorBotTop + nDoorBotMid = EgtCopyGlob(nLeft, nLa) + nLeftMid = nDoorBotMid + EgtMove( nDoorBotTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorBotMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + end + end + if nRight then + -- se il lato sinistro è il bottom + if nDoorBot == nRight then + nDoorBotTop = EgtCopyGlob(nRight, nLa) + nRightTop = nDoorBotTop + nDoorBotMid = EgtCopyGlob(nRight, nLa) + nRightMid = nDoorBotMid + EgtMove( nDoorBotTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorBotMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + else + nDoorTopTop = EgtCopyGlob(nRight, nLa) + nRightTop = nDoorTopTop + nDoorTopMid = EgtCopyGlob(nRight, nLa) + nRightMid = nDoorTopMid + EgtMove( nDoorTopTop, ORIG() + Point3d(0,0,(nParFlip*DGD.dT)), GDB_RT.GRID) + EgtMove( nDoorTopMid, ORIG() + Point3d(0,0,(nParFlip*DGD.dT/2)), GDB_RT.GRID) + end + end + + -- estendo le linee per creare i quadrilateri di base, medio e top + if nRight and nBase then -- base con destra + EgtTrimExtendCurveByLen( nBase,dDistToExtX,EgtEP(nBase)) + EgtTrimExtendCurveByLen( nRight,dDistToExtY,EgtSP(nRight)) + local nIdDel = EgtSplitCurveAtPoint( nBase, EgtIP(nBase,nRight,EgtEP(nBase))) + EgtErase(nIdDel) + nIdDel = nRight + nRight = EgtSplitCurveAtPoint( nRight, EgtEP(nBase)) + EgtErase(nIdDel) + end + if nRightMid and nBaseMid then -- base con destra mid + EgtTrimExtendCurveByLen( nBaseMid,dDistToExtX,EgtEP(nBaseMid)) + EgtTrimExtendCurveByLen( nRightMid,dDistToExtY,EgtSP(nRightMid)) + local nIdDel = EgtSplitCurveAtPoint( nBaseMid, EgtIP(nBaseMid,nRightMid,EgtEP(nBaseMid))) + EgtErase(nIdDel) + nIdDel = nRightMid + nRightMid = EgtSplitCurveAtPoint( nRightMid, EgtEP(nBaseMid)) + EgtErase(nIdDel) + end + if nRightTop and nBaseTop then -- base con destra top + EgtTrimExtendCurveByLen( nBaseTop,dDistToExtX,EgtEP(nBaseTop)) + EgtTrimExtendCurveByLen( nRightTop,dDistToExtY,EgtSP(nRightTop)) + local nIdDel = EgtSplitCurveAtPoint( nBaseTop, EgtIP(nBaseTop,nRightTop,EgtEP(nBaseTop))) + EgtErase(nIdDel) + nIdDel = nRightTop + nRightTop = EgtSplitCurveAtPoint( nRightTop, EgtEP(nBaseTop)) + EgtErase(nIdDel) + end + + if nLeft and nBase then -- base con sinistra + EgtTrimExtendCurveByLen( nBase,dDistToExtX,EgtSP(nBase)) + EgtTrimExtendCurveByLen( nLeft,dDistToExtY, EgtEP(nLeft)) + local nIdDel = nBase + nBase = EgtSplitCurveAtPoint( nBase, EgtIP(nBase,nLeft,EgtSP(nBase))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nLeft, EgtSP(nBase)) + EgtErase(nIdDel) + end + if nLeftMid and nBaseMid then -- base con sinistra mid + EgtTrimExtendCurveByLen( nBaseMid,dDistToExtX,EgtSP(nBaseMid)) + EgtTrimExtendCurveByLen( nLeftMid,dDistToExtY, EgtEP(nLeftMid)) + local nIdDel = nBaseMid + nBaseMid = EgtSplitCurveAtPoint( nBaseMid, EgtIP(nBaseMid,nLeftMid,EgtSP(nBaseMid))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nLeftMid, EgtSP(nBaseMid)) + EgtErase(nIdDel) + end + if nLeftTop and nBaseTop then -- base con sinistra top + EgtTrimExtendCurveByLen( nBaseTop,dDistToExtX,EgtSP(nBaseTop)) + EgtTrimExtendCurveByLen( nLeftTop,dDistToExtY, EgtEP(nLeftTop)) + local nIdDel = nBaseTop + nBaseTop = EgtSplitCurveAtPoint( nBaseTop, EgtIP(nBaseTop,nLeftTop,EgtSP(nBaseTop))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nLeftTop, EgtSP(nBaseTop)) + EgtErase(nIdDel) + end + + if nRight and nTop then -- top con destra + EgtTrimExtendCurveByLen( nTop,dDistToExtX,EgtSP(nTop)) + EgtTrimExtendCurveByLen( nRight,dDistToExtY, EgtEP(nRight)) + local nIdDel = nTop + nTop = EgtSplitCurveAtPoint( nTop, EgtIP(nTop,nRight,EgtSP(nTop))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nRight, EgtSP(nTop)) + EgtErase(nIdDel) + end + if nRightMid and nTopMid then -- top con destra mid + EgtTrimExtendCurveByLen( nTopMid,dDistToExtX,EgtSP(nTopMid)) + EgtTrimExtendCurveByLen( nRightMid,dDistToExtY, EgtEP(nRightMid)) + local nIdDel = nTopMid + nTopMid = EgtSplitCurveAtPoint( nTopMid, EgtIP(nTopMid,nRightMid,EgtSP(nTopMid))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nRightMid, EgtSP(nTopMid)) + EgtErase(nIdDel) + end + if nRightTop and nTopTop then -- top con destra top + EgtTrimExtendCurveByLen( nTopTop,dDistToExtX,EgtSP(nTopTop)) + EgtTrimExtendCurveByLen( nRightTop,dDistToExtY, EgtEP(nRightTop)) + local nIdDel = nTopTop + nTopTop = EgtSplitCurveAtPoint( nTopTop, EgtIP(nTopTop,nRightTop,EgtSP(nTopTop))) + EgtErase(nIdDel) + nIdDel = EgtSplitCurveAtPoint( nRightTop, EgtSP(nTopTop)) + EgtErase(nIdDel) + end + + if nLeft and nTop then -- top con sinistra + EgtTrimExtendCurveByLen( nTop,dDistToExtX,EgtEP(nTop)) + EgtTrimExtendCurveByLen( nLeft,dDistToExtY, EgtSP(nLeft)) + local nIdDel = EgtSplitCurveAtPoint( nTop, EgtIP(nTop,nLeft,EgtEP(nTop))) + EgtErase(nIdDel) + nIdDel = nLeft + nLeft = EgtSplitCurveAtPoint( nLeft, EgtEP(nTop)) + EgtErase(nIdDel) + end + if nLeftMid and nTopMid then -- top con sinistra mid + EgtTrimExtendCurveByLen( nTopMid,dDistToExtX,EgtEP(nTopMid)) + EgtTrimExtendCurveByLen( nLeftMid,dDistToExtY, EgtSP(nLeftMid)) + local nIdDel = EgtSplitCurveAtPoint( nTopMid, EgtIP(nTopMid,nLeftMid,EgtEP(nTopMid))) + EgtErase(nIdDel) + nIdDel = nLeftMid + nLeftMid = EgtSplitCurveAtPoint( nLeftMid, EgtEP(nTopMid)) + EgtErase(nIdDel) + end + if nLeftTop and nTopTop then -- top con sinistra top + EgtTrimExtendCurveByLen( nTopTop,dDistToExtX,EgtEP(nTopTop)) + EgtTrimExtendCurveByLen( nLeftTop,dDistToExtY, EgtSP(nLeftTop)) + local nIdDel = EgtSplitCurveAtPoint( nTopTop, EgtIP(nTopTop,nLeftTop,EgtEP(nTopTop))) + EgtErase(nIdDel) + nIdDel = nLeftTop + nLeftTop = EgtSplitCurveAtPoint( nLeftTop, EgtEP(nTopTop)) + EgtErase(nIdDel) + end + + if tProbeDoor.FD > 0.5 then -- se porta flippata + + -- dopo rotazione il giro è orario + EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), X_AX(), 180 ) + EgtRotate( {nBaseMid,nRightMid,nTopMid,nLeftMid} , ORIG(), X_AX(), 180 ) + EgtRotate( {nBaseTop,nRightTop,nTopTop,nLeftTop} , ORIG(), X_AX(), 180 ) + + if tProbeDoor.TD > 0.5 then -- se top a destra + EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), Z_AX(), 90 ) + EgtRotate( {nBaseMid,nRightMid,nTopMid,nLeftMid} , ORIG(), Z_AX(), 90 ) + EgtRotate( {nBaseTop,nRightTop,nTopTop,nLeftTop} , ORIG(), Z_AX(), 90 ) + nDoorLeft = nBase + nDoorRight = nTop + nDoorTop = nRight + nDoorBot = nLeft + nDoorLeftMid = nBaseMid + nDoorRightMid = nTopMid + nDoorTopMid = nRightMid + nDoorBotMid = nLeftMid + nDoorLeftTop = nBaseTop + nDoorRightTop = nTopTop + nDoorTopTop = nRightTop + nDoorBotTop = nLeftTop + else + EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), Z_AX(), -90 ) + EgtRotate( {nBaseMid,nRightMid,nTopMid,nLeftMid} , ORIG(), Z_AX(), -90 ) + EgtRotate( {nBaseTop,nRightTop,nTopTop,nLeftTop} , ORIG(), Z_AX(), -90 ) + nDoorLeft = nTop + nDoorRight = nBase + nDoorTop = nLeft + nDoorBot = nRight + nDoorLeftMid = nTopMid + nDoorRightMid = nBaseMid + nDoorTopMid = nLeftMid + nDoorBotMid = nRightMid + nDoorLeftTop = nTopTop + nDoorRightTop = nBaseTop + nDoorTopTop = nLeftTop + nDoorBotTop = nRightTop + end + else -- porta non flippata + + --inverto la direzione delle entità per avere giro orario + EgtInvertCurve({nBase,nRight,nTop,nLeft}) + EgtInvertCurve({nBaseMid,nRightMid,nTopMid,nLeftMid}) + EgtInvertCurve({nBaseTop,nRightTop,nTopTop,nLeftTop}) + + if tProbeDoor.TD > 0.5 then -- se top a destra + EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), Z_AX(), 90 ) + EgtRotate( {nBaseMid,nRightMid,nTopMid,nLeftMid} , ORIG(), Z_AX(), 90 ) + EgtRotate( {nBaseTop,nRightTop,nTopTop,nLeftTop} , ORIG(), Z_AX(), 90 ) + nDoorLeft = nTop + nDoorRight = nBase + nDoorTop = nRight + nDoorBot = nLeft + nDoorLeftMid = nTopMid + nDoorRightMid = nBaseMid + nDoorTopMid = nRightMid + nDoorBotMid = nLeftMid + nDoorLeftTop = nTopTop + nDoorRightTop = nBaseTop + nDoorTopTop = nRightTop + nDoorBotTop = nLeftTop + else + EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), Z_AX(), -90 ) + EgtRotate( {nBaseMid,nRightMid,nTopMid,nLeftMid} , ORIG(), Z_AX(), -90 ) + EgtRotate( {nBaseTop,nRightTop,nTopTop,nLeftTop} , ORIG(), Z_AX(), -90 ) + nDoorLeft = nBase + nDoorRight = nTop + nDoorTop = nLeft + nDoorBot = nRight + nDoorLeftMid = nBaseMid + nDoorRightMid = nTopMid + nDoorTopMid = nLeftMid + nDoorBotMid = nRightMid + nDoorLeftTop = nBaseTop + nDoorRightTop = nTopTop + nDoorTopTop = nLeftTop + nDoorBotTop = nRightTop + end + end + + EgtSetName (nDoorLeft, 'Left') + EgtSetName (nDoorRight, 'Right') + EgtSetName (nDoorTop, 'Top') + EgtSetName (nDoorBot, 'Bottom') + EgtSetName (nDoorLeftMid, 'LeftMid') + EgtSetName (nDoorRightMid, 'RightMid') + EgtSetName (nDoorTopMid, 'TopMid') + EgtSetName (nDoorBotMid, 'BottomMid') + EgtSetName (nDoorLeftTop, 'LeftTop') + EgtSetName (nDoorRightTop, 'RightTop') + EgtSetName (nDoorTopTop, 'TopTop') + EgtSetName (nDoorBotTop, 'BottomTop') + + -- Per ogni quadrilatero Prendo i 4 punti base e le direzioni relative che definiranno la porta + DGD.P1=EgtEP( nDoorBotTop, GDB_RT.GLOB) + DGD.P2=EgtEP( nDoorRightTop, GDB_RT.GLOB) + DGD.P3=EgtEP( nDoorRight, GDB_RT.GLOB) + DGD.P4=EgtEP( nDoorBot, GDB_RT.GLOB) + DGD.P5=EgtEP( nDoorBotMid, GDB_RT.GLOB) + DGD.P6=EgtEP( nDoorRightMid, GDB_RT.GLOB) + DGD.P7=EgtEP( nDoorLeftTop, GDB_RT.GLOB) + DGD.P8=EgtEP( nDoorTopTop, GDB_RT.GLOB) + DGD.P9=EgtEP( nDoorTop, GDB_RT.GLOB) + DGD.P10=EgtEP( nDoorLeft, GDB_RT.GLOB) + DGD.P11=EgtEP( nDoorLeftMid, GDB_RT.GLOB) + DGD.P12=EgtEP( nDoorTopMid, GDB_RT.GLOB) + + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == '1B' or sLeftType == '2B' or sLeftType == '3B' or + sLeftType == '4B' or sLeftType == '5B' or sLeftType == '6B' or sLeftType == '7B' or sLeftType == '8B' or + sLeftType == 'FDWC' then + DGD.PminBot = DGD.P5 + DGD.PminTop = DGD.P11 + elseif sLeftType == 'BU' or sLeftType == 'BUEB' or sLeftType == 'CV' then + DGD.PminBot = DGD.P4 + DGD.PminTop = DGD.P10 + elseif sLeftType == 'BD' or sLeftType == 'BDEB' then + DGD.PminBot = DGD.P1 + DGD.PminTop = DGD.P7 + end + + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == '1B' or sRightType == '2B' or sRightType == '3B' or + sRightType == '4B' or sRightType == '5B' or sRightType == '6B' or sRightType == '7B' or sRightType == '8B' or + sRightType == 'FDWC' then + DGD.PmaxBot = DGD.P6 + DGD.PmaxTop = DGD.P12 + elseif sRightType == 'BU' or sRightType == 'BUEB' or sRightType == 'CV' then + DGD.PmaxBot = DGD.P3 + DGD.PmaxTop = DGD.P9 + elseif sRightType == 'BD' or sRightType == 'BDEB' then + DGD.PmaxBot = DGD.P2 + DGD.PmaxTop = DGD.P8 + end + + local vDirEnt = EgtSV(nDoorBot) + DGD.A1=atan(vDirEnt:getY(),vDirEnt:getX()) + DGD.A2=DGD.A1+180 + DGD.L1=EgtCurveLength( nDoorBot) + DGD.L1Top=EgtCurveLength( nDoorBotTop) + + vDirEnt = EgtSV(nDoorLeft) + DGD.A3=atan(vDirEnt:getY(),vDirEnt:getX()) + DGD.A4=DGD.A3+180 + DGD.L2=EgtCurveLength( nDoorLeft) + DGD.L2Top=EgtCurveLength( nDoorLeftTop) + + vDirEnt = EgtSV(nDoorTop) + DGD.A5=atan(vDirEnt:getY(),vDirEnt:getX()) + DGD.A6=DGD.A5+180 + DGD.L3=EgtCurveLength( nDoorTop) + DGD.L3Top=EgtCurveLength( nDoorTopTop) + + vDirEnt = EgtSV(nDoorRight) + DGD.A7=atan(vDirEnt:getY(),vDirEnt:getX()) + DGD.A8=DGD.A7+180 + DGD.L4=EgtCurveLength( nDoorRight) + DGD.L4Top=EgtCurveLength( nDoorRightTop) + + -- errato calcolo: prende le ipotenuse di maggior lunghezza e larghezza e non i box + -- calcolo le dimensioni della porta +-- local dLungMax = max ( sqrt( ( DGD.PmaxBot[1] - DGD.PmaxTop[1]) * ( DGD.PmaxBot[1] - DGD.PmaxTop[1]) + +-- ( DGD.PmaxBot[2] - DGD.PmaxTop[2]) * ( DGD.PmaxBot[2] - DGD.PmaxTop[2])), +-- sqrt( ( DGD.PminBot[1] - DGD.PminTop[1]) * ( DGD.PminBot[1] - DGD.PminTop[1]) + +-- ( DGD.PminBot[2] - DGD.PminTop[2]) * ( DGD.PminBot[2] - DGD.PminTop[2]))) +-- +-- local dLarghMax = max ( sqrt( ( DGD.PmaxBot[1] - DGD.PminBot[1]) * ( DGD.PmaxBot[1] - DGD.PminBot[1]) + +-- ( DGD.PmaxBot[2] - DGD.PminBot[2]) * ( DGD.PmaxBot[2] - DGD.PminBot[2])), +-- sqrt( ( DGD.PmaxTop[1] - DGD.PminTop[1]) * ( DGD.PmaxTop[1] - DGD.PminTop[1]) + +-- ( DGD.PmaxTop[2] - DGD.PminTop[2]) * ( DGD.PmaxTop[2] - DGD.PminTop[2]))) + local dLungMax = max ( DGD.PmaxTop[2], DGD.PminTop[2]) - min( DGD.PmaxBot[2], DGD.PminBot[2]) + local dLarghMax = max ( DGD.PmaxTop[1], DGD.PmaxBot[1]) - min( DGD.PminTop[1], DGD.PminBot[1]) + + -- Sposto tutte e 4 le geometrie nel primo quadrante +-- EgtMove( {nBase,nRight,nTop,nLeft}, ORIG() - EgtSP(nDoorLeft), GDB_RT.GRID) + + -- allineo il lato sinistro con la Y +-- local vDirLeft = EgtSV( nDoorLeft) +-- EgtRotate( {nBase,nRight,nTop,nLeft} , ORIG(), Z_AX(), atan(vDirLeft:getX()/vDirLeft:getY()) ) + + -- ritorno le dimensioni calcolate + return dLungMax, dLarghMax +end + +----------------------------------------------------------------- +local function MakeSurfProfiles( nParLay, sBotType, dRadProfB, sRghtType, dRadProfR, + sTopType, dRadProfT, sLftType, dRadProfL, sSideName, + dPlnProfB, dPlnProfR, dPlnProfT, dPlnProf) + + -- setto variabili che indicano se i profili sono compatibili + local bJoinRgt = true + local bJoinLft = true + local bDelete = true + + -- profilo superiore + local nTopPath, nToptSezPath, ptMedArc + + -- creo curva superiore + if DGD.tProfs.top.radius then + -- se ci sono tangenze con profili diversi verifico se concatenare la swept superiore + if DGD.TPR then + if sTopType == 'BD' or sTopType == 'BDEB' or sTopType == 'BU' or sTopType == 'BUEB' then + if sRghtType == 'SQ' or sRghtType == 'EB' or sRightType == 'FDWC' then + bJoinRgt = false + elseif sRghtType == '1B' or sRghtType == '2B' or sRghtType == '3B' or sRghtType == '4B' or + sRghtType == '5B' or sRghtType == '6B' or sRghtType == '7B' or sRghtType == '8B' then + bJoinRgt = true + elseif sRghtType == 'CV' then + bJoinRgt = false + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + + if sRghtType == '1B' or sRghtType == '2B' or sRghtType == '3B' or sRghtType == '4B' or + sRghtType == '5B' or sRghtType == '6B' or sRghtType == '7B' or sRghtType == '8B' then + -- tolgo di mezzo il B e confronto i numeri + local sNumProfTop = sTopType:gsub( 'B', '') + local sNumProfSide = sRghtType:gsub( 'B', '') + local nNumProfTop = tonumber(sNumProfTop) + local nNumProfSide = tonumber(sNumProfSide) + if nNumProfTop < nNumProfSide then + bJoinRgt = false + end + elseif sRghtType == 'BD' or sRghtType == 'BDEB' or sRghtType == 'BU' or sRghtType == 'BUEB' then + bJoinRgt = false + elseif sRghtType == 'CV' or sRghtType == 'SQ' or sRghtType == 'EB' or sRightType == 'FDWC' then + bJoinRgt = false + end + elseif sTopType == 'CV' then + if sRghtType == 'BD' or sRghtType == 'BDEB' or sRghtType == 'BU' or sRghtType == 'BUEB' then + bJoinRgt = false + elseif sRghtType == '1B' or sRghtType == '2B' or sRghtType == '3B' or sRghtType == '4B' or + sRghtType == '5B' or sRghtType == '6B' or sRghtType == '7B' or sRghtType == '8B' then + bJoinRgt = false + end + end + end + if DGD.TPL then + if sTopType == 'BD' or sTopType == 'BDEB' or sTopType == 'BU' or sTopType == 'BUEB' then + if sLftType == 'SQ' or sLftType == 'EB' or sLftType == 'FDWC' then + bJoinLft = false + elseif sLftType == '1B' or sLftType == '2B' or sLftType == '3B' or sLftType == '4B' or + sLftType == '5B' or sLftType == '6B' or sLftType == '7B' or sLftType == '8B' then + bJoinLft = true + elseif sLftType == 'CV' then + bJoinLft = false + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + + if sLftType == '1B' or sLftType == '2B' or sLftType == '3B' or sLftType == '4B' or + sLftType == '5B' or sLftType == '6B' or sLftType == '7B' or sLftType == '8B' then + -- tolgo di mezzo il B e confronto i numeri + local sNumProfTop = sTopType:gsub( 'B', '') + local sNumProfSide = sLftType:gsub( 'B', '') + local nNumProfTop = tonumber(sNumProfTop) + local nNumProfSide = tonumber(sNumProfSide) + if nNumProfTop < nNumProfSide then + bJoinLft = false + end + elseif sLftType == 'BD' or sLftType == 'BDEB' or sLftType == 'BU' or sLftType == 'BUEB' then + bJoinLft = false + elseif sLftType == 'CV' or sLftType == 'SQ' or sLftType == 'EB' or sLftType == 'FDWC' then + bJoinLft = false + end + elseif sTopType == 'CV' then + if sLftType == 'BD' or sLftType == 'BDEB' or sLftType == 'BU' or sLftType == 'BUEB' then + bJoinLft = false + elseif sLftType == '1B' or sLftType == '2B' or sLftType == '3B' or sLftType == '4B' or + sLftType == '5B' or sLftType == '6B' or sLftType == '7B' or sLftType == '8B' then + bJoinLft = false + end + end + end + + -- Arco top + nTopPath = EgtArcC2P( nParLay, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.RMa, DGD.AMr, DGD.Dra}, { DGD.LMa, DGD.AMl, DGD.Dla}, GDB_RT.GLOB) -- arco max + local vcIni = EgtSV(nTopPath) + EgtErase(nTopPath) + nTopPath = EgtArc2PV( nParLay, { DGD.RMa, DGD.AMr, DGD.Dra}, { DGD.LMa, DGD.AMl, DGD.Dla}, vcIni, GDB_RT.GLOB) + ptMedArc = EgtMP(nTopPath) + if not DGD.TPR then -- se non ho tangenza a destra allungo il percorso + local dDistY = abs((DGD.dH-DGD.tProfs.top.ydeltapos) - DGD.AMr) + if dDistY > 50.8 then + EgtTrimExtendCurveByLen( nTopPath, 50.8 , { DGD.RMa, DGD.AMr, DGD.Dra}) + else + EgtTrimExtendCurveByLen( nTopPath, dDistY*1.1 , { DGD.RMa, DGD.AMr, DGD.Dra}) + end + end + if not DGD.TPL then -- se non ho tangenza a sinistra allungo il percorso + local dDistY = abs((DGD.dH-DGD.tProfs.top.ydeltapos) - DGD.AMl) + if dDistY > 50.8 then + EgtTrimExtendCurveByLen( nTopPath, 50.8 , { DGD.LMa, DGD.AMl, DGD.Dla}) + else + EgtTrimExtendCurveByLen( nTopPath, dDistY*1.1 , { DGD.LMa, DGD.AMl, DGD.Dla}) + end + end + elseif DGD.Tpa then + + if DGD.tProfs.top.xdeltapos > 0 then + local nE1 = EgtLine( nParLay, {DGD.Rua,DGD.Aur,DGD.Dra}, {DGD.Cmu,DGD.Aut,DGD.Dla}, GDB_RT.GLOB) -- p14 a p19 + local nE2 = EgtLine( nParLay, {DGD.Cmu,DGD.Aut,DGD.Dla}, {DGD.Lua,DGD.Aul,DGD.Dla}, GDB_RT.GLOB) -- p19 a p13 + nTopPath = EgtCurveCompo( nParLay, {nE1,nE2}, true) + else + nTopPath = EgtLine( nParLay, {DGD.Rua,DGD.Aur,DGD.Dra}, {DGD.Lua,DGD.Aul,DGD.Dla}, GDB_RT.GLOB) -- p14 a p13 + end + + EgtTrimExtendCurveByLen( nTopPath, DGD.dW/4, {DGD.Rua,DGD.Aur,DGD.Dra}) + EgtTrimExtendCurveByLen( nTopPath, DGD.dW/4, {DGD.Lua,DGD.Aul,DGD.Dla}) + else + nTopPath = EgtLine( nParLay, {DGD.Rut,DGD.Tur,DGD.Drt}, {DGD.Lut,DGD.Tul,DGD.Dlt}, GDB_RT.GLOB) -- p8 a p7 + EgtTrimExtendCurveByLen( nTopPath, DGD.dW/4, {DGD.Rut,DGD.Tur,DGD.Drt}) + EgtTrimExtendCurveByLen( nTopPath, DGD.dW/4, {DGD.Lut,DGD.Tul,DGD.Dlt}) + end + + -- prendo il versore iniziale + local vIni = EgtSV( nTopPath, GDB_RT.GLOB) + local pIni = EgtSP( nTopPath, GDB_RT.GLOB) + + -- griglia locale + EgtSetGridFrame( Frame3d( pIni, vIni)) + + if sTopType == 'BD' or sTopType == 'BDEB' then + -- profilo sezione + nToptSezPath = EgtLine ( nParLay, {(DGD.dT*TAN3),0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + elseif sTopType == 'BU' or sTopType == 'BUEB' then + if DGD.tProfs.top.radius then + -- profilo sezione + nToptSezPath = EgtLine ( nParLay, {0,0,0}, {(DGD.dT*TAN3),DGD.dT,0}, GDB_RT.GRID) + else + -- profilo sezione + nToptSezPath = EgtLine ( nParLay, {-(DGD.dT*TAN3),0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + local dDeltaPos = dRadProfT - sqrt( ( dRadProfT * dRadProfT) - ((DGD.dT/2)*(DGD.dT/2))) + if DGD.tProfs.top.radius then + -- profilo sezione + nToptSezPath = EgtArc3P( nParLay, {dDeltaPos,0,0}, {0,DGD.dT/2,0}, {dDeltaPos,DGD.dT,0}, GDB_RT.GRID) + else + -- profilo sezione + nToptSezPath = EgtArc3P( nParLay, {0,0,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + elseif sTopType == 'CV' then + local dDeltaPos = dRadProfT - sqrt( ( dRadProfT * dRadProfT) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + -- profilo sezione + if dPlnProfT > 0 then + local nLine1, nLine2, nArc + nLine1 = EgtLine ( nParLay, {0,0,0}, {0,dPlnProfT,0}, GDB_RT.GRID) + nArc = EgtArc3P( nParLay, {0,dPlnProfT,0}, {dDeltaPos,DGD.dT/2,0}, {0,DGD.dT-dPlnProfT,0}, GDB_RT.GRID) + nLine2 = EgtLine ( nParLay, {0,DGD.dT-dPlnProfT,0}, {0,DGD.dT,0}, GDB_RT.GRID) + nToptSezPath = EgtCurveCompo( nParLay, {nLine1,nArc,nLine2}, true) + else + nToptSezPath = EgtArc3P( nParLay, {0,0,0}, {dDeltaPos,DGD.dT/2,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + else -- profilo SQ o FDWC + -- profilo sezione + nToptSezPath = EgtLine ( nParLay, {0,0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + + -- disegno le swept sopra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + local nSwT = EgtSurfTmSwept( nParLay, nToptSezPath, nTopPath,false, 0.05) + + ------------------------------- + -- semi-profili inferiori + ------------------------------- + local nBotPath, nBotPath2, nBotPathL, nBotPathR, nBotSezPath + -- griglia a sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + + if sBotType == 'BD' or sBotType == 'BDEB' then + -- profilo sezione + nBotSezPath = EgtLine ( nParLay, {-(DGD.dT*TAN3),0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nBotPathL = EgtLine ( nParLay, {-(DGD.dW/4),(DGD.dT*TAN3),0}, {(DGD.dW/2),(DGD.dT*TAN3),0}, GDB_RT.GRID) + nBotPathR = EgtLine ( nParLay, {(DGD.dW/2),(DGD.dT*TAN3),0}, {(DGD.dW*1.25),(DGD.dT*TAN3),0}, GDB_RT.GRID) + elseif sBotType == 'BU' or sBotType == 'BUEB' then + -- profilo sezione + nBotSezPath = EgtLine ( nParLay, {0,0,0}, {-(DGD.dT*TAN3),DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nBotPathL = EgtLine ( nParLay, {-(DGD.dW/4),0,0}, {(DGD.dW/2),0,0}, GDB_RT.GRID) + nBotPathR = EgtLine ( nParLay, {(DGD.dW/2),0,0}, {(DGD.dW*1.25),0,0}, GDB_RT.GRID) + elseif sBotType == '1B' or sBotType == '2B' or sBotType == '3B' or sBotType == '4B' or + sBotType == '5B' or sBotType == '6B' or sBotType == '7B' or sBotType == '8B' then + local dDeltaPos = dRadProfB - sqrt( ( dRadProfB * dRadProfB) - ((DGD.dT/2)*(DGD.dT/2))) + -- profilo sezione + nBotSezPath = EgtArc3P( nParLay, {-dDeltaPos,0,0}, {0,DGD.dT/2,0}, {-dDeltaPos,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nBotPathL = EgtLine ( nParLay, {-(DGD.dW/4),dDeltaPos,0}, {(DGD.dW/2),dDeltaPos,0}, GDB_RT.GRID) + nBotPathR = EgtLine ( nParLay, {(DGD.dW/2),dDeltaPos,0}, {(DGD.dW*1.25),dDeltaPos,0}, GDB_RT.GRID) + elseif sBotType == 'CV' then + local dDeltaPos = dRadProfB - sqrt( ( dRadProfB * dRadProfB) - (((DGD.dT/2)-dPlnProfB)*((DGD.dT/2)-dPlnProfB))) + -- profilo sezione + if dPlnProfB > 0 then + local nLine1, nLine2, nArc + nLine1 = EgtLine ( nParLay, {0,0,0}, {0,dPlnProfB,0}, GDB_RT.GRID) + nArc = EgtArc3P( nParLay, {0,dPlnProfB,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT-dPlnProfB,0}, GDB_RT.GRID) + nLine2 = EgtLine ( nParLay, {0,DGD.dT-dPlnProfB,0}, {0,DGD.dT,0}, GDB_RT.GRID) + nBotSezPath = EgtCurveCompo( nParLay, {nLine1,nArc,nLine2}, true) + else + nBotSezPath = EgtArc3P( nParLay, {0,0,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nBotPathL = EgtLine ( nParLay, {-(DGD.dW/4),0,0}, {(DGD.dW/2),0,0}, GDB_RT.GRID) + nBotPathR = EgtLine ( nParLay, {(DGD.dW/2),0,0}, {(DGD.dW*1.25),0,0}, GDB_RT.GRID) + else -- profilo SQ o FDWC + -- profilo sezione + nBotSezPath = EgtLine ( nParLay, {0,0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nBotPathL = EgtLine ( nParLay, {-(DGD.dW/4),0,0}, {(DGD.dW/2),0,0}, GDB_RT.GRID) + nBotPathR = EgtLine ( nParLay, {(DGD.dW/2),0,0}, {(DGD.dW*1.25),0,0}, GDB_RT.GRID) + end + -- disegno le swept inferiori + local nSwBL, nSwBR + nSwBL = EgtSurfTmSwept( nParLay, nBotSezPath, nBotPathL,false, 0.05) + nSwBR = EgtSurfTmSwept( nParLay, nBotSezPath, nBotPathR,false, 0.05) + + -- profilo destro + local nRghtPath, nRghtSezPath + + -- griglia in fronte + EgtSetGridFrame( Frame3d( DGD.dW,0,0, GDB_FR.FRONT)) + + if sRghtType == 'BD' or sRghtType == 'BDEB' then + -- profilo sezione + nRghtSezPath = EgtLine ( nParLay, {-(DGD.dT*TAN3),0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nRghtPath = EgtLine ( nParLay, {DGD.dW,-(DGD.dH*0.25),0}, {DGD.dW,(DGD.dH*1.25),0}, GDB_RT.GRID) + elseif sRghtType == 'BU' or sRghtType == 'BUEB' then + -- profilo sezione + nRghtSezPath = EgtLine ( nParLay, {0,0,0}, {-(DGD.dT*TAN3),DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nRghtPath = EgtLine ( nParLay, {DGD.dW-(DGD.dT*TAN3),-(DGD.dH*0.25),0}, {DGD.dW-(DGD.dT*TAN3),(DGD.dH*1.25),0}, GDB_RT.GRID) + elseif sRghtType == '1B' or sRghtType == '2B' or sRghtType == '3B' or sRghtType == '4B' or + sRghtType == '5B' or sRghtType == '6B' or sRghtType == '7B' or sRghtType == '8B' then + local dDeltaPos = dRadProfR - sqrt( ( dRadProfR * dRadProfR) - ((DGD.dT/2)*(DGD.dT/2))) + -- profilo sezione + nRghtSezPath = EgtArc3P( nParLay, {-dDeltaPos,0,0}, {0,DGD.dT/2,0}, {-dDeltaPos,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nRghtPath = EgtLine ( nParLay, {DGD.dW-dDeltaPos,-(DGD.dH*0.25),0}, {DGD.dW-dDeltaPos,(DGD.dH*1.25),0}, GDB_RT.GRID) + elseif sRghtType == 'CV' then + local dDeltaPos = dRadProfR - sqrt( ( dRadProfR * dRadProfR) - (((DGD.dT/2)-dPlnProfR)*((DGD.dT/2)-dPlnProfR))) + -- profilo sezione + if dPlnProfR > 0 then + local nLine1, nLine2, nArc + nLine1 = EgtLine ( nParLay, {0,0,0}, {0,dPlnProfR,0}, GDB_RT.GRID) + nArc = EgtArc3P( nParLay, {0,dPlnProfR,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT-dPlnProfR,0}, GDB_RT.GRID) + nLine2 = EgtLine ( nParLay, {0,DGD.dT-dPlnProfR,0}, {0,DGD.dT,0}, GDB_RT.GRID) + nRghtSezPath = EgtCurveCompo( nParLay, {nLine1,nArc,nLine2}, true) + else + nRghtSezPath = EgtArc3P( nParLay, {0,0,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nRghtPath = EgtLine ( nParLay, {DGD.dW,-(DGD.dH*0.25),0}, {DGD.dW,(DGD.dH*1.25),0}, GDB_RT.GRID) + else -- profilo SQ o FDWC + -- profilo sezione + nRghtSezPath = EgtLine ( nParLay, {0,0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nRghtPath = EgtLine ( nParLay, {DGD.dW,-(DGD.dH*0.25),0}, {DGD.dW,(DGD.dH*1.25),0}, GDB_RT.GRID) + end + -- disegno la swept destra + local nSwR = EgtSurfTmSwept( nParLay, nRghtSezPath, nRghtPath,false, 0.05) + + -- profilo sinistro + local nLftPath, nLftSezPath + + -- griglia dietro + EgtSetGridFrame( Frame3d( 0,DGD.dH,0, GDB_FR.BACK)) + + if sLftType == 'BD' or sLftType == 'BDEB' then + -- profilo sezione + nLftSezPath = EgtLine ( nParLay, {-(DGD.dT*TAN3),0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nLftPath = EgtLine ( nParLay, {(DGD.dT*TAN3),(DGD.dH*1.25),0}, {(DGD.dT*TAN3),-(DGD.dH*0.25),0}, GDB_RT.GRID) + elseif sLftType == 'BU' or sLftType == 'BUEB' then + -- profilo sezione + nLftSezPath = EgtLine ( nParLay, {0,0,0}, {-(DGD.dT*TAN3),DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nLftPath = EgtLine ( nParLay, {0,(DGD.dH*1.25),0}, {0,-(DGD.dH*0.25),0}, GDB_RT.GRID) + elseif sLftType == '1B' or sLftType == '2B' or sLftType == '3B' or sLftType == '4B' or + sLftType == '5B' or sLftType == '6B' or sLftType == '7B' or sLftType == '8B' then + local dDeltaPos = dRadProfL - sqrt( ( dRadProfL * dRadProfL) - ((DGD.dT/2)*(DGD.dT/2))) + -- profilo sezione + nLftSezPath = EgtArc3P( nParLay, {-dDeltaPos,0,0}, {0,DGD.dT/2,0}, {-dDeltaPos,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nLftPath = EgtLine ( nParLay, {dDeltaPos,(DGD.dH*1.25),0}, {dDeltaPos,-(DGD.dH*0.25),0}, GDB_RT.GRID) + elseif sLftType == 'CV' then + local dDeltaPos = dRadProfL - sqrt( ( dRadProfL * dRadProfL) - (((DGD.dT/2)-dPlnProf)*((DGD.dT/2)-dPlnProf))) + -- profilo sezione + if dPlnProf > 0 then + local nLine1, nLine2, nArc + nLine1 = EgtLine ( nParLay, {0,0,0}, {0,dPlnProf,0}, GDB_RT.GRID) + nArc = EgtArc3P( nParLay, {0,dPlnProf,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT-dPlnProf,0}, GDB_RT.GRID) + nLine2 = EgtLine ( nParLay, {0,DGD.dT-dPlnProf,0}, {0,DGD.dT,0}, GDB_RT.GRID) + nLftSezPath = EgtCurveCompo( nParLay, {nLine1,nArc,nLine2}, true) + else + nLftSezPath = EgtArc3P( nParLay, {0,0,0}, {-dDeltaPos,DGD.dT/2,0}, {0,DGD.dT,0}, GDB_RT.GRID) + end + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nLftPath = EgtLine ( nParLay, {0,(DGD.dH*1.25),0}, {0,-(DGD.dH*0.25),0}, GDB_RT.GRID) + else -- profilo SQ o FDWC + -- profilo sezione + nLftSezPath = EgtLine ( nParLay, {0,0,0}, {0,DGD.dT,0}, GDB_RT.GRID) + -- percorsi guida + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + nLftPath = EgtLine ( nParLay, {0,(DGD.dH*1.25),0}, {0,-(DGD.dH*0.25),0}, GDB_RT.GRID) + end + + -- disegno la swept sinistra + local nSwL = EgtSurfTmSwept( nParLay, nLftSezPath, nLftPath,false, 0.05) + + -- se ci sono tutte le swept procedo a rastremarle + if nSwT and nSwBL and nSwBR and nSwR and nSwL then + + -- in base al profilo del top e se è in tangenza creo una superficie di appoggio + if DGD.TPL and sTopType ~= 'SQ' and sTopType ~= 'EB' and sTopType ~= 'FDWC' then + local nLine1, nLine2, nSwTmp + nLine1 = EgtLine( nParLay, {(DGD.dW/2),DGD.AMl,0}, {(DGD.dW/2),DGD.AMl,DGD.dT}) + nLine2 = EgtLine( nParLay, {-100,DGD.AMl,0}, {-100,DGD.AMl,DGD.dT}) +-- nLine1 = EgtLine( nParLay, {(DGD.Lda+DGD.dT),DGD.Adl+(DGD.dT*tan(60)),0}, {(DGD.Lua+DGD.dT),DGD.Aul+(DGD.dT*tan(60)),DGD.dT}) +-- nLine2 = EgtLine( nParLay, {-10,DGD.Adl-((10+DGD.Lda)*tan(60)),0}, {-10,DGD.Aul-((10+DGD.Lua)*tan(60)),DGD.dT}) + nSwTmp = EgtSurfTmRuled( nParLay, nLine2, nLine1, 0.05) + + if bDelete then + EgtErase( nLine1) + EgtErase( nLine2) + end + + -- somma tra le due superfici + EgtSurfTmAdd(nSwT,nSwTmp) + if nSwT then -- se ho una superficie sommata cancello la seconda + EgtErase( nSwTmp) + end + end + + -- estrapolo il percorso intersezione + EgtSurfTmSurfTmInters(nSwL,nSwT,nParLay) + -- trimmo la swept sinistra con la superiore + EgtSurfTmIntersect(nSwL,nSwT) + if nSwL then -- se ho una superficie trimmata cancello la seconda +-- EgtOutBox( 'trim ok', 'Trim', 'Trim') + EgtErase( nSwT) + else +-- EgtOutBox( 'trim bad', 'Error Trim', 'Error Trim') + return false + end + + -- in base al profilo del top e se è in tangenza creo una superficie di appoggio + if DGD.TPR and sTopType ~= 'SQ' and sTopType ~= 'EB' and sTopType ~= 'FDWC' then + local nLine1, nLine2, nSwTmp + nLine1 = EgtLine( nParLay, {DGD.dW+100,DGD.AMr,0}, {DGD.dW+100,DGD.AMr,DGD.dT}) + nLine2 = EgtLine( nParLay, {(DGD.dW/2),DGD.AMr,0}, {(DGD.dW/2),DGD.AMr,DGD.dT}) +-- nLine1 = EgtLine( nParLay, {DGD.dW+10,DGD.Adr-((DGD.dW-DGD.Rda+10)*tan(60)),0}, {DGD.dW+10,DGD.Aur-((DGD.dW-DGD.Rua+10)*tan(60)),DGD.dT}) +-- nLine2 = EgtLine( nParLay, {(DGD.Rda-DGD.dT),DGD.Adr+(DGD.dT*tan(60)),0}, {(DGD.Rua-DGD.dT),DGD.Aur+(DGD.dT*tan(60)),DGD.dT}) + nSwTmp = EgtSurfTmRuled( nParLay, nLine2, nLine1, 0.05) + + if bDelete then + EgtErase( nLine1) + EgtErase( nLine2) + end + + -- somma tra le due superfici + EgtSurfTmAdd(nSwL,nSwTmp) + if nSwL then -- se ho una superficie sommata cancello la seconda + EgtErase( nSwTmp) + end + end + + --debug +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- estrapolo il percorso intersezione + EgtSurfTmSurfTmInters(nSwL,nSwR,nParLay) + -- trimmo la swept sinistra/superiore con la destra + EgtSurfTmIntersect(nSwL,nSwR) + if nSwL then -- se ho una superficie trimmata cancello la seconda + EgtErase( nSwR) + else + return false + end + + -- estrapolo il percorso intersezione + EgtSurfTmSurfTmInters(nSwL,nSwBL,nParLay) + -- trimmo la swept sinistra/superiore/destra con la swept inferiore sinistra + EgtSurfTmIntersect(nSwL,nSwBL) + if nSwL then -- se ho una superficie trimmata cancello la seconda + EgtErase( nSwBL) + else + return false + end + + -- estrapolo il percorso intersezione + EgtSurfTmSurfTmInters(nSwL,nSwBR,nParLay) + -- trimmo la swept inferiore destra con la restante swept + EgtSurfTmIntersect(nSwL,nSwBR) + if nSwL then -- se ho una superficie trimmata cancello la seconda + EgtErase( nSwBR) + else + return false + end + + EgtSetName( nSwL, sSideName) + + --debug +-- EgtSaveFile( sNgeFile) +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + if bDelete then + -- cancello eventuali percorsi di costruzione + if nTopPath then + EgtErase(nTopPath) + end + if nToptSezPath then + EgtErase(nToptSezPath) + end + if nBotPathL then + EgtErase(nBotPathL) + end + if nBotPathR then + EgtErase(nBotPathR) + end + if nBotSezPath then + EgtErase(nBotSezPath) + end + if nRghtPath then + EgtErase(nRghtPath) + end + if nRghtSezPath then + EgtErase(nRghtSezPath) + end + if nLftPath then + EgtErase(nLftPath) + end + if nLftSezPath then + EgtErase(nLftSezPath) + end + end + + return true, ptMedArc, bJoinRgt, bJoinLft + else + return false + end +end + +----------------------------------------------------------------- +local function CreateDoor() + + local bInactive + + -- determinazione lato serratura + if DGD.sSwing == 'RH' or DGD.sSwing == 'RHR' or DGD.sSwing == 'RHA' or + DGD.sSwing == 'RHRI' or DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRA' then + DGD.Lock = 'L' + else + DGD.Lock = 'R' + end + + -- determinazione se apertura a spingere o tirare + if DGD.sSwing == 'RH' or DGD.sSwing == 'RHA' or DGD.sSwing == 'RHI' or + DGD.sSwing == 'LH' or DGD.sSwing == 'LHI' or DGD.sSwing == 'LHA' then + DGD.Push = true + else + DGD.Push = false + end + + if DGD.sSwing == 'LHI' or DGD.sSwing == 'RHI' or + DGD.sSwing == 'RHRI' or DGD.sSwing == 'LHRI' then + bInactive = true + end + + local sLocalLockPrf = DGD.tProfs.lockedge.trimming + local sLocalHingeProf = DGD.tProfs.hingeedge.trimming + + if string.find( DGD.tProfs.lockedge.trimming, 'BU') then + sLocalLockPrf = 'BU' + elseif string.find( DGD.tProfs.lockedge.trimming, 'BD') then + sLocalLockPrf = 'BD' + end + if string.find( DGD.tProfs.hingeedge.trimming, 'BU') then + sLocalHingeProf = 'BU' + elseif string.find( DGD.tProfs.hingeedge.trimming, 'BD') then + sLocalHingeProf = 'BD' + end + + -- Se porta inattiva + if bInactive then + -- Premessa: per definizione il profilo scritto indica la disposizione voluta, quindi se un profilo bevel è in opposizione + -- al parametro secure, allora indica il profilo opposto. + -- Se profilo serratura opposto al secure e diverso dal profilo hinge + if ( ( DGD.Push and DGD.sSecSide == 'UP' and sLocalLockPrf == 'BU' ) or + ( DGD.Push and DGD.sSecSide == 'DN' and sLocalLockPrf == 'BD' ) or + ( not DGD.Push and DGD.sSecSide == 'DN' and sLocalLockPrf == 'BU' ) or + ( not DGD.Push and DGD.sSecSide == 'UP' and sLocalLockPrf == 'BD' ) ) and + sLocalHingeProf ~= sLocalLockPrf then + DGD.bBothOppoBevel = true + else + DGD.bBothOppoBevel = false + end + else + -- determino se ho entrambe profili bevel e diversi tra loro + DGD.bBothOppoBevel = ( sLocalLockPrf == 'BU' or sLocalLockPrf == 'BD') and + ( sLocalHingeProf == 'BU' or sLocalHingeProf == 'BD') and + ( sLocalHingeProf ~= sLocalLockPrf) + end + + -- se porta non inactive e profilo hinge e lock con bevel discordanti emetto warning + if not bInactive and DGD.bBothOppoBevel then + -- Warning con outbox + DoorOutLog( string.format( EgtDoorsMsg[500], DGD.sSwing, DGD.tProfs.hingeedge.trimming, DGD.tProfs.lockedge.trimming), 0) + EgtOutBox( string.format(EgtDoorsMsg[500], DGD.sSwing, DGD.tProfs.hingeedge.trimming, DGD.tProfs.lockedge.trimming), EgtDoorsMsg[501], EgtDoorsMsg[502]) + end + + -- verifico congruenza tra presenza di profili bevel ed eventuale parametro 'secure' + local sBevelPrf + if sLocalHingeProf == 'BU' then sBevelPrf = 'BU' end + if not sBevelPrf and sLocalHingeProf == 'BD' then sBevelPrf = 'BD' end + if not sBevelPrf and sLocalLockPrf == 'BU' then sBevelPrf = 'BU' end + if not sBevelPrf and sLocalLockPrf == 'BD' then sBevelPrf = 'BD' end + + -- casi di parametri incongruenti ( solo su porta, nei frame il secure è sempre DN) + if DGD.sSecSide and sBevelPrf then -- se profilo bevel e parametro secure esistenti + if not DGD.sFrame then + if ( DGD.Push and sBevelPrf == 'BU' and DGD.sSecSide == 'UP' and not DGD.bBothOppoBevel) or + ( DGD.Push and sBevelPrf == 'BD' and DGD.sSecSide == 'DN' and not DGD.bBothOppoBevel) or + ( not DGD.Push and sBevelPrf == 'BU' and DGD.sSecSide == 'DN' and not DGD.bBothOppoBevel) or + ( not DGD.Push and sBevelPrf == 'BD' and DGD.sSecSide == 'UP' and not DGD.bBothOppoBevel) then + DoorOutLog( string.format( EgtDoorsMsg[544], DGD.sSwing, sBevelPrf, DGD.sSecSide), 0) + EgtOutBox( string.format( EgtDoorsMsg[544], DGD.sSwing, sBevelPrf, DGD.sSecSide), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + end + -- se non c'è il profilo bevel e neppure il secure + elseif ( not DGD.sSecSide or #DGD.sSecSide == 0) and not sBevelPrf and DGD.MachEn > 0 then + DoorOutLog( EgtDoorsMsg[545], 0) + EgtOutBox( EgtDoorsMsg[545], EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + + -- casi di incongruenza per frame: se posizione nel ddf non corrisponde con swing e tipo frame + if DGD.sFrame then + -- se frame sinistro + if nTypePiece == 3 then + -- se tipo hinge e lato serratura sinistro o tipo lock e lato serratura destro, incongruenza + if ( ( DGD.sFrame == 'H' or DGD.sFrame == 'HE') and DGD.Lock == 'L') or + ( ( DGD.sFrame == 'L' or DGD.sFrame == 'LE') and DGD.Lock == 'R') then + DoorOutLog( string.format( EgtDoorsMsg[609],EgtDoorsMsg[605], DGD.sFrame, DGD.Lock), 0) + EgtOutBox( string.format( EgtDoorsMsg[609], EgtDoorsMsg[605], DGD.sFrame, DGD.Lock), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + -- se frame destro + elseif nTypePiece == 4 then + -- se tipo hinge e lato serratura destro o tipo lock e lato serratura sinistro, incongruenza + if ( ( DGD.sFrame == 'H' or DGD.sFrame == 'HE') and DGD.Lock == 'R') or + ( ( DGD.sFrame == 'L' or DGD.sFrame == 'LE') and DGD.Lock == 'L') then + DoorOutLog( string.format( EgtDoorsMsg[609],EgtDoorsMsg[606], DGD.sFrame, DGD.Lock), 0) + EgtOutBox( string.format( EgtDoorsMsg[609], EgtDoorsMsg[606], DGD.sFrame, DGD.Lock), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + -- se frame top + elseif nTypePiece == 5 then + -- se tipo non top incongruenza + if DGD.nTypePz ~= 5 then + DoorOutLog( string.format( EgtDoorsMsg[609],EgtDoorsMsg[607], DGD.sFrame, '-'), 0) + EgtOutBox( string.format( EgtDoorsMsg[609], EgtDoorsMsg[607], DGD.sFrame, '-'), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + -- se frame bottom + elseif nTypePiece == 6 then + -- se tipo non bottom incongruenza + if DGD.nTypePz ~= 6 then + DoorOutLog( string.format( EgtDoorsMsg[609],EgtDoorsMsg[608], DGD.sFrame, '-'), 0) + EgtOutBox( string.format( EgtDoorsMsg[609], EgtDoorsMsg[608], DGD.sFrame, '-'), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + end + else + -- setto la variabile che indica che il top è effettivamente ad angolo e + -- il lato piatto è minore della larghezza porta - un delta + DGD.Tpa = DGD.tProfs.top.angle and abs(DGD.tProfs.top.angle) >= GEO.EPS_SMALL + DGD.Tpa = DGD.Tpa and DGD.tProfs.top.xdeltapos and DGD.tProfs.top.xdeltapos < ( DGD.dW - (2* DGD.dT * TAN3)) + -- se porta ad arco o con angolo con probe attivato do errore + if ( DGD.tProfs.top.radius or DGD.Tpa) and ( DGD.PROBE > 0 and DGC.NPM == 0) then + DoorOutLog( EgtDoorsMsg[628], 0) + EgtOutBox( EgtDoorsMsg[628], EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 0 + end + end + + -- setto le variabili profili per edge break (EB) + local tEbThProf = {} + local sFoundProfEb = '' + local sProfName = '' + + -- verifico (e correggo) se variabile globale per dimensione piano su profilo CV si avvicina alla metà spessore porta + if DGC.CVP and DGC.CVP >= ( DGD.dT*0.45) then DGC.CVP = 0 end + + -- tipo profilo lato sinistro + local sLeftType = GetRealEdgeTrimming( 'L') + local dRadProf = 0 + local dPlnProf = 0 + -- se profilo tondo ottengo il raggio per il confronto con lo spessore porta + if sLeftType == '1B' then dRadProf = DGC.B1 end + if sLeftType == '2B' then dRadProf = DGC.B2 end + if sLeftType == '3B' then dRadProf = DGC.B3 end + if sLeftType == '4B' then dRadProf = DGC.B4 end + if sLeftType == '5B' then dRadProf = DGC.B5 end + if sLeftType == '6B' then dRadProf = DGC.B6 end + if sLeftType == '7B' then dRadProf = DGC.B7 end + if sLeftType == '8B' then dRadProf = DGC.B8 end + if sLeftType == 'CV' then dRadProf = DGC.CV end + if sLeftType == 'CV' then dPlnProf = DGC.CVP or 0 end + local dRadProfL = dRadProf + -- se profilo edge break ottengo la tabella con gli spessori dei profili con gli errori per ogni profilo + if sLeftType == 'EB' or sLeftType == 'BUEB' or sLeftType == 'BDEB' then + tEbThProf = DGC.EB + sFoundProfEb = EgtIf( DGD.Lock == 'L', EgtDoorsMsg[519], EgtDoorsMsg[518]) .. ',' .. sFoundProfEb + sProfName = sLeftType + end + + if (sLeftType == 'BD' or sLeftType == 'BDEB' or sLeftType == 'BU' or sLeftType == 'BUEB') and not DGD.sFrame then + -- se lato sinistro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'L' and ( DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + -- inverto il profilo + sLeftType = SetInvertEdgeTrimming(sLeftType) + end + end + + -- tipo profilo lato destro + local sRightType = GetRealEdgeTrimming( 'R') + local dRadProfR = 0 + local dPlnProfR = 0 + -- se profilo tondo ottengo il raggio per il confronto con lo spessore porta + if sRightType == '1B' then dRadProfR = DGC.B1 end + if sRightType == '2B' then dRadProfR = DGC.B2 end + if sRightType == '3B' then dRadProfR = DGC.B3 end + if sRightType == '4B' then dRadProfR = DGC.B4 end + if sRightType == '5B' then dRadProfR = DGC.B5 end + if sRightType == '6B' then dRadProfR = DGC.B6 end + if sRightType == '7B' then dRadProfR = DGC.B7 end + if sRightType == '8B' then dRadProfR = DGC.B8 end + if sRightType == 'CV' then dRadProfR = DGC.CV end + if sRightType == 'CV' then dPlnProfR = DGC.CVP or 0 end + -- se profilo edge break ottengo la tabella con gli spessori dei profili con gli errori per ogni profilo + if sRightType == 'EB' or sRightType == 'BUEB' or sRightType == 'BDEB' then + tEbThProf = DGC.EB + sFoundProfEb = EgtIf( DGD.Lock == 'L', EgtDoorsMsg[518], EgtDoorsMsg[519]) .. ',' .. sFoundProfEb + sProfName = sRightType + end + + if ( sRightType == 'BD' or sRightType == 'BDEB' or sRightType == 'BU' or sRightType == 'BUEB') and not DGD.sFrame then + -- se lato destro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'R' and ( DGD.sSwing == 'LHI' or DGD.sSwing == 'LHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + -- inverto il profilo + sRightType = SetInvertEdgeTrimming(sRightType) + end + end + + -- tipo profilo lato top + local sTopType = GetRealEdgeTrimming( 'T') + local dRadProfT = 0 + local dPlnProfT = 0 + -- se profilo tondo ottengo il raggio per il confronto con lo spessore porta + if sTopType == '1B' then dRadProfT = DGC.B1 end + if sTopType == '2B' then dRadProfT = DGC.B2 end + if sTopType == '3B' then dRadProfT = DGC.B3 end + if sTopType == '4B' then dRadProfT = DGC.B4 end + if sTopType == '5B' then dRadProfT = DGC.B5 end + if sTopType == '6B' then dRadProfT = DGC.B6 end + if sTopType == '7B' then dRadProfT = DGC.B7 end + if sTopType == '8B' then dRadProfT = DGC.B8 end + if sTopType == 'CV' then dRadProfT = DGC.CV end + if sTopType == 'CV' then dPlnProfT = DGC.CVP or 0 end + -- se profilo edge break ottengo la tabella con gli spessori dei profili con gli errori per ogni profilo + if sTopType == 'EB' or sTopType == 'BUEB' or sTopType == 'BDEB' then + tEbThProf = DGC.EB + sFoundProfEb = EgtDoorsMsg[607] .. ',' .. sFoundProfEb + sProfName = sTopType + end + + -- tipo profilo lato bottom + local sBotType = GetRealEdgeTrimming( 'B') + local dRadProfB = 0 + local dPlnProfB = 0 + -- se profilo tondo ottengo il raggio per il confronto con lo spessore porta + if sBotType == '1B' then dRadProfB = DGC.B1 end + if sBotType == '2B' then dRadProfB = DGC.B2 end + if sBotType == '3B' then dRadProfB = DGC.B3 end + if sBotType == '4B' then dRadProfB = DGC.B4 end + if sBotType == '5B' then dRadProfB = DGC.B5 end + if sBotType == '6B' then dRadProfB = DGC.B6 end + if sBotType == '7B' then dRadProfB = DGC.B7 end + if sBotType == '8B' then dRadProfB = DGC.B8 end + if sBotType == 'CV' then dRadProfB = DGC.CV end + if sBotType == 'CV' then dPlnProfB = DGC.CVP or 0 end + -- se profilo edge break ottengo la tabella con gli spessori dei profili con gli errori per ogni profilo + if sBotType == 'EB' or sTopType == 'BUEB' or sTopType == 'BDEB' then + tEbThProf = DGC.EB + sFoundProfEb = EgtDoorsMsg[644] .. ',' .. sFoundProfEb + sProfName = sBotType + end + + ------------------------------------------------------------------------------ + -- verifica se il profilo EB è stato configurato nel file CurrDoorsCustomData + ------------------------------------------------------------------------------ + if not tEbThProf and #sFoundProfEb > 0 then + local sErrMess = string.format( EgtDoorsMsg[667], sProfName, sFoundProfEb) + return false, 2, sErrMess + end + + ------------------------------------------------------------------------------ + -- verifica del profilo EB nei lati destro, sinistro, sopra e sotto + -- in caso lo spessore è compatibile con uno dei profili, viene ridefinito anche + -- il valore della variabile di massimo errore ammesso sullo spessore tastato: DGC.Dt + ------------------------------------------------------------------------------ + -- se ho un profilo edge break (EB) verifico se gli spessori profili sono congruenti con lo spessore porta + if #tEbThProf > 0 then + + local bMatchprofile + + if #DGD.EBP > 0 then -- se ho già settato la compatibilità di profilo, evito di ricalcolarla + bMatchprofile = true + else + for i = 1, #tEbThProf do + -- se lo spessore porta è compreso tra lo spessore profilo + o - la tolleranza esco con match a true + if DGD.dT <= ( tEbThProf[i][1] + tEbThProf[i][2]) and DGD.dT >= ( tEbThProf[i][1] - tEbThProf[i][2]) then + bMatchprofile = true + DGD.EBP = string.format( '%s', i) -- setto la variabile globale con il numero profilo congruente + -- reinizializzo la variabile di errore massimo in tastatura dello spessore + if not DGD.sFrame and DGD.PROBE == 2 then + DGC.Dt = tEbThProf[i][2] + end + break + end + end + end + + if not bMatchprofile then + local sListThProf = '(' + for i = 1, #tEbThProf do + sListThProf = sListThProf .. string.format( EgtDoorsMsg[642], i, EgtToUiUnits(tEbThProf[i][1])) .. ',' + end + sListThProf = sListThProf .. ')' + local sErrMess = string.format( EgtDoorsMsg[643], sProfName, sFoundProfEb, EgtToUiUnits(DGD.dT), sProfName, sListThProf) + return false, 2, sErrMess + end + end + + -- se non è un frame e la tabella è completa, ricreo pezzo porta + if not DGD.sFrame and DGD.PROBE == 2 then + + -- ricostruisco la geometria porta dai punti tastati + local dLungMax, dLarghMax = RemakeDoor( sLeftType, dRadProf, sRightType, dRadProfR, dPlnProf, dPlnProfR) + bRemake = true -- setto il flag per indicare che la funzione RemakeDoor è stata fatta + + -- verifico se le dimensioni ricavate differiscono molto dalle dimensioni originarie + if ( abs( dLungMax - DGD.dH) > DGC.Dh) or ( abs( dLarghMax - DGD.dW) > DGC.Dw) or + ( abs( tProbeDoor.PZ - DGD.dT) > DGC.Dt) then + DoorOutLog( string.format( EgtDoorsMsg[629], + EgtNumToString( EgtToUiUnits(dLungMax), 4), EgtNumToString( EgtToUiUnits(dLarghMax), 4), EgtNumToString( EgtToUiUnits(tProbeDoor.PZ), 4), + EgtToUiUnits(DGC.Dh), EgtToUiUnits(DGC.Dw), EgtToUiUnits(DGC.Dt), + EgtToUiUnits(DGD.dH), EgtToUiUnits(DGD.dW), EgtToUiUnits(DGD.dT)), 0) + EgtOutBox( string.format( EgtDoorsMsg[629], + EgtNumToString( EgtToUiUnits(dLungMax), 4), EgtNumToString( EgtToUiUnits(dLarghMax), 4), EgtNumToString( EgtToUiUnits(tProbeDoor.PZ), 4), + EgtToUiUnits(DGC.Dh), EgtToUiUnits(DGC.Dw), EgtToUiUnits(DGC.Dt), + EgtToUiUnits(DGD.dH), EgtToUiUnits(DGD.dW), EgtToUiUnits(DGD.dT)), EgtDoorsMsg[476], EgtDoorsMsg[477]) + return false, 1 + else -- altrimenti le dimensioni accettate, scrivo le note con le dimensioni calcolate + EgtSetInfo( DGD.PZ, 'ProbeDoorWidth', EgtToUiUnits(dLarghMax)) + EgtSetInfo( DGD.PZ, 'ProbeDoorHeight', EgtToUiUnits(dLungMax)) + EgtSetInfo( DGD.PZ, 'ProbeDoorThick', EgtToUiUnits(tProbeDoor.PZ)) + end + end + + ----------------- + -- lato sinistro + ----------------- + + -- assegno a variabile globale + if DGD.Lock == 'R' then + DGD.RPH = dRadProf + DGD.PPH = dPlnProf + DGD.RPL = dRadProfR + DGD.PPL = dPlnProfR + end + + -- verifico se lo spessore porta è congruente con il raggio profilo + if dRadProf > 0 then + if ( DGD.dT - (2*dPlnProf)) > (2*dRadProf) then + DoorOutLog( string.format( EgtDoorsMsg[433], ( DGD.dT - (2*dPlnProf)), sLeftType, dRadProf), 0) + return false, 0 + end + end + + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 5 then -- se frame SX o TOP + DGD.Ulb = DGD.dT + DGD.Urb = DGD.dT + DGD.Ult = DGD.dT + DGD.Urt = DGD.dT + elseif nTypePiece == 4 or nTypePiece == 6 then -- se frame DX o BOTTOM + DGD.Drb = 0 + DGD.Dlb = 0 + DGD.Drt = 0 + DGD.Dlt = 0 + end + else + if DGD.PROBE == 2 and bRemake then + DGD.Lut = DGD.P7:getX() + DGD.Lub = DGD.P1:getX() + DGD.Ldt = DGD.P10:getX() + DGD.Ldb = DGD.P4:getX() + else + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Ldt = 0 + DGD.Ldb = 0 + end + end + elseif sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB'then + if DGD.sFrame then + -- se frame left e BD + if ( nTypePiece == 3 and ( sLeftType == 'BD' or sLeftType == 'BDEB')) then + DGD.Ulb = DGD.dT - ( DGD.dW * TAN3) + DGD.Ult = DGD.Ulb + DGD.Urb = DGD.dT + DGD.Urt = DGD.dT + -- se frame left e BU + elseif ( nTypePiece == 3 and ( sLeftType == 'BU' or sLeftType == 'BUEB')) then + DGD.Urb = DGD.dT - ( DGD.dW * TAN3) + DGD.Urt = DGD.Urb + DGD.Ulb = DGD.dT + DGD.Ult = DGD.dT + -- se frame right e BD + elseif ( nTypePiece == 4 and ( sLeftType == 'BD' or sLeftType == 'BDEB')) then + DGD.Dlb = 0 + DGD.Dlt = 0 + DGD.Drb = ( DGD.dW * TAN3) + DGD.Drt = DGD.Drb + -- se frame right e BU + elseif ( nTypePiece == 4 and ( sLeftType == 'BU' or sLeftType == 'BUEB')) then + DGD.Drb = 0 + DGD.Drt = 0 + DGD.Dlb = ( DGD.dW * TAN3) + DGD.Dlt = DGD.Dlb + elseif nTypePiece == 5 then -- se frame top + if sLeftType == 'BD' or sLeftType == 'BDEB' then + DGD.Ulb = DGD.dT + DGD.Urb = DGD.dT + DGD.Ult = DGD.dT - ( DGD.dH * TAN3) + DGD.Urt = DGD.Ult + elseif sLeftType == 'BU' or sLeftType == 'BUEB' then + DGD.Ulb = DGD.dT - ( DGD.dH * TAN3) + DGD.Urb = DGD.Ulb + DGD.Ult = DGD.dT + DGD.Urt = DGD.dT + end + elseif nTypePiece == 6 then -- se frame bottom + if sLeftType == 'BD' or sLeftType == 'BDEB' then + DGD.Drb = ( DGD.dH * TAN3) + DGD.Dlb = DGD.Drb + DGD.Drt = 0 + DGD.Dlt = 0 + elseif sLeftType == 'BU' or sLeftType == 'BUEB' then + DGD.Drb = 0 + DGD.Dlb = 0 + DGD.Drt = ( DGD.dH * TAN3) + DGD.Dlt = DGD.Drt + end + end + else + if DGD.PROBE == 2 and bRemake then + DGD.Lut = DGD.P7:getX() + DGD.Lub = DGD.P1:getX() + DGD.Ldt = DGD.P10:getX() + DGD.Ldb = DGD.P4:getX() + else + -- se lato sinistro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'L' and ( DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + if DGD.Push then + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Ldt = DGD.dT * TAN3 + DGD.Ldb = DGD.Ldt + else + DGD.Lut = DGD.dT * TAN3 + DGD.Lub = DGD.Lut + DGD.Ldt = 0 + DGD.Ldb = 0 + end + else -- altrimenti normale + if DGD.Push then + DGD.Lut = DGD.dT * TAN3 + DGD.Lub = DGD.Lut + DGD.Ldt = 0 + DGD.Ldb = 0 + else + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Ldt = DGD.dT * TAN3 + DGD.Ldb = DGD.Ldt + end + end + end + end + elseif sLeftType == '1B' or sLeftType == '2B' or sLeftType == '3B' or sLeftType == '4B' or + sLeftType == '5B' or sLeftType == '6B' or sLeftType == '7B' or sLeftType == '8B' then + if DGD.PROBE == 2 and bRemake then + DGD.Lut = DGD.P7:getX() + DGD.Lub = DGD.P1:getX() + DGD.Ldt = DGD.P10:getX() + DGD.Ldb = DGD.P4:getX() + DGD.Lmb = DGD.P5:getX() + DGD.Lmt = DGD.P11:getX() + else + DGD.Lut = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + DGD.Lub = DGD.Lut + DGD.Ldt = DGD.Lut + DGD.Ldb = DGD.Lut + DGD.Lm = 0 + end + elseif sLeftType == 'CV' then + if DGD.PROBE == 2 and bRemake then + DGD.Lut = DGD.P7:getX() + DGD.Lub = DGD.P1:getX() + DGD.Ldt = DGD.P10:getX() + DGD.Ldb = DGD.P4:getX() + DGD.Lmb = DGD.P5:getX() + DGD.Lmt = DGD.P11:getX() + else + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Ldt = 0 + DGD.Ldb = 0 + DGD.Lm = dRadProf - sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProf)*((DGD.dT/2)-dPlnProf))) + end + end + + -- setto punti relativi allo spessore + SetFrameThickValues( true) + + ----------------- + -- lato destro + ----------------- + + -- assegno a variabile globale + if DGD.Lock == 'L' then + DGD.RPH = dRadProfR + DGD.PPH = dPlnProfR + DGD.RPL = dRadProf + DGD.PPL = dPlnProf + end + + dRadProf = dRadProfR -- assegno il valore del raggio profilo + + -- verifico se lo spessore porta è congruente con il raggio profilo + if dRadProf > 0 then + if ( DGD.dT - (2*dPlnProfR)) > (2*dRadProf) then + DoorOutLog( string.format( EgtDoorsMsg[433], ( DGD.dT - (2*dPlnProfR)), sRightType, dRadProf), 0) + return false, 0 + end + end + + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 5 then -- se frame SX o TOP + DGD.Drb = 0 + DGD.Dlb = 0 + DGD.Drt = 0 + DGD.Dlt = 0 + elseif nTypePiece == 4 or nTypePiece == 6 then -- se frame DX o BOTTOM + DGD.Ulb = DGD.dT + DGD.Urb = DGD.dT + DGD.Ult = DGD.dT + DGD.Urt = DGD.dT + end + else + if DGD.PROBE == 2 and bRemake then + DGD.Rub = DGD.P2:getX() + DGD.Rut = DGD.P8:getX() + DGD.Rdb = DGD.P3:getX() + DGD.Rdt = DGD.P9:getX() + else + DGD.Rub = DGD.dW + DGD.Rut = DGD.dW + DGD.Rdb = DGD.dW + DGD.Rdt = DGD.dW + end + end + elseif sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' then + + if DGD.sFrame then + -- se frame left e BD + if ( nTypePiece == 3 and ( sRightType == 'BD' or sRightType == 'BDEB')) then + DGD.Dlb = ( DGD.dW * TAN3) + DGD.Dlt = DGD.Dlb + DGD.Drb = 0 + DGD.Drt = 0 + -- se frame left e BU + elseif ( nTypePiece == 3 and ( sLeftType == 'BU' or sLeftType == 'BUEB')) then + DGD.Drb = ( DGD.dW * TAN3) + DGD.Drt = DGD.Drb + DGD.Dlb = 0 + DGD.Dlt = 0 + -- se frame right e BU + elseif ( nTypePiece == 4 and ( sRightType == 'BU' or sRightType == 'BUEB')) then + DGD.Ulb = DGD.dT - ( DGD.dW * TAN3) + DGD.Ult = DGD.Ulb + DGD.Urb = DGD.dT + DGD.Urt = DGD.dT + -- se frame right e BD + elseif ( nTypePiece == 4 and ( sRightType == 'BD' or sRightType == 'BDEB')) then + DGD.Urb = DGD.dT - ( DGD.dW * TAN3) + DGD.Urt = DGD.Urb + DGD.Ulb = DGD.dT + DGD.Ult = DGD.dT + elseif nTypePiece == 5 then -- se frame top + if sRightType == 'BD' or sRightType == 'BDEB' then + DGD.Dlb = 0 + DGD.Drb = 0 + DGD.Dlt = ( DGD.dH * TAN3) + DGD.Drt = DGD.Dlt + elseif sRightType == 'BU' or sRightType == 'BUEB'then + DGD.Dlb = ( DGD.dH * TAN3) + DGD.Drb = DGD.Dlb + DGD.Dlt = 0 + DGD.Drt = 0 + end + elseif nTypePiece == 6 then -- se frame bottom + if sRightType == 'BD' or sRightType == 'BDEB' then + DGD.Urb = DGD.dT - ( DGD.dH * TAN3) + DGD.Ulb = DGD.Urb + DGD.Urt = DGD.dT + DGD.Ult = DGD.dT + elseif sRightType == 'BU' or sRightType == 'BUEB' then + DGD.Urb = DGD.dT + DGD.Ulb = DGD.dT + DGD.Urt = DGD.dT - ( DGD.dH * TAN3) + DGD.Ult = DGD.Urt + end + end + else + if DGD.PROBE == 2 and bRemake then + DGD.Rub = DGD.P2:getX() + DGD.Rut = DGD.P8:getX() + DGD.Rdb = DGD.P3:getX() + DGD.Rdt = DGD.P9:getX() + else + -- se lato destro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'R' and ( DGD.sSwing == 'LHI' or DGD.sSwing == 'LHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + if DGD.Push then + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + DGD.Rdt = DGD.dW - ( DGD.dT * TAN3) + DGD.Rdb = DGD.Rdt + else + DGD.Rut = DGD.dW - ( DGD.dT * TAN3) + DGD.Rub = DGD.Rut + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + end + else -- altrimenti normale + if DGD.Push then + DGD.Rut = DGD.dW - ( DGD.dT * TAN3) + DGD.Rub = DGD.Rut + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + else + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + DGD.Rdt = DGD.dW - ( DGD.dT * TAN3) + DGD.Rdb = DGD.Rdt + end + end + end + end + elseif sRightType == '1B' or sRightType == '2B' or sRightType == '3B' or sRightType == '4B' or + sRightType == '5B' or sRightType == '6B' or sRightType == '7B' or sRightType == '8B' then + if DGD.PROBE == 2 and bRemake then + DGD.Rub = DGD.P2:getX() + DGD.Rut = DGD.P8:getX() + DGD.Rdb = DGD.P3:getX() + DGD.Rdt = DGD.P9:getX() + DGD.Rmb = DGD.P6:getX() + DGD.Rmt = DGD.P12:getX() + else + DGD.Rut = DGD.dW - dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + DGD.Rub = DGD.Rut + DGD.Rdt = DGD.Rut + DGD.Rdb = DGD.Rut + DGD.Rm = DGD.dW + end + elseif sRightType == 'CV' then + if DGD.PROBE == 2 and bRemake then + DGD.Rub = DGD.P2:getX() + DGD.Rut = DGD.P8:getX() + DGD.Rdb = DGD.P3:getX() + DGD.Rdt = DGD.P9:getX() + DGD.Rmb = DGD.P6:getX() + DGD.Rmt = DGD.P12:getX() + else + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + DGD.Rm = DGD.dW + sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfR)*((DGD.dT/2)-dPlnProfR))) - dRadProf + end + end + + -- setto punti relativi allo spessore + SetFrameThickValues() + + ----------------- + -- lato top + ----------------- + dRadProf = dRadProfT -- setto il valore del raggio profilo + -- assegno a variabile globale + DGD.RPT = dRadProf + DGD.PPT = dPlnProfT + + -- verifico se lo spessore porta è congruente con il raggio profilo + if dRadProf > 0 then + if ( DGD.dT - (2*dPlnProfT)) > (2*dRadProf) then + DoorOutLog( string.format( EgtDoorsMsg[433], ( DGD.dT - (2*dPlnProfT)), sRightType, dRadProf), 0) + return false, 0 + end + end + + -- Nei frame top e bottom sempre SQ o FDWC + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 4 then -- se frame SX o DX + DGD.Bul = 0 + DGD.Bur = 0 + DGD.Bdl = 0 + DGD.Bdr = 0 + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + elseif nTypePiece == 5 or nTypePiece == 6 then -- se frame TOP o BOTTOM + DGD.Lut = 0 + DGD.Lub = 0 + DGD.Ldt = 0 + DGD.Ldb = 0 + DGD.Rut = DGD.dW + DGD.Rub = DGD.dW + DGD.Rdt = DGD.dW + DGD.Rdb = DGD.dW + end + else + if DGD.PROBE == 2 and bRemake then + DGD.Bul = DGD.P1:getY() + DGD.Bur = DGD.P2:getY() + DGD.Bdl = DGD.P4:getY() + DGD.Bdr = DGD.P3:getY() + DGD.Bml = DGD.P5:getY() + DGD.Bmr = DGD.P6:getY() + DGD.Tul = DGD.P7:getY() + DGD.Tur = DGD.P8:getY() + DGD.Tdl = DGD.P10:getY() + DGD.Tdr = DGD.P9:getY() + DGD.Tml = DGD.P11:getY() + DGD.Tmr = DGD.P12:getY() + else + if sTopType == 'SQ' or sTopType == 'EB' or sTopType == 'FDWC' then + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + DGD.Tml = DGD.dH + DGD.Tmr = DGD.dH + elseif sTopType == 'BD' or sTopType == 'BU' or sTopType == 'BDEB' or sTopType == 'BUEB' then + if DGD.Push then + DGD.Tul = DGD.dH - ( DGD.dT * TAN3) + DGD.Tur = DGD.Tul + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + DGD.Tml = DGD.dH - ( DGD.dT * TAN3)/2 + DGD.Tmr = DGD.Tml + else + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + DGD.Tdl = DGD.dH - ( DGD.dT * TAN3) + DGD.Tdr = DGD.Tdl + DGD.Tml = DGD.dH - ( DGD.dT * TAN3)/2 + DGD.Tmr = DGD.Tml + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + DGD.Tul = DGD.dH - dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + DGD.Tur = DGD.Tul + DGD.Tdl = DGD.Tul + DGD.Tdr = DGD.Tul + DGD.Tml = DGD.dH + DGD.Tmr = DGD.dH + elseif sTopType == 'CV' then + DGD.Tul = DGD.dH + DGD.Tur = DGD.dH + DGD.Tdl = DGD.dH + DGD.Tdr = DGD.dH + DGD.Tml = DGD.dH - dRadProf + sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + DGD.Tmr = DGD.Tml + end + + -- se top è ad arco + if DGD.tProfs.top.radius then + + if not DGD.tProfs.top.xdeltapos then + DGD.tProfs.top.xdeltapos = 0 + end + + -- calcolo il delta y dell'arco + -- se centro arco è compreso nella larghezza porta + if abs(DGD.tProfs.top.xdeltapos) <= (DGD.dW/2) then + DGD.tProfs.top.ydeltapos = DGD.tProfs.top.radius + else -- altrimenti è esterno + DGD.tProfs.top.ydeltapos = CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos)), nil, DGD.tProfs.top.radius) + end + + -- verifico se ho una tangenza con l'arco + if abs( abs(DGD.tProfs.top.xdeltapos) + (DGD.dW/2) - DGD.tProfs.top.radius) <= GEO.EPS_SMALL then + if DGD.tProfs.top.xdeltapos < 0 then -- se centro arco verso X- la tangenza è a destra + DGD.TPR = DGD.dH-DGD.tProfs.top.ydeltapos + elseif DGD.tProfs.top.xdeltapos > 0 then -- se centro arco verso X+ la tangenza è a sinistra + DGD.TPL = DGD.dH-DGD.tProfs.top.ydeltapos + else -- entrambe le tangenze + DGD.TPR = DGD.dH-DGD.tProfs.top.ydeltapos + DGD.TPL = DGD.TPR + end + end + + if sTopType == 'SQ' or sTopType == 'EB' or sTopType == 'FDWC' then -- se top con profilo diritto prendo i valori dai fianchi + DGD.Rua = DGD.Rut + DGD.Rda = DGD.Rdt + DGD.Rma = DGD.Rm + DGD.Lua = DGD.Lut + DGD.Lda = DGD.Ldt + DGD.Lma = DGD.Lm + elseif sTopType == 'BD' or sTopType == 'BDEB' then + -- se la quota X dell'arco è interna al fianco tengo quella dell'arco + if DGD.dW - DGD.Rut >= GEO.EPS_SMALL then + DGD.Rua = DGD.Rut + else + DGD.Rua = DGD.dW + end + if DGD.Rdt <= (DGD.dW - ( DGD.dT * TAN3)) then + DGD.Rda = DGD.Rdt + else + if not DGD.TPR then + if sRightType == 'CV' or sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + DGD.Rda = DGD.dW + else + DGD.Rda = DGD.dW - ( DGD.dT * TAN3) + end + else + DGD.Rda = DGD.dW - ( DGD.dT * TAN3) + end + end + if DGD.Lut >= GEO.EPS_SMALL then + DGD.Lua = DGD.Lut + else + DGD.Lua = 0 + end + if DGD.Ldt >= ( DGD.dT * TAN3) then + DGD.Lda = DGD.Ldt + else + if not DGD.TPL then + if sLeftType == 'CV' or sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + DGD.Lda = 0 + else + DGD.Lda = ( DGD.dT * TAN3) + end + else + DGD.Lda = ( DGD.dT * TAN3) + end + end + elseif sTopType == 'BU' or sTopType == 'BUEB' then + if DGD.Rut <= (DGD.dW - ( DGD.dT * TAN3)) then + DGD.Rua = DGD.Rut + else + if not DGD.TPR then + if sRightType == 'CV' or sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + DGD.Rua = DGD.dW + else + DGD.Rua = DGD.dW - ( DGD.dT * TAN3) + end + else + DGD.Rua = DGD.dW - ( DGD.dT * TAN3) + end + end + if DGD.Rdt <= DGD.dW then + DGD.Rda = DGD.Rdt + else + DGD.Rda = DGD.dW + end + if DGD.Lut >= ( DGD.dT * TAN3) then + DGD.Lua = DGD.Lut + else + if not DGD.TPL then + if sLeftType == 'CV' or sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + DGD.Lua = 0 + else + DGD.Lua = ( DGD.dT * TAN3) + end + else + DGD.Lua = ( DGD.dT * TAN3) + end + end + if DGD.Ldt >= 0 then + DGD.Lda = DGD.Ldt + else + DGD.Lda = 0 + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + if DGD.Rut <= (DGD.dW - ( dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) then + DGD.Rua = DGD.Rut + else + DGD.Rua = DGD.dW - dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + end + if DGD.Rdt <= (DGD.dW - ( dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))))) then + DGD.Rda = DGD.Rdt + else + DGD.Rda = DGD.dW - dRadProf + sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + end + DGD.Rma = DGD.dW + if DGD.Lut >= ( dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2)))) then + DGD.Lua = DGD.Lut + else + DGD.Lua = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + end + if DGD.Ldt >= ( dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2)))) then + DGD.Lda = DGD.Ldt + else + DGD.Lda = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + end + DGD.Lma = 0 + elseif sTopType == 'CV' then + if DGD.dW - DGD.Rut >= GEO.EPS_SMALL then + DGD.Rua = DGD.Rut + else + DGD.Rua = DGD.dW + end + if DGD.dW - DGD.Rdt >= GEO.EPS_SMALL then + DGD.Rda = DGD.Rdt + else + DGD.Rda = DGD.dW + end + DGD.Rma = DGD.dW - dRadProf + sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + if DGD.Lut >= GEO.EPS_SMALL then + DGD.Lua = DGD.Lut + else + DGD.Lua = 0 + end + if DGD.Ldt >= GEO.EPS_SMALL then + DGD.Lda = DGD.Ldt + else + DGD.Lda = 0 + end + DGD.Lma = dRadProf - sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + end + + local dDistRad = 0 + local dDistRadCv = 0 + + if sTopType == 'BD' or sTopType == 'BDEB' then -- se top bevel down + DGD.Adt = ( DGD.dT * TAN3) + DGD.Amt = DGD.Adt / 2 + elseif sTopType == 'BU' or sTopType == 'BUEB' then + DGD.Aut = ( DGD.dT * TAN3) + DGD.Amt = DGD.Aut / 2 + elseif sTopType == 'CV' then + dDistRadCv = dRadProf - sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + dDistRad = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + end + + -- valori x max arco + DGD.LMa = 0 + DGD.RMa = DGD.dW + -- valori x min arco + DGD.lma = dDistRadCv + (DGD.Amt*2) + DGD.rma = DGD.dW - dDistRadCv - (DGD.Amt*2) + + -- valori in Z arco + DGD.Ula = DGD.dT + DGD.Ura = DGD.dT + DGD.Dra = 0 + DGD.Dla = 0 + DGD.Mla = DGD.dT / 2 + DGD.Mra = DGD.dT / 2 + + -- se centro arco è compreso nella larghezza porta + if abs(DGD.tProfs.top.xdeltapos) <= (DGD.dW/2) then + DGD.Aul = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) + DGD.tProfs.top.xdeltapos - DGD.Lua), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adl = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) + DGD.tProfs.top.xdeltapos - DGD.Lda), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aur = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) - DGD.tProfs.top.xdeltapos - (DGD.dW - DGD.Rua)), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adr = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) - DGD.tProfs.top.xdeltapos - (DGD.dW - DGD.Rda)), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aml = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) + DGD.tProfs.top.xdeltapos - DGD.Lma), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + DGD.Amr = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) - DGD.tProfs.top.xdeltapos - (DGD.dW - DGD.Rma)), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + -- punti con ingombro max + DGD.AMl = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) + DGD.tProfs.top.xdeltapos - DGD.LMa), nil, DGD.tProfs.top.radius) + DGD.AMr = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) - DGD.tProfs.top.xdeltapos - (DGD.dW - DGD.RMa)), nil, DGD.tProfs.top.radius) + -- punti con ingombro min per profilo CV + DGD.aml = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) + DGD.tProfs.top.xdeltapos - DGD.lma), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + DGD.amr = DGD.dH - DGD.tProfs.top.radius + CalcSideRectTringle( ((DGD.dW/2) - DGD.tProfs.top.xdeltapos - (DGD.dW - DGD.rma)), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + else -- altrimenti è esterno + if DGD.tProfs.top.xdeltapos > 0 then -- se centro arco è a destra + DGD.Aul = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - DGD.Lua), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adl = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - DGD.Lda), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aur = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rua)), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rda)), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aml = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - DGD.Lma), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + DGD.Amr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rma)), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + -- punti con ingombro max + DGD.AMl = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - DGD.LMa), nil, DGD.tProfs.top.radius) + DGD.AMr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.RMa)), nil, DGD.tProfs.top.radius) + -- punti con ingombro min per profilo CV + DGD.aml = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - DGD.lma), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + DGD.amr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.rma)), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + else -- altrimenti centro arco è a sinistra + DGD.Aul = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - DGD.Lua), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adl = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - DGD.Lda), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aur = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rua)), nil, ( DGD.tProfs.top.radius - DGD.Aut-dDistRad)) + DGD.Adr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rda)), nil, ( DGD.tProfs.top.radius - DGD.Adt-dDistRad)) + DGD.Aml = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - DGD.Lma), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + DGD.Amr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.Rma)), nil, ( DGD.tProfs.top.radius - DGD.Amt-dDistRad)) + -- punti con ingombro max + DGD.AMl = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - DGD.LMa), nil, DGD.tProfs.top.radius) + DGD.AMr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.RMa)), nil, DGD.tProfs.top.radius) + -- punti con ingombro min per profilo CV + DGD.aml = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) - abs(DGD.tProfs.top.xdeltapos) - DGD.lma), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + DGD.amr = DGD.dH - DGD.tProfs.top.ydeltapos + CalcSideRectTringle( ((DGD.dW/2) + abs(DGD.tProfs.top.xdeltapos) - (DGD.dW - DGD.rma)), nil, ( DGD.tProfs.top.radius - dDistRadCv - (DGD.Amt*2))) + end + end + elseif DGD.Tpa then -- se top ad angolo + + if not DGD.tProfs.top.xdeltapos then + DGD.tProfs.top.xdeltapos = 0 + end + if DGD.tProfs.top.xdeltapos <= (2* DGD.dT * TAN3) and + ( sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB') and + ( sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB') then + DGD.tProfs.top.xdeltapos = 0 + end + if sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB' or sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'FDWC' then + DGD.Lua = DGD.Lut + DGD.Lda = DGD.Ldt + DGD.Lma = (DGD.Lut + DGD.Ldt) / 2 + else + DGD.Lua = DGD.Lut + DGD.Lda = DGD.Lua + DGD.Lma = DGD.Lm + end + + if sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' or sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'FDWC' then + DGD.Rua = DGD.Rut + DGD.Rda = DGD.Rdt + DGD.Rma = (DGD.Rut + DGD.Rdt) / 2 + else + DGD.Rua = DGD.Rut + DGD.Rda = DGD.Rua + DGD.Rma = DGD.Rm + end + + if sTopType == 'BD' or sTopType == 'BDEB' then -- se top bevel down + DGD.Adt = ( DGD.dT * TAN3) + DGD.Amt = DGD.Adt / 2 + DGD.Dpd = DGD.Adt / abs(cos(DGD.tProfs.top.angle)) + elseif sTopType == 'BU' or sTopType == 'BUEB' then + DGD.Aut = ( DGD.dT * TAN3) + DGD.Amt = DGD.Aut / 2 + DGD.Dpu = DGD.Aut / abs(cos(DGD.tProfs.top.angle)) + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + DGD.Adt = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + DGD.Aut = DGD.Adt + DGD.Dpu = DGD.Adt / abs(cos(DGD.tProfs.top.angle)) + DGD.Dpd = DGD.Dpu + elseif sTopType == 'CV' then + DGD.Amt = dRadProf - sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfT)*((DGD.dT/2)-dPlnProfT))) + DGD.Dpm = DGD.Amt / abs(cos(DGD.tProfs.top.angle)) + end + + DGD.Ula = DGD.dT + DGD.Ura = DGD.dT + DGD.Dra = 0 + DGD.Dla = 0 + DGD.Mla = DGD.dT / 2 + DGD.Mra = DGD.dT / 2 + + -- se angolo positivo + if DGD.tProfs.top.angle > 0 then + DGD.Aul = DGD.dH - (( DGD.dW - DGD.tProfs.top.xdeltapos - DGD.Lua) * tan( DGD.tProfs.top.angle)) - DGD.Dpu + DGD.Adl = DGD.dH - (( DGD.dW - DGD.tProfs.top.xdeltapos - DGD.Lda) * tan( DGD.tProfs.top.angle)) - DGD.Dpd + DGD.Aur = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Aut, ((( DGD.dW - DGD.Rua) * tan( DGD.tProfs.top.angle)) + DGD.Dpu)) + DGD.Adr = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Adt, ((( DGD.dW - DGD.Rda) * tan( DGD.tProfs.top.angle)) + DGD.Dpd)) + DGD.Aml = DGD.dH - (( DGD.dW - DGD.tProfs.top.xdeltapos - DGD.Lma) * tan( DGD.tProfs.top.angle)) - DGD.Amt + DGD.Amr = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Amt, ((( DGD.dW - DGD.Rma) * tan( DGD.tProfs.top.angle)) + DGD.Dpm)) + else + DGD.Aul = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Aut, (( DGD.Lua * tan( abs(DGD.tProfs.top.angle))) + DGD.Dpu)) + DGD.Adl = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Adt, (( DGD.Lda * tan( abs(DGD.tProfs.top.angle))) + DGD.Dpd)) + DGD.Aur = DGD.dH - (( DGD.Rua - DGD.tProfs.top.xdeltapos) * tan( abs(DGD.tProfs.top.angle))) - DGD.Dpu + DGD.Adr = DGD.dH - (( DGD.Rda - DGD.tProfs.top.xdeltapos) * tan( abs(DGD.tProfs.top.angle))) - DGD.Dpd + DGD.Aml = DGD.dH - EgtIf( DGD.tProfs.top.xdeltapos > 0, DGD.Amt, (( DGD.Lma * tan( abs(DGD.tProfs.top.angle))) + DGD.Dpm)) + DGD.Amr = DGD.dH - (( DGD.Rma - DGD.tProfs.top.xdeltapos) * tan( abs(DGD.tProfs.top.angle))) - DGD.Amt + end + + -- punti intersezione curva sopra + if DGD.tProfs.top.xdeltapos > 0 then + local dTempU = DGD.Aut + local dTempD = DGD.Adt + local dTempM = DGD.Amt + DGD.Aut = DGD.dH - DGD.Aut + DGD.Adt = DGD.dH - DGD.Adt + DGD.Amt = DGD.dH - DGD.Amt + -- se angolo positivo + if DGD.tProfs.top.angle > 0 then + DGD.Cmu = DGD.dW - DGD.tProfs.top.xdeltapos + ( dTempU * tan(DGD.tProfs.top.angle/2)) + DGD.Cmd = DGD.dW - DGD.tProfs.top.xdeltapos + ( dTempD * tan(DGD.tProfs.top.angle/2)) + DGD.Cmm = DGD.dW - DGD.tProfs.top.xdeltapos + ( dTempM * tan(DGD.tProfs.top.angle/2)) + else + DGD.Cmu = DGD.tProfs.top.xdeltapos + ( dTempU * tan(DGD.tProfs.top.angle/2)) + DGD.Cmd = DGD.tProfs.top.xdeltapos + ( dTempD * tan(DGD.tProfs.top.angle/2)) + DGD.Cmm = DGD.tProfs.top.xdeltapos + ( dTempM * tan(DGD.tProfs.top.angle/2)) + end + end + end + end + end + + ----------------- + -- lato bottom + ----------------- + dRadProf = dRadProfB -- setto il valore del raggio profilo + -- assegno a variabile globale + DGD.RPB = dRadProf + DGD.PPB = dPlnProfB + + -- verifico se lo spessore porta è congruente con il raggio profilo + if dRadProf > 0 then + if ( DGD.dT - (2*dPlnProfB)) > (2*dRadProf) then + DoorOutLog( string.format( EgtDoorsMsg[433], ( DGD.dT - (2*dPlnProfB)), sRightType, dRadProf), 0) + return false, 0 + end + end + + if not DGD.sFrame then + + if not( DGD.PROBE == 2 and bRemake) then + + DGD.Bul = 0 + DGD.Bur = 0 + DGD.Bdl = 0 + DGD.Bdr = 0 + + if sBotType == 'BD' or sBotType == 'BU' or sBotType == 'BDEB' or sBotType == 'BUEB' then + if DGD.Push then + DGD.Bul = ( DGD.dT * TAN3) + DGD.Bur = ( DGD.dT * TAN3) + DGD.Bml = DGD.Bul / 2 + DGD.Bmr = DGD.Bml + else + DGD.Bdl = ( DGD.dT * TAN3) + DGD.Bdr = ( DGD.dT * TAN3) + DGD.Bml = DGD.Bdl / 2 + DGD.Bmr = DGD.Bml + end + elseif sBotType == '1B' or sBotType == '2B' or sBotType == '3B' or sBotType == '4B' or + sBotType == '5B' or sBotType == '6B' or sBotType == '7B' or sBotType == '8B' then + DGD.Bul = dRadProf - sqrt( ( dRadProf * dRadProf) - ((DGD.dT/2)*(DGD.dT/2))) + DGD.Bur = DGD.Bul + DGD.Bdl = DGD.Bul + DGD.Bdr = DGD.Bul + elseif sBotType == 'CV' then + DGD.Bml = dRadProf - sqrt( ( dRadProf * dRadProf) - (((DGD.dT/2)-dPlnProfB)*((DGD.dT/2)-dPlnProfB))) + DGD.Bmr = DGD.Bml + end + end + end + + -------------------- + -- creo pezzo porta + -------------------- + + --local nP = EgtGetFirstGroupInGroup( GDB_ID.ROOT) + local nLa = EgtGroup( DGD.PZ) + EgtSetName( nLa, 'AUX') + EgtSetColor( nLa, BROWN()) + local nLs = EgtGroup( DGD.PZ) + EgtSetName( nLs, 'SOLID') + + if DGD.bProoduce then + if DGD.Material and string.lower(DGD.Material) == 'wood' then + EgtSetColor( nLs, ORANGE()) + EgtSetBackground( Color3d(176,208,210), Color3d(145,177,196), false) + elseif DGD.Material and string.lower(DGD.Material) == 'steel' then + EgtSetColor( nLs, Color3d(167,196,197)) +-- EgtSetColor( nLs, Color3d(186,193,199)) + EgtSetBackground( WHITE(), GRAY(), false) + elseif DGD.Material and string.lower(DGD.Material) == 'aluminum' then + EgtSetColor( nLs, Color3d(208,213,217)) +-- EgtSetBackground( WHITE(), GRAY(), false) + EgtSetBackground( WHITE(), Color3d(170,170,170), false) + elseif DGD.Material and string.lower(DGD.Material) == 'fiberglass' then + EgtSetColor( nLs, Color3d(198,227,211)) + EgtSetBackground( WHITE(), Color3d(210,255,210), false) + else + EgtSetColor( nLs, ORANGE()) + end + EgtSetAlpha( nLs, 30) + else + EgtSetColor( nLs, BLACK()) + EgtSetAlpha( nLs, 20) + EgtSetAlpha( nLa, 20) + end + + local nFu, nFd + local sFlatU = 'FLAT_UP' + local sFlatU2 = 'FLAT_UP_2' + local sFlatD = 'FLAT_DW' + local sFlatD2 = 'FLAT_DW_2' + local sSideL = 'SIDE_LF' + local sSideR = 'SIDE_RH' + local sSide = 'SIDE' + + local bMakeSideSurf, ptMedArc, bJoinRgt, bJoinLft = MakeSurfProfiles( nLs, sBotType, dRadProfB, sRightType, dRadProfR, + sTopType, dRadProfT, sLeftType, dRadProfL, sSide, + dPlnProfB, dPlnProfR, dPlnProfT, dPlnProf) + + if not bMakeSideSurf then + local sErrMess = EgtDoorsMsg[677] + return bMakeSideSurf, 2, sErrMess + end + + -- disegno facce sopra e sotto + if DGD.sFrame then + + -- setto la disposizione di piatto o di fianco dei jamb laterali e superiore, + -- per quello inferiore, se le dimensioni della sezione sono sotto un certo valore, viene disposto solo di piatto + if nTypePiece == 3 then -- se frame SX + if DGD.Dws then -- se disposizione sul lato wide (di piatto) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + nFu = EgtRectangle2P( nLa, { DGD.Bur, DGD.Urb, DGD.Rub}, { DGD.Tdr, DGD.Drt, DGD.Rdt}, GDB_RT.GRID ) -- p2 a p9 + nFd = EgtRectangle2P( nLa, { DGD.Bul, DGD.Ulb, DGD.Lub}, { DGD.Tdl, DGD.Dlt, DGD.Ldt}, GDB_RT.GRID ) -- p1 a p10 + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + else -- altrimenti disposizione su lato narrow + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rut, DGD.Tur, DGD.Urt}) -- p1 a p8 + nFd = EgtRectangle2P( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdt, DGD.Tdr, DGD.Drt}) -- p4 a p9 + end + elseif nTypePiece == 4 then -- se frame DX + if DGD.Dws then -- se disposizione sul lato wide (di piatto) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + nFu = EgtRectangle2P( nLa, { -DGD.Tdl, DGD.Dlt, -DGD.Ldt}, { -DGD.Bul, DGD.Ulb, -DGD.Lub}, GDB_RT.GRID ) -- p10 a p1 + nFd = EgtRectangle2P( nLa, { -DGD.Tdr, DGD.Drt, -DGD.Rdt}, { -DGD.Bur, DGD.Urb, -DGD.Rub}, GDB_RT.GRID ) -- p9 a p2 + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + else -- altrimenti disposizione su lato narrow + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rut, DGD.Tur, DGD.Urt}) -- p1 a p8 + nFd = EgtRectangle2P( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdt, DGD.Tdr, DGD.Drt}) -- p4 a p9 + end + elseif nTypePiece == 5 then -- tipo frame top + if DGD.Dws then -- se disposizione sul lato wide (di piatto) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Ulb, DGD.Bul}, { DGD.Rdb, DGD.Drb, DGD.Bdr}, GDB_RT.GRID ) -- p1 a p3 + nFd = EgtRectangle2P( nLa, { DGD.Lut, DGD.Ult, -DGD.Tul}, { DGD.Rdt, DGD.Drt, -DGD.Tdr}, GDB_RT.GRID ) -- p7 a p9 + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + else -- altrimenti disposizione su lato narrow + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rut, DGD.Tur, DGD.Urt}) -- p1 a p8 + nFd = EgtRectangle2P( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdt, DGD.Tdr, DGD.Drt}) -- p4 a p9 + end + else -- tipo frame bottom + if DGD.Dws then -- se disposizione sul lato wide (di piatto) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.BACK)) + nFu = EgtRectangle2P( nLa, { -DGD.Ldt, DGD.Dlt, DGD.Tdl}, { -DGD.Rut, DGD.Urt, DGD.Tur}, GDB_RT.GRID ) -- p10 a p8 + nFd = EgtRectangle2P( nLa, { -DGD.Ldb, DGD.Dlb, DGD.Bdl}, { -DGD.Rub, DGD.Urb, DGD.Bur}, GDB_RT.GRID ) --p4 a p2 + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + else -- altrimenti disposizione su lato narrow + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rut, DGD.Tur, DGD.Urt}) -- p1 a p8 + nFd = EgtRectangle2P( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdt, DGD.Tdr, DGD.Drt}) -- p4 a p9 + end + end + else + -- se top è ad arco + if DGD.tProfs.top.radius then + -- percorso superiore + local nE1 = EgtLine( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rub, DGD.Bur, DGD.Urb}, GDB_RT.LOC) -- p1 a p2 + local nE2 + local nE4 + local nE5 + local nE6 + if bJoinRgt then + nE2 = EgtLine( nLa, { DGD.Rub, DGD.Bur, DGD.Urb}, { DGD.Rua, DGD.Aur, DGD.Ura}, GDB_RT.LOC) -- p2 a p14(con XY nuova) + else + nE2 = EgtLine( nLa, { DGD.Rub, DGD.Bur, DGD.Urb}, { DGD.Rut, DGD.Aur, DGD.Ura}, GDB_RT.LOC) -- p2 a p14(con XY nuova) + nE5 = EgtLine( nLa, { DGD.Rut, DGD.Aur, DGD.Ura}, { DGD.Rua, DGD.Aur, DGD.Ura}, GDB_RT.LOC) -- linea giunzione discontinuità + end + local nE3 = EgtArcC2P( nLa, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Ura}, + { DGD.Rua, DGD.Aur, DGD.Ura}, { DGD.Lua, DGD.Aul, DGD.Ula}, GDB_RT.LOC) -- arco p14 a p13 + -- per migliorare l'arco recupero la direzione iniziale, cancello l'arco e lo ricreo con il punto finale preciso + if nE3 then + local vcIni = EgtSV(nE3) + EgtErase(nE3) + nE3 = EgtArc2PV( nLa, { DGD.Rua, DGD.Aur, DGD.Ura}, { DGD.Lua, DGD.Aul, DGD.Ula}, vcIni, GDB_RT.LOC) + end + if bJoinLft then + nE4 = EgtLine( nLa, { DGD.Lua, DGD.Aul, DGD.Ula}, { DGD.Lub, DGD.Bul, DGD.Ulb}, GDB_RT.LOC) -- p13(con Y nuova) a p1 + else + nE6 = EgtLine( nLa, { DGD.Lua, DGD.Aul, DGD.Ula}, { DGD.Lut, DGD.Aul, DGD.Ula}, GDB_RT.LOC) -- linea giunzione discontinuità + nE4 = EgtLine( nLa, { DGD.Lut, DGD.Aul, DGD.Ula}, { DGD.Lub, DGD.Bul, DGD.Ulb}, GDB_RT.LOC) -- p13(con XY nuova) a p1 + end + + if nE5 and nE6 then + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE5,nE3,nE6,nE4}, true) + elseif nE5 and not nE6 then + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE5,nE3,nE4}, true) + elseif not nE5 and nE6 then + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE6,nE4}, true) + else + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4}, true) + end + + -- percorso inferiore + nE5 = nil + nE6 = nil + nE1 = EgtLine( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdb, DGD.Bdr, DGD.Drb}, GDB_RT.LOC) -- p4 a p3 + if bJoinRgt then + nE2 = EgtLine( nLa, { DGD.Rdb, DGD.Bdr, DGD.Drb}, { DGD.Rda, DGD.Adr, DGD.Dra}, GDB_RT.LOC) -- p3 a p15(con XY nuova) + else + nE2 = EgtLine( nLa, { DGD.Rdb, DGD.Bdr, DGD.Drb}, { DGD.Rdt, DGD.Adr, DGD.Dra}, GDB_RT.LOC) -- p3 a p15(con XY nuova) + nE5 = EgtLine( nLa, { DGD.Rdt, DGD.Adr, DGD.Dra}, { DGD.Rda, DGD.Adr, DGD.Dra}, GDB_RT.LOC) -- linea giunzione discontinuità + end + nE3 = EgtArcC2P( nLa, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.Rda, DGD.Adr, DGD.Dra}, { DGD.Lda, DGD.Adl, DGD.Dla}, GDB_RT.LOC) -- arco p15 a p16 + -- per migliorare l'arco recupero la direzione iniziale, cancello l'arco e lo ricreo con il punto finale preciso + if nE3 then + local vcIni = EgtSV(nE3) + EgtErase(nE3) + nE3 = EgtArc2PV( nLa, { DGD.Rda, DGD.Adr, DGD.Dra}, { DGD.Lda, DGD.Adl, DGD.Dla}, vcIni, GDB_RT.LOC) + end + if bJoinLft then + nE4 = EgtLine( nLa, { DGD.Lda, DGD.Adl, DGD.Dla}, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, GDB_RT.LOC) -- p16 a p4 + else + nE6 = EgtLine( nLa, { DGD.Lda, DGD.Adl, DGD.Dla}, { DGD.Ldt, DGD.Adl, DGD.Dla}, GDB_RT.LOC) -- linea giunzione discontinuità + nE4 = EgtLine( nLa, { DGD.Ldt, DGD.Adl, DGD.Dla}, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, GDB_RT.LOC) -- p16 a p4 + end + + if nE5 and nE6 then + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE5,nE3,nE6,nE4}, true) + elseif nE5 and not nE6 then + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE5,nE3,nE4}, true) + elseif not nE5 and nE6 then + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE6,nE4}, true) + else + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4}, true) + end + elseif DGD.Tpa then -- se top è ad angolo + -- percorso superiore + local nE1 = EgtLine( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rub, DGD.Bur, DGD.Urb}, GDB_RT.LOC) -- p1 a p2 + local nE2 = EgtLine( nLa, { DGD.Rub, DGD.Bur, DGD.Urb}, { DGD.Rua, DGD.Aur, DGD.Ura}, GDB_RT.LOC) -- p2 a p14 + local nE3, nE4, nE5 + if DGD.tProfs.top.xdeltapos > 0 then + nE3 = EgtLine( nLa, { DGD.Rua, DGD.Aur, DGD.Ura}, { DGD.Cmu, DGD.Aut, DGD.Ura}, GDB_RT.LOC) -- p14 a p19 + nE4 = EgtLine( nLa, { DGD.Cmu, DGD.Aut, DGD.Ura}, { DGD.Lua, DGD.Aul, DGD.Ula}, GDB_RT.LOC) -- p19 a p13 + nE5 = EgtLine( nLa, { DGD.Lua, DGD.Aul, DGD.Ula}, { DGD.Lub, DGD.Bul, DGD.Ulb}, GDB_RT.LOC) -- p13 a p1 + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4,nE5}, true) + else + nE3 = EgtLine( nLa, { DGD.Rua, DGD.Aur, DGD.Ura}, { DGD.Lua, DGD.Aul, DGD.Ula}, GDB_RT.LOC) -- p14 a p13 + nE4 = EgtLine( nLa, { DGD.Lua, DGD.Aul, DGD.Ula}, { DGD.Lub, DGD.Bul, DGD.Ulb}, GDB_RT.LOC) -- p13 a p1 + nFu = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4}, true) + end + -- percorso inferiore + nE1 = EgtLine( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdb, DGD.Bdr, DGD.Drb}, GDB_RT.LOC) -- p4 a p3 + nE2 = EgtLine( nLa, { DGD.Rdb, DGD.Bdr, DGD.Drb}, { DGD.Rda, DGD.Adr, DGD.Dra}, GDB_RT.LOC) -- p3 a p15 + if DGD.tProfs.top.xdeltapos > 0 then + nE3 = EgtLine( nLa, { DGD.Rda, DGD.Adr, DGD.Dra}, { DGD.Cmd, DGD.Adt, DGD.Dra}, GDB_RT.LOC) -- p15 a p20 + nE4 = EgtLine( nLa, { DGD.Cmd, DGD.Adt, DGD.Dra}, { DGD.Lda, DGD.Adl, DGD.Dla}, GDB_RT.LOC) -- p20 a p16 + nE5 = EgtLine( nLa, { DGD.Lda, DGD.Adl, DGD.Dla}, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, GDB_RT.LOC) -- p16 a p4 + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4,nE5}, true) + else + nE3 = EgtLine( nLa, { DGD.Rda, DGD.Adr, DGD.Dra}, { DGD.Lda, DGD.Adl, DGD.Dla}, GDB_RT.LOC) -- p15 a p16 + nE4 = EgtLine( nLa, { DGD.Lda, DGD.Adl, DGD.Dla}, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, GDB_RT.LOC) -- p16 a p4 + nFd = EgtCurveCompo( nLa, {nE1,nE2,nE3,nE4}, true) + end + else + if DGD.PROBE == 2 and bRemake then + EgtInvertCurve({nDoorLeft,nDoorTop,nDoorRight,nDoorBot}) + EgtInvertCurve({nDoorLeftMid,nDoorTopMid,nDoorRightMid,nDoorBotMid}) + EgtInvertCurve({nDoorLeftTop,nDoorTopTop,nDoorRightTop,nDoorBotTop}) + nFu = EgtCurveCompo( nLa, {nDoorBotTop,nDoorRightTop,nDoorTopTop,nDoorLeftTop}, false) + nFd = EgtCurveCompo( nLa, {nDoorBot,nDoorRight,nDoorTop,nDoorLeft}, false) + else + nFu = EgtRectangle2P( nLa, { DGD.Lub, DGD.Bul, DGD.Ulb}, { DGD.Rut, DGD.Tur, DGD.Urt}) -- p1 a p8 + nFd = EgtRectangle2P( nLa, { DGD.Ldb, DGD.Bdl, DGD.Dlb}, { DGD.Rdt, DGD.Tdr, DGD.Drt}) -- p4 a p9 + end + end + end + + local nFrU + local nFrD + local nCountSurf + if DGD.PROBE == 2 and bRemake then + nFrU = EgtSurfFlatRegion( nLs, nFu) + EgtSetName( nFrU, sFlatU2) + EgtSetAlpha( nFrU, 10) + end + nFrU = EgtSurfFlatRegion( nLs, nFu) + EgtSetName( nFrU, sFlatU) + if DGD.PROBE == 2 and bRemake then + nFrD = EgtSurfFlatRegion( nLs, nFd) + EgtInvertSurf(nFrD) + EgtSetName( nFrD, sFlatD2) + EgtSetAlpha( nFrD, 10) + end + nFrD = EgtSurfFlatRegion( nLs, nFd) + EgtInvertSurf(nFrD) + EgtSetName( nFrD, sFlatD) + + -- tabelle percorsi profili + local tProPath = {} + + -- disegno bordo sinistro + local nFrL + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB' or sLeftType == 'FDWC' then + -- disegno + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + tProPath.nClt = EgtLine( nLa, {DGD.Lut,DGD.Tul,DGD.Ult}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p7 a p8 + tProPath.nClb = EgtLine( nLa, {DGD.Lub,DGD.Bul,DGD.Ulb}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p1 a p2 + elseif nTypePiece == 4 then -- se frame DX + tProPath.nClt = EgtLine( nLa, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Ldt,DGD.Tdl,DGD.Dlt}) -- p9 a p10 + tProPath.nClb = EgtLine( nLa, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Ldb,DGD.Bdl,DGD.Dlb}) -- p3 a p4 + elseif nTypePiece == 5 then -- tipo frame top + tProPath.nClt = EgtLine( nLa, {DGD.Rut,DGD.Tur,DGD.Urt}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p8 a p2 + tProPath.nClb = EgtLine( nLa, {DGD.Lut,DGD.Tul,DGD.Ult}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p7 a p1 + else -- tipo frame bottom + tProPath.nClt = EgtLine( nLa, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Rdt,DGD.Tdr,DGD.Drt}) -- p3 a p9 + tProPath.nClb = EgtLine( nLa, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Ldt,DGD.Tdl,DGD.Dlt}) -- p4 a p10 + end + nFrL = EgtSurfTmRuled( nLs, tProPath.nClt, tProPath.nClb, 0.05) + EgtInvertSurf(nFrL) + EgtSetName( nFrL, sSideL) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'L') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Left') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'L')) + local nMId + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + nMId = EgtLine( nLl, {DGD.Lut,DGD.Tul,DGD.Ult}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p7 a p1 + elseif nTypePiece == 4 then -- se frame DX + nMId = EgtLine( nLl, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Rdb,DGD.Bdr,DGD.Drb}) -- p9 a p3 + elseif nTypePiece == 5 then -- tipo frame top + nMId = EgtLine( nLl, {DGD.Rut,DGD.Tur,DGD.Urt}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p8 a p7 + else -- tipo frame bottom + nMId = EgtLine( nLl, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Ldb,DGD.Bdl,DGD.Dlb}) -- p3 a p4 + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Lda,max(DGD.Adl,DGD.Aul),DGD.Dla}, {DGD.Ldb,min(DGD.Bdl,DGD.Bul,DGD.Bml),DGD.Dlb}) -- p16 a p4 + else + nMId = EgtLine( nLl, {DGD.Ldt,max(DGD.Tdl,DGD.Tul,DGD.Tml),DGD.Dlt}, {DGD.Ldb,min(DGD.Bdl,DGD.Bul,DGD.Bml),DGD.Dlb}) -- p10 a p4 + end + end + + if sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB' then + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + if sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( COS3, 0, SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( COS3, 0, -SIN3), GDB_RT.GLOB) + end + elseif nTypePiece == 4 then -- se frame DX + if sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( -COS3, 0, -SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( -COS3, 0, SIN3), GDB_RT.GLOB) + end + elseif nTypePiece == 5 then -- tipo frame top + if sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -COS3, SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -COS3, -SIN3), GDB_RT.GLOB) + end + else -- tipo frame bottom + if sLeftType == 'BD' or sLeftType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, COS3, -SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, COS3, SIN3), GDB_RT.GLOB) + end + end + else + -- se lato sinistro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'L' and ( DGD.sSwing == 'RHI' or DGD.sSwing == 'RHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( -SIN3, 0, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( SIN3, 0, COS3), GDB_RT.GLOB) + end + else + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( SIN3, 0, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( -SIN3, 0, COS3), GDB_RT.GLOB) + end + end + end + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 4 then -- se frame SX o DX + EgtModifyCurveThickness( nMId, DGD.dW / COS3) + else + EgtModifyCurveThickness( nMId, DGD.dH / COS3) + end + else + EgtModifyCurveThickness( nMId, DGD.dT / COS3) + end + else + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + EgtModifyCurveExtrusion( nMId, Vector3d( 1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 4 then -- se frame DX + EgtModifyCurveExtrusion( nMId, Vector3d( -1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 5 then -- tipo frame top + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + else -- tipo frame bottom + EgtModifyCurveExtrusion( nMId, Vector3d( 0, 1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + end + else + EgtModifyCurveThickness( nMId, DGD.dT) + end + end + EgtSetName( nMId, sLeftType .. EgtIf( string.find( sLeftType,'EB'), DGD.EBP, '')) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'L') + else + EgtSetInfo( nMId, 'EdgeDoor', 'H') + end + end + elseif sLeftType == '1B' or sLeftType == '2B' or sLeftType == '3B' or sLeftType == '4B' or + sLeftType == '5B' or sLeftType == '6B' or sLeftType == '7B' or sLeftType == '8B' then + -- setto la griglia di fronte : da rivedere + if DGD.PROBE == 2 and bRemake then + tProPath.nClb = EgtArc3P( nLa, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Lmb,DGD.Bml,DGD.Mlb}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p4 a p5 a p1 + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + tProPath.nClt = EgtArc3P( nLa, {DGD.Lda,DGD.Adl,DGD.Dla}, {DGD.Lma,DGD.Aml,DGD.Mla}, {DGD.Lua,DGD.Aul,DGD.Ula}) -- p16 a p17 a p13 + else + tProPath.nClt = EgtArc3P( nLa, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Lmt,DGD.Tml,DGD.Mlt}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p10 a p11 a p7 + end + nFrL = EgtSurfTmRuled( nLs, tProPath.nClt, tProPath.nClb, 0.05) + EgtInvertSurf(nFrL) + EgtSetName( nFrL, sSideL) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'L') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Left') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'L')) + local nMId + if DGD.PROBE == 2 and bRemake then + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Lma, DGD.Aml, DGD.Dla}, { DGD.Lmb, DGD.Bml, DGD.Dlb}) -- pmu a pmd + else + nMId = EgtLine( nLl, {DGD.Lmt, DGD.Tml, DGD.Dlt}, { DGD.Lmb, DGD.Bml, DGD.Dlb}) -- pmu a pmd + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Lm, max(DGD.Adl,DGD.Aul), DGD.Dla}, { DGD.Lm, min(DGD.Bdl,DGD.Bul,DGD.Bml), DGD.Dlb}) -- pmu a pmd + else + nMId = EgtLine( nLl, {DGD.Lm, max(DGD.Tdl,DGD.Tul,DGD.Tml), DGD.Dlt}, { DGD.Lm, min(DGD.Bdl,DGD.Bul,DGD.Bml), DGD.Dlb}) -- pmu a pmd + end + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sLeftType) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'L') + else + EgtSetInfo( nMId, 'EdgeDoor', 'H') + end + end + elseif sLeftType == 'CV' then + -- setto la griglia di fronte: da rivedere + if DGD.PROBE == 2 and bRemake then + tProPath.nClb = EgtArc3P( nLa, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Lmb,DGD.Bml,DGD.Mlb}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p4 a p5 a p1 + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + tProPath.nClt = EgtArc3P( nLa, {DGD.Lda,DGD.Adl,DGD.Dla}, {DGD.Lma,DGD.Aml,DGD.Mla}, {DGD.Lua,DGD.Aul,DGD.Ula}) -- p16 a p17 a p13 + else + tProPath.nClt = EgtArc3P( nLa, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Lmt,DGD.Tml,DGD.Mlt}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p10 a p11 a p7 + end + nFrL = EgtSurfTmRuled( nLs, tProPath.nClt, tProPath.nClb, 0.05) + EgtInvertSurf(nFrL) + EgtSetName( nFrL, sSideL) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'L') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Left') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'L')) + local nMId + if DGD.PROBE == 2 and bRemake then + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Lma, DGD.Aml, DGD.Dla}, { DGD.Lmb, DGD.Bml, DGD.Dlb}) -- pmu a pmd + else + nMId = EgtLine( nLl, {DGD.Lmt, DGD.Tml, DGD.Dlt}, { DGD.Lmb, DGD.Bml, DGD.Dlb}) -- pmu a pmd + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Lm, max(DGD.Adl,DGD.Aul), DGD.Dla}, { DGD.Lm, min(DGD.Bdl,DGD.Bul,DGD.Bml), DGD.Dlb}) -- pmu a pmd + else + nMId = EgtLine( nLl, {DGD.Lm, max(DGD.Tdl,DGD.Tul,DGD.Tml), DGD.Dlt}, { DGD.Lm, min(DGD.Bdl,DGD.Bul,DGD.Bml), DGD.Dlb}) -- pmu a pmd + end + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sLeftType) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'L') + else + EgtSetInfo( nMId, 'EdgeDoor', 'H') + end + end + end + + -- disegno bordo destro + local nFrR + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' or sRightType == 'FDWC' then + -- disegno + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + tProPath.nCrt = EgtLine( nLa, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Rdt,DGD.Tdr,DGD.Drt}) -- p10 a p9 + tProPath.nCrb = EgtLine( nLa, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Rdb,DGD.Bdr,DGD.Drb}) -- p4 a p3 + elseif nTypePiece == 4 then -- se frame DX + tProPath.nCrt = EgtLine( nLa, {DGD.Rut,DGD.Tur,DGD.Urt}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p8 a p7 + tProPath.nCrb = EgtLine( nLa, {DGD.Rub,DGD.Bur,DGD.Urb}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p2 a p1 + elseif nTypePiece == 5 then -- tipo frame top + tProPath.nCrt = EgtLine( nLa, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Rdb,DGD.Bdr,DGD.Drb}) -- p9 a p3 + tProPath.nCrb = EgtLine( nLa, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Ldb,DGD.Bdl,DGD.Dlb}) -- p10 a p4 + else -- tipo frame bottom + tProPath.nCrt = EgtLine( nLa, {DGD.Rub,DGD.Bur,DGD.Urb}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p2 a p8 + tProPath.nCrb = EgtLine( nLa, {DGD.Lub,DGD.Bul,DGD.Ulb}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p1 a p7 + end + nFrR = EgtSurfTmRuled( nLs, tProPath.nCrt, tProPath.nCrb, 0.05) + EgtSetName( nFrR, sSideR) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'R') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Right') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'R')) + local nMId + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + nMId = EgtLine( nLl, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Ldt,DGD.Tdl,DGD.Dlt}) -- p4 a p10 + elseif nTypePiece == 4 then -- se frame DX + nMId = EgtLine( nLl, {DGD.Rub,DGD.Bur,DGD.Urb}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p2 a p8 + elseif nTypePiece == 5 then -- tipo frame top + nMId = EgtLine( nLl, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Rdt,DGD.Tdr,DGD.Drt}) -- p10 a p9 + else -- tipo frame bottom + nMId = EgtLine( nLl, {DGD.Lub,DGD.Bul,DGD.Ulb}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p1 a p2 + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Rdb,min(DGD.Bdr,DGD.Bur),DGD.Drb}, {DGD.Rda,max(DGD.Adr,DGD.Aur),DGD.Dra}) -- p3 a p15 + else + nMId = EgtLine( nLl, {DGD.Rdb,min(DGD.Bdr,DGD.Bur,DGD.Bmr),DGD.Drb}, {DGD.Rdt,max(DGD.Tdr,DGD.Tur,DGD.Tmr),DGD.Drt}) -- p3 a p9 + end + end + + if sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' then + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + if sRightType == 'BD' or sRightType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( COS3, 0, -SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( COS3, 0, SIN3), GDB_RT.GLOB) + end + elseif nTypePiece == 4 then -- se frame DX + if sRightType == 'BD' or sRightType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( -COS3, 0, SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( -COS3, 0, -SIN3), GDB_RT.GLOB) + end + elseif nTypePiece == 5 then -- tipo frame top + if sRightType == 'BD' or sRightType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -COS3, -SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -COS3, SIN3), GDB_RT.GLOB) + end + else -- tipo frame bottom + if sRightType == 'BD' or sRightType == 'BDEB' then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, COS3, SIN3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, COS3, -SIN3), GDB_RT.GLOB) + end + end + else + -- se lato destro con serratura e senza maniglia e abilitata la funzione + -- di inversione automatica bevel sul lato inactive o discordanza tra i due profili, inverto l'inclinazione + if DGD.Lock == 'R' and ( DGD.sSwing == 'LHI' or DGD.sSwing == 'LHRI') and + ( ( DGD.RevInBv and DGD.RevInBv == 1) or DGD.bBothOppoBevel) then + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( SIN3, 0, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( -SIN3, 0, COS3), GDB_RT.GLOB) + end + else + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( -SIN3, 0, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( SIN3, 0, COS3), GDB_RT.GLOB) + end + end + end + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 4 then -- se frame SX o DX + EgtModifyCurveThickness( nMId, DGD.dW / COS3) + else + EgtModifyCurveThickness( nMId, DGD.dH / COS3) + end + else + EgtModifyCurveThickness( nMId, DGD.dT / COS3) + end + else + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + EgtModifyCurveExtrusion( nMId, Vector3d( 1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 4 then -- se frame DX + EgtModifyCurveExtrusion( nMId, Vector3d( -1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 5 then -- tipo frame top + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + else -- tipo frame bottom + EgtModifyCurveExtrusion( nMId, Vector3d( 0, 1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + end + else + EgtModifyCurveThickness( nMId, DGD.dT) + end + end + EgtSetName( nMId, sRightType .. EgtIf( string.find( sRightType,'EB'), DGD.EBP, '')) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'H') + else + EgtSetInfo( nMId, 'EdgeDoor', 'L') + end + end + elseif sRightType == '1B' or sRightType == '2B' or sRightType == '3B' or sRightType == '4B' or + sRightType == '5B' or sRightType == '6B' or sRightType == '7B' or sRightType == '8B' then + -- setto la griglia di fronte: da rivedere + if DGD.PROBE == 2 and bRemake then + tProPath.nCrb = EgtArc3P( nLa, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Rmb,DGD.Bmr,DGD.Mrb}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p3 a p6 a p2 + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + tProPath.nCrt = EgtArc3P( nLa, {DGD.Rda,DGD.Adr,DGD.Dra}, {DGD.Rma,DGD.Amr,DGD.Mra}, {DGD.Rua,DGD.Aur,DGD.Ura}) -- p15 a p18 a p14 + else + tProPath.nCrt = EgtArc3P( nLa, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Rmt,DGD.Tmr,DGD.Mrt}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p9 a p12 a p8 + end + nFrR = EgtSurfTmRuled( nLs, tProPath.nCrt, tProPath.nCrb, 0.05) + EgtSetName( nFrR, sSideR) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'R') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Right') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'R')) + local nMId + if DGD.PROBE == 2 and bRemake then + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Rmb, DGD.Bmr, DGD.Drb}, { DGD.Rma, DGD.Amr, DGD.Dra}) -- pmd a pmu + else + nMId = EgtLine( nLl, {DGD.Rmb, DGD.Bmr, DGD.Drb}, { DGD.Rmt, DGD.Tmr, DGD.Drt}) -- pmd a pmu + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Rm, min(DGD.Bdr,DGD.Bur), DGD.Drb}, { DGD.Rm, max(DGD.Adr,DGD.Aur), DGD.Dra}) -- pmd a pmu + else + nMId = EgtLine( nLl, {DGD.Rm, min(DGD.Bdr,DGD.Bur,DGD.Bmr), DGD.Drb}, { DGD.Rm, max(DGD.Tdr,DGD.Tur,DGD.Tmr), DGD.Drt}) -- pmd a pmu + end + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sRightType) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'H') + else + EgtSetInfo( nMId, 'EdgeDoor', 'L') + end + end + elseif sRightType == 'CV' then + -- setto la griglia di fronte: da rivedere + if DGD.PROBE == 2 and bRemake then + tProPath.nCrb = EgtArc3P( nLa, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Rmb,DGD.Bmr,DGD.Mrb}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p3 a p6 a p2 + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + tProPath.nCrt = EgtArc3P( nLa, {DGD.Rda,DGD.Adr,DGD.Dra}, {DGD.Rma,DGD.Amr,DGD.Mra}, {DGD.Rua,DGD.Aur,DGD.Ura}) -- p15 a p18 a p14 + else + tProPath.nCrt = EgtArc3P( nLa, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Rmt,DGD.Tmr,DGD.Mrt}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p9 a p12 a p8 + end + nFrR = EgtSurfTmRuled( nLs, tProPath.nCrt, tProPath.nCrb, 0.05) + EgtSetName( nFrR, sSideR) + end + -- se richiesta lavorazione + if GetEdgeToMachine( 'R') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Right') + EgtSetInfo( nLl, 'Offs', GetEdgeOffset( 'R')) + local nMId + if DGD.PROBE == 2 and bRemake then + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Rmb, DGD.Bmr, DGD.Drb}, { DGD.Rma, DGD.Amr, DGD.Dra}) -- pmd a pmu + else + nMId = EgtLine( nLl, {DGD.Rmb, DGD.Bmr, DGD.Drb}, { DGD.Rmt, DGD.Tmr, DGD.Drt}) -- pmd a pmu + end + else + -- se top è ad arco e solo in modalità disegno + if ( DGD.tProfs.top.radius or DGD.Tpa) and DGD.MachEn == 0 then + nMId = EgtLine( nLl, {DGD.Rm, min(DGD.Bdr,DGD.Bur), DGD.Drb}, { DGD.Rm, max(DGD.Adr,DGD.Aur), DGD.Dra}) -- pmd a pmu + else + nMId = EgtLine( nLl, {DGD.Rm, min(DGD.Bdr,DGD.Bur,DGD.Bmr), DGD.Drb}, { DGD.Rm, max(DGD.Tdr,DGD.Tur,DGD.Tmr), DGD.Drt}) -- pmd a pmu + end + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sRightType) + EgtSetColor( nMId, BLACK()) + if DGD.Lock == 'L' then + EgtSetInfo( nMId, 'EdgeDoor', 'H') + else + EgtSetInfo( nMId, 'EdgeDoor', 'L') + end + end + end + + -- bordo in basso + -- se richiesta lavorazione + if GetEdgeToMachine( 'B') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Bottom') + EgtSetInfo( nLl, 'Offs', DGD.tProfs.bottom.offset) + local nMId, nAsl, nAsr + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + nMId = EgtLine( nLl, {DGD.Lub,DGD.Bul,DGD.Ulb}, {DGD.Ldb,DGD.Bdl,DGD.Dlb}) -- p1 a p4 + EgtModifyCurveExtrusion( nMId, Vector3d( 1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 4 then -- se frame DX + nMId = EgtLine( nLl, {DGD.Rdb,DGD.Bdr,DGD.Drb}, {DGD.Rub,DGD.Bur,DGD.Urb}) -- p3 a p2 + EgtModifyCurveExtrusion( nMId, Vector3d( -1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 5 then -- tipo frame top + nMId = EgtLine( nLl, {DGD.Lut,DGD.Tul,DGD.Ult}, {DGD.Ldt,DGD.Tdl,DGD.Dlt}) -- p7 a p10 + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + else -- tipo frame bottom + nMId = EgtLine( nLl, {DGD.Ldb,DGD.Bdl,DGD.Dlb}, {DGD.Lub,DGD.Bul,DGD.Ulb}) -- p4 a p1 + EgtModifyCurveExtrusion( nMId, Vector3d( 0, 1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + end + EgtSetName( nMId, 'SQ_H') + EgtSetColor( nMId, BLACK()) + else + if sBotType == 'BD' or sBotType == 'BU' or sBotType == 'BDEB' or sBotType == 'BUEB' then + nMId = EgtLine( nLl, {min(DGD.Ldb,DGD.Lm,DGD.Lub),DGD.Bdl,DGD.Dlb}, {max(DGD.Rdb,DGD.Rm,DGD.Rub),DGD.Bdr,DGD.Drb}) -- p4 a p3 + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, SIN3, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -SIN3, COS3), GDB_RT.GLOB) + end + EgtModifyCurveThickness( nMId, DGD.dT / COS3) + elseif sBotType == '1B' or sBotType == '2B' or sBotType == '3B' or sBotType == '4B' or + sBotType == '5B' or sBotType == '6B' or sBotType == '7B' or sBotType == '8B' then + nMId = EgtLine( nLl, {min(DGD.Ldb,DGD.Lm,DGD.Lub),DGD.Bml,DGD.Dlb}, {max(DGD.Rdb,DGD.Rm,DGD.Rub),DGD.Bmr,DGD.Drb}) -- p5 a p6 con Z0 + EgtModifyCurveThickness( nMId, DGD.dT) + elseif sBotType == 'CV' then + nMId = EgtLine( nLl, {min(DGD.Ldb,DGD.Lm,DGD.Lub),DGD.Bml,DGD.Dlb}, {max(DGD.Rdb,DGD.Rm,DGD.Rub),DGD.Bmr,DGD.Drb}) -- p4 a p3 + EgtModifyCurveThickness( nMId, DGD.dT) + else -- SQ/EB/FDWC + nMId = EgtLine( nLl, {min(DGD.Ldb,DGD.Lm,DGD.Lub),DGD.Bdl,DGD.Dlb}, {max(DGD.Rdb,DGD.Rm,DGD.Rub),DGD.Bdr,DGD.Drb}) -- p4 a p3 + EgtModifyCurveThickness( nMId, DGD.dT) + end + + -- creo percorsi anti-scheggia lungo lo spessore + if not ( sBotType == '1B' or sBotType == '2B' or sBotType == '3B' or sBotType == '4B' or + sBotType == '5B' or sBotType == '6B' or sBotType == '7B' or sBotType == '8B' or + sBotType == 'CV') then + -- griglia a sinistra per percorso a sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB' or sLeftType == 'FDWC' then + nAsl = EgtLine( nLl, {-DGD.Bdl,DGD.Dlb,-DGD.Ldb}, {-DGD.Bul,DGD.Ulb,-DGD.Lub}, GDB_RT.GRID) -- p4 a p1 + else + nAsl = EgtLine( nLl, {-DGD.Bdl,DGD.Dlb,-(min(DGD.Ldb,DGD.Lm,DGD.Lub))}, {-DGD.Bul,DGD.Ulb,-(min(DGD.Ldb,DGD.Lm,DGD.Lub))}, GDB_RT.GRID) -- p4 a p1 + end + EgtModifyCurveThickness( nAsl, 0) + EgtSetColor( nAsl, BLACK()) + -- griglia a destra per percorso a destra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' or sRightType == 'FDWC' then + nAsr = EgtLine( nLl, {DGD.Bur,DGD.Urb,DGD.Rub}, {DGD.Bdr,DGD.Drb,DGD.Rdb}, GDB_RT.GRID) -- p2 a p3 + else + nAsr = EgtLine( nLl, {DGD.Bur,DGD.Urb,max(DGD.Rub,DGD.Rm,DGD.Rdb)}, {DGD.Bdr,DGD.Drb,max(DGD.Rub,DGD.Rm,DGD.Rdb)}, GDB_RT.GRID) -- p2 a p3 + end + EgtModifyCurveThickness( nAsr, 0) + EgtSetColor( nAsr, BLACK()) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + if DGD.Lock == 'R' then + EgtSetName( nAsl, 'ASLB_HNG') -- indico nel nome che è sul lato hinge + EgtSetName( nAsr, 'ASRB') + else + EgtSetName( nAsl, 'ASLB') + EgtSetName( nAsr, 'ASRB_HNG') -- indico nel nome che è sul lato hinge + end + end + EgtSetName( nMId, sBotType .. EgtIf( string.find( sBotType,'EB'), DGD.EBP, '') .. '_H') + EgtSetColor( nMId, BLACK()) + end + EgtSetInfo( nMId, 'EdgeDoor', 'B') + end + + -- bordo in alto + -- se richiesta lavorazione + if GetEdgeToMachine( 'T') and DGD.MachEn > 0 then + local nLl = EgtGroup( DGD.PZ) + EgtSetName( nLl, 'Top') + EgtSetInfo( nLl, 'Offs', DGD.tProfs.top.offset) + local nMId, nAsl, nAsr + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + nMId = EgtLine( nLl, {DGD.Ldt,DGD.Tdl,DGD.Dlt}, {DGD.Lut,DGD.Tul,DGD.Ult}) -- p10 a p7 + EgtModifyCurveExtrusion( nMId, Vector3d( 1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 4 then -- se frame DX + nMId = EgtLine( nLl, {DGD.Rut,DGD.Tur,DGD.Urt}, {DGD.Rdt,DGD.Tdr,DGD.Drt}) -- p8 a p9 + EgtModifyCurveExtrusion( nMId, Vector3d( -1, 0, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dW) + elseif nTypePiece == 5 then -- tipo frame top + nMId = EgtLine( nLl, {DGD.Rdt,DGD.Tdr,DGD.Drt}, {DGD.Rut,DGD.Tur,DGD.Urt}) -- p9 a p8 + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + else -- tipo frame bottom + nMId = EgtLine( nLl, {DGD.Rub,DGD.Bur,DGD.Urb}, {DGD.Rdb,DGD.Bdr,DGD.Drb}) -- p2 a p3 + EgtModifyCurveExtrusion( nMId, Vector3d( 0, 1, 0), GDB_RT.GLOB) + EgtModifyCurveThickness( nMId, DGD.dH) + end + EgtSetName( nMId, 'SQ_H') + EgtSetColor( nMId, BLACK()) + else + -- se top è ad arco + if DGD.tProfs.top.radius then + if sTopType == 'BD' or sTopType == 'BU' or sTopType == 'BDEB' or sTopType == 'BUEB' or + sTopType == 'SQ' or sTopType == 'EB' or sTopType == 'BV' or sTopType == 'BVEB' or + sTopType == 'FDWC' then -- profilo top + if DGD.Push then -- se a spingere percorso con punti da curva sopra spessore (la curva più stretta) + + nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.rma, DGD.amr, DGD.Dra}, { DGD.lma, DGD.aml, DGD.Dla}, GDB_RT.LOC) -- arco p22 a p23 +-- nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, +-- { DGD.Rua, DGD.Aur, DGD.Dra}, { DGD.Lua, DGD.Aul, DGD.Dla}, GDB_RT.LOC) -- arco p22 a p23 + else -- altrimenti a tirare percorso con punti da curva sotto (la curva più stretta) + + nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.rma, DGD.amr, DGD.Dra}, { DGD.lma, DGD.aml, DGD.Dla}, GDB_RT.LOC) -- arco p24 a p25 +-- nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, +-- { DGD.Rda, DGD.Adr, DGD.Dra}, { DGD.Lda, DGD.Adl, DGD.Dla}, GDB_RT.LOC) -- arco p24 a p25 + end + elseif sTopType == 'CV' then + nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.rma, DGD.amr, DGD.Dra}, { DGD.lma, DGD.aml, DGD.Dla}, GDB_RT.LOC) -- arco interno P24 a P25 + else + nMId = EgtArcC2P( nLl, {((DGD.dW/2)+DGD.tProfs.top.xdeltapos), (DGD.dH-DGD.tProfs.top.ydeltapos), DGD.Dra}, + { DGD.RMa, DGD.AMr, DGD.Dra}, { DGD.LMa, DGD.AMl, DGD.Dla}, GDB_RT.LOC) -- arco p22 a p23 + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sTopType .. EgtIf( string.find( sTopType,'EB'), DGD.EBP, '') .. '_H') + EgtSetColor( nMId, BLACK()) + EgtSetInfo( nMId, 'EdgeDoor', 'T') + elseif DGD.Tpa then -- se top ad angolo + if sTopType == 'BD' or sTopType == 'BU' or sTopType == 'BDEB' or sTopType == 'BUEB' or + sTopType == 'SQ' or sTopType == 'EB' or sTopType == 'BV' or sTopType == 'BVEB' or + sTopType == 'FDWC' then -- profilo top + if DGD.Push then + if DGD.tProfs.top.xdeltapos > 0 then + local nE1 = EgtLine( nLl, {DGD.Rua,DGD.Aur,DGD.Dra}, {DGD.Cmu,DGD.Aut,DGD.Dla}) -- p14 a p19 + local nE2 = EgtLine( nLl, {DGD.Cmu,DGD.Aut,DGD.Dla}, {DGD.Lua,DGD.Aul,DGD.Dla}) -- p19 a p13 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs(max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rua) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nE1) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE1, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rua,DGD.Aur,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max(DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs(min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lua) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nE2) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE2, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lua,DGD.Aul,DGD.Dla}) + end + nMId = EgtCurveCompo( nLl, {nE1,nE2}, true) + else + nMId = EgtLine( nLl, {DGD.Rua,DGD.Aur,DGD.Dra}, {DGD.Lua,DGD.Aul,DGD.Dla}) -- p14 a p13 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs(max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rua) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rua,DGD.Aur,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max(DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs(min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lua) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lua,DGD.Aul,DGD.Dla}) + end + end + else + if DGD.tProfs.top.xdeltapos > 0 then + local nE1 = EgtLine( nLl, {DGD.Rda,DGD.Adr,DGD.Dra}, {DGD.Cmd,DGD.Adt,DGD.Drt}) -- p15 a p20 + local nE2 = EgtLine( nLl, {DGD.Cmd,DGD.Adt,DGD.Drt}, {DGD.Lda,DGD.Adl,DGD.Dla}) -- p20 a p16 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs( max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rda) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nE1) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE1, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rda,DGD.Adr,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max( DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs( min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lda) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nE2) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE2, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lda,DGD.Adl,DGD.Dla}) + end + nMId = EgtCurveCompo( nLl, {nE1,nE2}, true) + else + nMId = EgtLine( nLl, {DGD.Rda,DGD.Adr,DGD.Dra}, {DGD.Lda,DGD.Adl,DGD.Dla}) -- p15 a p16 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs(max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rda) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rda,DGD.Adr,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max(DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs(min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lda) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lda,DGD.Adl,DGD.Dla}) + end + end + end + else + if DGD.tProfs.top.xdeltapos > 0 then + local nE1 = EgtLine( nLl, {DGD.Rma,DGD.Amr,DGD.Dra}, {DGD.Cmm,DGD.Amt,DGD.Drt}) -- p18 a p21 + local nE2 = EgtLine( nLl, {DGD.Cmm,DGD.Amt,DGD.Drt}, {DGD.Lma,DGD.Aml,DGD.Dla}) -- p21 a p17 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs( max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rma) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nE1) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE1, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rdm,DGD.Amr,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max( DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs( min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lma) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nE2) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nE2, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lma,DGD.Aml,DGD.Dla}) + end + nMId = EgtCurveCompo( nLl, {nE1,nE2}, true) + else + nMId = EgtLine( nLl, {DGD.Rma,DGD.Amr,DGD.Dra}, {DGD.Lma,DGD.Aml,DGD.Dla}) -- p18 a p17 + -- eventuale allungamento percorso sull'inizio + local dDistMax = max(DGD.Rda,DGD.Rua,DGD.Rma) - min(DGD.Rda,DGD.Rua,DGD.Rma) + if dDistMax > GEO.EPS_SMALL and abs(max(DGD.Rda,DGD.Rua,DGD.Rma) - DGD.Rma) > GEO.EPS_SMALL then + local sVecIni = EgtSV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)) ,{DGD.Rma,DGD.Amr,DGD.Dra}) + end + -- eventuale allungamento percorso sulla fine + dDistMax = max(DGD.Lda,DGD.Lua,DGD.Lma) - min(DGD.Lda,DGD.Lua,DGD.Lma) + if dDistMax > GEO.EPS_SMALL and abs(min(DGD.Lda,DGD.Lua,DGD.Lma) - DGD.Lma) > GEO.EPS_SMALL then + local sVecIni = EgtEV(nMId) + local dCompoY = (dDistMax/sVecIni:getX()*sVecIni:getY()) + EgtTrimExtendCurveByLen( nMId, sqrt( (dDistMax*dDistMax) + (dCompoY*dCompoY)), {DGD.Lma,DGD.Aml,DGD.Dla}) + end + end + end + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sTopType .. EgtIf( string.find( sTopType,'EB'), DGD.EBP, '') .. '_H') + EgtSetColor( nMId, BLACK()) + EgtSetInfo( nMId, 'EdgeDoor', 'T') + else + if sTopType == 'BD' or sTopType == 'BU' or sTopType == 'BDEB' or sTopType == 'BUEB' or sTopType == 'SQ' or sTopType == 'EB' or sTopType == 'FDWC' then + nMId = EgtLine( nLl, {max(DGD.Rdt,DGD.Rm,DGD.Rut),DGD.Tdr,DGD.Drt}, {min(DGD.Ldt,DGD.Lm,DGD.Lut),DGD.Tdl,DGD.Dlt}) -- p9 a p10 + if sTopType == 'BD' or sTopType == 'BU' or sTopType == 'BDEB' or sTopType == 'BUEB' then + if DGD.Push then + EgtModifyCurveExtrusion( nMId, Vector3d( 0, -SIN3, COS3), GDB_RT.GLOB) + else + EgtModifyCurveExtrusion( nMId, Vector3d( 0, SIN3, COS3), GDB_RT.GLOB) + end + EgtModifyCurveThickness( nMId, DGD.dT / COS3) + else -- SQ/EB/FDWC + EgtModifyCurveThickness( nMId, DGD.dT) + end + EgtSetName( nMId, sTopType .. EgtIf( string.find( sTopType,'EB'), DGD.EBP, '') .. '_H') + EgtSetColor( nMId, BLACK()) + EgtSetInfo( nMId, 'EdgeDoor', 'T') + -- creo percorsi anti-scheggia lungo lo spessore + -- griglia a destra per percorso a destra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + if sRightType == 'SQ' or sRightType == 'EB' or sRightType == 'BD' or sRightType == 'BU' or sRightType == 'BDEB' or sRightType == 'BUEB' or sRightType == 'FDWC' then + nAsr = EgtLine( nLl, {DGD.Tdr,DGD.Drt,DGD.Rdt}, {DGD.Tur,DGD.Urt,DGD.Rut}, GDB_RT.GRID) -- p9 a p8 + else + nAsr = EgtLine( nLl, {DGD.Tdr,DGD.Drt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, {DGD.Tur,DGD.Urt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, GDB_RT.GRID) -- p9 a p8 + end + EgtModifyCurveThickness( nAsr, 0) + EgtSetColor( nAsr, BLACK()) + -- griglia a sinistra per percorso a sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + if sLeftType == 'SQ' or sLeftType == 'EB' or sLeftType == 'BD' or sLeftType == 'BU' or sLeftType == 'BDEB' or sLeftType == 'BUEB' or sLeftType == 'FDWC' then + nAsl = EgtLine( nLl, {-DGD.Tul,DGD.Ult,-DGD.Lut}, {-DGD.Tdl,DGD.Dlt,-DGD.Ldt}, GDB_RT.GRID) -- p7 a p10 + else + nAsl = EgtLine( nLl, {-DGD.Tul,DGD.Ult,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, {-DGD.Tdl,DGD.Dlt,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, GDB_RT.GRID) -- p7 a p10 + end + EgtModifyCurveThickness( nAsl, 0) + EgtSetColor( nAsl, BLACK()) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + if DGD.Lock == 'R' then + EgtSetName( nAsl, 'ASLT_HNG') -- indico nel nome che è sul lato hinge + EgtSetName( nAsr, 'ASRT') + else + EgtSetName( nAsl, 'ASLT') + EgtSetName( nAsr, 'ASRT_HNG') -- indico nel nome che è sul lato hinge + end + elseif sTopType == '1B' or sTopType == '2B' or sTopType == '3B' or sTopType == '4B' or + sTopType == '5B' or sTopType == '6B' or sTopType == '7B' or sTopType == '8B' then + nMId = EgtLine( nLl, {max(DGD.Rdt,DGD.Rm,DGD.Rut),DGD.Tdr,DGD.Drt}, {min(DGD.Ldt,DGD.Lm,DGD.Lut),DGD.Tdl,DGD.Dlt}) -- p9 a p10 + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sTopType..'_H') + EgtSetColor( nMId, BLACK()) + EgtSetInfo( nMId, 'EdgeDoor', 'T') +--[[ + -- creo percorsi antischeggia lungo lo spessore + -- griglia a destra per percorso a destra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + nAsr = EgtLine( nLl, {max(DGD.Tdr,DGD.Tur),DGD.Drt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, {max(DGD.Tdr,DGD.Tur),DGD.Urt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, GDB_RT.GRID) -- p9 a p8 + EgtModifyCurveThickness( nAsr, 0) + EgtSetColor( nAsr, BLACK()) + -- griglia a sinistra per percorso a sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + nAsl = EgtLine( nLl, {-(max(DGD.Tul,DGD.Tdl)),DGD.Ult,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, {-(max(DGD.Tul,DGD.Tdl)),DGD.Dlt,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, GDB_RT.GRID) -- p7 a p10 + EgtModifyCurveThickness( nAsl, 0) + EgtSetColor( nAsl, BLACK()) + + if DGD.Lock == 'R' then + EgtSetName( nAsl, 'ASLT_HNG') -- indico nel nome che è sul lato hinge + EgtSetName( nAsr, 'ASRT') + else + EgtSetName( nAsl, 'ASLT') + EgtSetName( nAsr, 'ASRT_HNG') -- indico nel nome che è sul lato hinge + end +]]-- + elseif sTopType == 'CV' then + nMId = EgtLine( nLl, {max(DGD.Rdt,DGD.Rm,DGD.Rut),DGD.Tmr,DGD.Drt}, {min(DGD.Ldt,DGD.Lm,DGD.Lut),DGD.Tml,DGD.Dlt}) -- p9 a p10 + EgtModifyCurveThickness( nMId, DGD.dT) + EgtSetName( nMId, sTopType..'_H') + EgtSetColor( nMId, BLACK()) + EgtSetInfo( nMId, 'EdgeDoor', 'T') +--[[ + -- creo percorsi antischeggia lungo lo spessore + -- griglia a destra per percorso a destra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.RIGHT)) + nAsr = EgtLine( nLl, {max(DGD.Tdr,DGD.Tur),DGD.Drt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, {max(DGD.Tdr,DGD.Tur),DGD.Urt,max(DGD.Rdt,DGD.Rm,DGD.Rut)}, GDB_RT.GRID) -- p9 a p8 + EgtModifyCurveThickness( nAsr, 0) + EgtSetColor( nAsr, BLACK()) + -- griglia a sinistra per percorso a sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + nAsl = EgtLine( nLl, {-(max(DGD.Tul,DGD.Tdl)),DGD.Ult,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, {-(max(DGD.Tul,DGD.Tdl)),DGD.Dlt,-(min(DGD.Lut,DGD.Lm,DGD.Ldt))}, GDB_RT.GRID) -- p7 a p10 + EgtModifyCurveThickness( nAsl, 0) + EgtSetColor( nAsl, BLACK()) + + if DGD.Lock == 'R' then + EgtSetName( nAsl, 'ASLT_HNG') -- indico nel nome che è sul lato hinge + EgtSetName( nAsr, 'ASRT') + else + EgtSetName( nAsl, 'ASLT') + EgtSetName( nAsr, 'ASRT_HNG') -- indico nel nome che è sul lato hinge + end +]]-- + end + end + end + end + + -- elimino le 12 linee + EgtErase(nDoorBot) + EgtErase(nDoorLeft) + EgtErase(nDoorTop) + EgtErase(nDoorRight) + EgtErase(nDoorBotMid) + EgtErase(nDoorLeftMid) + EgtErase(nDoorTopMid) + EgtErase(nDoorRightMid) + EgtErase(nDoorBotTop) + EgtErase(nDoorLeftTop) + EgtErase(nDoorTopTop) + EgtErase(nDoorRightTop) + + -- per i frame risetto le variabili profilo a SQ + if DGD.sFrame then + DGD.tProfs.hingeedge.trimming = 'SQ' + DGD.tProfs.lockedge.trimming = 'SQ' + end + + -- inserisco sfinestrature + if #DGD.tVisions > 0 then + InsertGeom( DGD.tVisions, DGD.Lock, DGD.Push, 'vision') + end + + -- inserisco sfinestrature inferiori + if #DGD.tLouvers > 0 then + InsertGeom( DGD.tLouvers, DGD.Lock, DGD.Push, 'louver') + end + + -- inserisco sfinestrature inferiori mail slot + if #DGD.tMailSlots > 0 then + InsertGeom( DGD.tMailSlots, DGD.Lock, DGD.Push, 'mail') + end + + -- inserisco spioncini + if #DGD.tViewers > 0 then + InsertGeom( DGD.tViewers, DGD.Lock, DGD.Push, 'viewer') + end + + -- inserisco disegni flush pull + if #DGD.tFlushPulls > 0 then + InsertGeom( DGD.tFlushPulls, DGD.Lock, DGD.Push, 'flush') + end + + -- inserisco disegni cerniere + if #DGD.tHinges > 0 then + nNumHingePivot = nNumHingePivot + #DGD.tHinges -- prendo il numero di cerniere inserite + InsertGeom( DGD.tHinges, DGD.Lock, DGD.Push, 'hinge') + end + + -- inserisco disegni EPT + if #DGD.tEPTs > 0 then + InsertGeom( DGD.tEPTs, DGD.Lock, DGD.Push, 'ept') + end + + --inserisco disegni serrature + if #DGD.tLocks > 0 then + InsertGeom( DGD.tLocks, DGD.Lock, DGD.Push, 'lock') + end + + --inserisco disegni flush bolt + if #DGD.tFlushBolts > 0 then + InsertGeom( DGD.tFlushBolts, DGD.Lock, DGD.Push, 'flushbolt') + end + + --inserisco disegni edge pull + if #DGD.tEdgePulls > 0 then + InsertGeom( DGD.tEdgePulls, DGD.Lock, DGD.Push, 'edgepull') + end + + --inserisco disegni Roller Latch + if #DGD.tRollerLatchs > 0 then + InsertGeom( DGD.tRollerLatchs, DGD.Lock, DGD.Push, 'rollerlatch') + end + + --inserisco disegni Pivot + if #DGD.tPivots > 0 then + InsertGeom( DGD.tPivots, DGD.Lock, DGD.Push, 'pivot') + end + + --inserisco disegni stops and closers + if #DGD.tStopsAndClosers > 0 then + InsertGeom( DGD.tStopsAndClosers, DGD.Lock, DGD.Push, 'stopandcloser') + end + + --inserisco disegni over heads + if #DGD.tOHeads > 0 then + InsertGeom( DGD.tOHeads, DGD.Lock, DGD.Push, 'overhead') + end + + --inserisco disegni strike + if #DGD.tStrikes > 0 then + InsertGeom( DGD.tStrikes, DGD.Lock, DGD.Push, 'strike') + end + + --inserisco disegni groove + if #DGD.tGrooves > 0 then + InsertGeom( DGD.tGrooves, DGD.Lock, DGD.Push, 'groove') + end + + --inserisco disegni rabbet + if #DGD.tRabbets > 0 then + InsertGeom( DGD.tRabbets, DGD.Lock, DGD.Push, 'rabbet') + end + + --inserisco disegni face decoration + if #DGD.tDecorations > 0 then + InsertGeom( DGD.tDecorations, DGD.Lock, DGD.Push, 'facedecoration') + end + --debug +-- EgtSaveFile() +-- EgtMove(DGD.PZ, Point3d(0,0,nil) - ORIG()) + + -- sottraggo le superfici in modo da avere la visualizzazione della porta con le sfinestrature + -- ed elimino le superfici temporanee + SubAndDeleteTempSurf( nLs) + + if DGD.sFrame then + if nTypePiece == 3 then -- se frame SX + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( DGD.PZ, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtMove( DGD.PZ, Point3d(DGD.dT,0,0) - ORIG(), GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nTypePiece == 4 then -- se frame DX + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.FRONT)) + EgtRotate( DGD.PZ, Point3d(DGD.dW,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia frontale + EgtMove( DGD.PZ, Point3d(-DGD.dW,0,0) - ORIG(), GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + elseif nTypePiece == 5 then -- tipo frame top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( DGD.PZ, Point3d(-DGD.dH,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia sinistra + EgtMove( DGD.PZ, Point3d(DGD.dH,0,0) - ORIG(), GDB_RT.GRID) + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtRotate( DGD.PZ, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia top + EgtMove( DGD.PZ, Point3d(DGD.dT,0,0) - ORIG(), GDB_RT.GRID) + else -- tipo frame bottom + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.LEFT)) + EgtRotate( DGD.PZ, Point3d(0,0,0), Z_AX(), -90, GDB_RT.GRID) -- ruoto su faccia sinistra + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + EgtRotate( DGD.PZ, Point3d(0,0,0), Z_AX(), 90, GDB_RT.GRID) -- ruoto su faccia top + end + end + + -- scritta TOP per debug + if DGD.sFrame then + if nTypePiece == 3 or nTypePiece == 4 then -- se frame SX o DX + EgtText(nLa,{ 5, DGD.dH - 100, DGD.dW},'TOP-'.. EgtIf( nTypePiece == 3, 'JL', 'JR') .. '-' .. DGD.sAliasSwng,20,GDB_RT.GLOB) + else + EgtText(nLa,{ 5, DGD.dW - 100, DGD.dH},'TOP-'.. EgtIf( nTypePiece == 5, 'JT', 'JB') .. '-' .. DGD.sAliasSwng,20,GDB_RT.GLOB) + end + else + if DGD.tProfs.top.angle then + -- faccio il calcolo per capire se taglia la scritta + local nDltPosY + if DGD.tProfs.top.angle > 0 then + nDltPosY = ( DGD.dW - DGD.tProfs.top.xdeltapos - (0.5*(DGD.Lut+DGD.Rut)-150)) * tan(DGD.tProfs.top.angle) + else + nDltPosY = ( ( 0.5*(DGD.Lut+DGD.Rut)+150) - DGD.tProfs.top.xdeltapos) * tan(abs(DGD.tProfs.top.angle)) + end + if nDltPosY < 0 then + nDltPosY = 0 + end + EgtText(nLa,{ 0.5*(DGD.Lut+DGD.Rut)-150, DGD.Tul - 100 - nDltPosY, DGD.dT},'TOP-'..DGD.sAliasSwng,50,GDB_RT.GLOB) + else + EgtText(nLa,{ 0.5*(DGD.Lut+DGD.Rut)-150, DGD.Tul - 100, DGD.dT},'TOP-'..DGD.sAliasSwng,50,GDB_RT.GLOB) + end + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + end + + ------------------- + -- quotatura porta + ------------------- + InsertSize( 0, nil, ptMedArc, nil) + + return true +end + +----------------------------------------------------------------- +-- *** read Probe file *** +----------------------------------------------------------------- +local function LoadDataProbeFile( sOriProbeFile, sProbeFile) + + local bReadFile = true + + if DGD.PROBE == 2 then + + local nIdPrb = OpenPrbFile( sOriProbeFile, 'r') + + -- se trovato il file generico data.dat lo rinomino in .dat + if nIdPrb then + nIdPrb:close() -- chiudo il file + EgtCopyFile( sOriProbeFile, sProbeFile) -- faccio la copia sovrascrivendo l'eventuale file .dat + -- elimino il file data.dat così poi c'è il tempo per riaprire il file .dat + EgtEraseFile( sOriProbeFile) + end + + nIdPrb = OpenPrbFile( sProbeFile, 'r') + + if nIdPrb then + -- leggo la prossima linea + local sLine = nIdPrb:read( '*l') + + while sLine do + -- elimino spazi finali (compresi tab e simili) + sLine = EgtTrimRight( sLine) + -- se linea contiene qualcosa + if sLine:len() > 0 then + + -- se non ci sono commenti + local nI = sLine:find( ';', 1, true) + + if not nI then + + if sLine:find( 'OPM=', 1, true) then + sLine = sLine:sub( 5) + tProbeDoor.OPM = tonumber(sLine) + elseif sLine:find( 'P1.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P1x = tonumber(sLine) + elseif sLine:find( 'P1.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P1y = tonumber(sLine) + elseif sLine:find( 'P2.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P2x = tonumber(sLine) + elseif sLine:find( 'P2.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P2y = tonumber(sLine) + elseif sLine:find( 'P3.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P3x = tonumber(sLine) + elseif sLine:find( 'P3.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P3y = tonumber(sLine) + elseif sLine:find( 'P4.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P4x = tonumber(sLine) + elseif sLine:find( 'P4.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P4y = tonumber(sLine) + elseif sLine:find( 'P5.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P5x = tonumber(sLine) + elseif sLine:find( 'P5.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P5y = tonumber(sLine) + elseif sLine:find( 'P6.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P6x = tonumber(sLine) + elseif sLine:find( 'P6.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P6y = tonumber(sLine) + elseif sLine:find( 'P7.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P7x = tonumber(sLine) + elseif sLine:find( 'P7.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P7y = tonumber(sLine) + elseif sLine:find( 'P8.x=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P8x = tonumber(sLine) + elseif sLine:find( 'P8.y=', 1, true) then + sLine = sLine:sub( 6) + tProbeDoor.P8y = tonumber(sLine) + elseif sLine:find( 'FD=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.FD = tonumber(sLine) + elseif sLine:find( 'TD=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.TD = tonumber(sLine) + elseif sLine:find( 'DR=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.DR = EgtIf( DGD.bMM, 1, GEO.ONE_INCH)*tonumber(sLine) + elseif sLine:find( 'DO=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.DO = EgtIf( DGD.bMM, 1, GEO.ONE_INCH)*tonumber(sLine) + elseif sLine:find( 'DD=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.DD = tonumber(sLine) + elseif sLine:find( 'PX=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.PX = tonumber(sLine) + elseif sLine:find( 'PY=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.PY = tonumber(sLine) + elseif sLine:find( 'PZ=', 1, true) then + sLine = sLine:sub( 4) + tProbeDoor.PZ = tonumber(sLine) + -- se lo spessore passato è 0 lo setto allo spessore nominale + if abs(tProbeDoor.PZ) < GEO.EPS_SMALL then + tProbeDoor.PZ = DGD.dT + end + end + end + end + sLine = nIdPrb:read( '*l') + end + -- chiudo il file + nIdPrb:close() + else + bReadFile = false + end + end + + return bReadFile +end + +----------------------------------------------------------------- +-- *** Verify Mtable *** +----------------------------------------------------------------- +local function VerifyMtable() + + local M + local bLocFoundMTable = true + + -- verifico se esiste il nome file + if not sMTable or #sMTable <= 0 then + bLocFoundMTable = false + end + + if bLocFoundMTable and DGD.MachEn > 0 then + + -- verifico se esiste il file + sMTablePath = sBaseDir..'MTables\\'..sMTable..'.mtl' + + if EgtExistsFile(sMTablePath) then + + sMTablePath = sBaseDir..'MTables\\' + M = require( sMTable) + + if M then + tMachineData = M.MMachineData + if not tMachineData then + local sMessageErr = string.format( EgtDoorsMsg[489], sMTable) -- dati macchina non validi + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 25 +-- WriteErrFile( sErrFileM) + bLocFoundMTable = false + end + else + local sMessageErr = string.format( EgtDoorsMsg[490], sMTable) -- tabella non trovata + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 24 +-- WriteErrFile( sErrFileM) + bLocFoundMTable = false + end + else + local sMessageErr = string.format( EgtDoorsMsg[487], 'Mtable ',sMTablePath) -- non c'è il file della tabella + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 23 +-- WriteErrFile( sErrFileM) + bLocFoundMTable = false + end + elseif DGD.MachEn > 0 then + local sMessageErr = string.format( EgtDoorsMsg[487], 'Mtable ', sMTable) -- il nome del file della tabella non è valido + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 22 +-- WriteErrFile( sErrFileM) + end + + return bLocFoundMTable +end + +----------------------------------------------------------------- +-- *** DOOR creation *** +----------------------------------------------------------------- +local function DoorCreation() + + local bLocFoundMTable = true + + -- Creo pezzo porta + EgtNewFile() + DGD.PZ = EgtGroup( GDB_ID.ROOT) + if not DGD.sFrame then + EgtSetName( DGD.PZ, 'DOOR') + elseif DGD.sFrame == 'L' then + EgtSetName( DGD.PZ, 'FRAME_LOCK') + elseif DGD.sFrame == 'LE' then + EgtSetName( DGD.PZ, 'FRAME_LOCK_EXT') + elseif DGD.sFrame == 'H' then + EgtSetName( DGD.PZ, 'FRAME_HINGE') + elseif DGD.sFrame == 'HE' then + EgtSetName( DGD.PZ, 'FRAME_HINGE_EXT') + elseif DGD.sFrame == 'T' then + EgtSetName( DGD.PZ, 'FRAME_TOP') + elseif DGD.sFrame == 'TE' then + EgtSetName( DGD.PZ, 'FRAME_TOP_EXT') + elseif DGD.sFrame == 'B' then + EgtSetName( DGD.PZ, 'FRAME_BOT') + elseif DGD.sFrame == 'BE' then + EgtSetName( DGD.PZ, 'FRAME_BOT_EXT') + end + + EgtSetCurrPartLayer( DGD.PZ, GDB_ID.NULL) + + -- scrivo le note + local tAppo + local sParam, sValue + for i = 1, #tGenInfo do + tAppo = tGenInfo[i] + sParam = tAppo[1] + sValue = tAppo[2] + EgtSetInfo( DGD.PZ, sParam, sValue) + end + + -- nota del frame + EgtSetInfo( DGD.PZ, 'Frame', DGD.sFrame) + + -- controllo la macchina solo se ho abilitato la generazione della geometria di lavorazione + if DGD.MachEn > 0 then + + -- faccio qui il controllo come frame deve essere disposto ed eventualmente modifico la Mtable + if DGD.sFrame then + local nDispJamb = 0 + if DGC.Dwjs and DGD.Material and string.lower(DGD.Material) == 'wood' then + nDispJamb = DGC.Dwjs + elseif DGC.Dsjs and DGD.Material and string.lower(DGD.Material) == 'steel' then + nDispJamb = DGC.Dsjs + elseif DGC.Dajs and DGD.Material and string.lower(DGD.Material) == 'aluminum' then + nDispJamb = DGC.Dajs + elseif DGC.Dfjs and DGD.Material and string.lower(DGD.Material) == 'fiberglass' then + nDispJamb = DGC.Dfjs + end + + -- setto la disposizione di piatto o di fianco dei jamb laterali e superiore, + -- per quello inferiore, se le dimensioni della sezione sono sotto un certo valore, viene disposto solo di piatto + if nTypePiece == 3 then -- se frame SX + if nDispJamb > 0 and DGD.dW > DGC.Mjn then -- se disposizione sul lato narrow e lato maggiore del valore minimo + DGD.Dws = false + else + DGD.Dws = true + end + elseif nTypePiece == 4 then -- se frame DX + if nDispJamb > 0 and DGD.dW > DGC.Mjn then -- se disposizione sul lato narrow e lato maggiore del valore minimo + DGD.Dws = false + else + DGD.Dws = true + end + elseif nTypePiece == 5 then -- tipo frame top + if nDispJamb > 0 and DGD.dH > DGC.Mjn then -- se disposizione sul lato narrow e lato maggiore del valore minimo + DGD.Dws = false + else + DGD.Dws = true + end + else -- tipo frame bottom + if nDispJamb > 0 and DGD.dH > DGC.Mjn then -- se disposizione sul lato narrow e lato maggiore del valore minimo + DGD.Dws = false + else + DGD.Dws = true + end + end + + -- se ho disposto eventuale frame sul lato wide modifico il nome della Mtable e la verifico + if DGD.Dws then + sMTable = sMTable .. '_wide' + bLocFoundMTable = VerifyMtable() + end + DGD.Spd = DGC.Spd or 0 + else + DGD.Dws = nil + DGD.Spd = 0 + end + + -- Check machines and search into CurrCamInfo the parameter for manage large wide door + for i = 1, #tMachineData do + + -- se nome macchina non c'è + if not tMachineData[i].MachName then + DoorOutLog( string.format(EgtDoorsMsg[488], tMachineData[i].MachName), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format(EgtDoorsMsg[488], tMachineData[i].MachName) + DGD.ERR = -12 + -- se non c'è la macchina + elseif not EgtSetCurrMachine( tMachineData[i].MachName) then + DoorOutLog( string.format(EgtDoorsMsg[488], tMachineData[i].MachName), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format(EgtDoorsMsg[488], tMachineData[i].MachName) + DGD.ERR = -11 + -- macchina presente + else + local CCI = require( 'CurrCamInfo') + for j = 1, #CCI do + if CCI[j].MachName == tMachineData[i].MachName then + if CCI[j].WideDoorWidth and CCI[j].WideDoorWidth > 0 then + DGD.Part = CCI[j].WideDoorWidth + end + if CCI[j].SideDoorDefined and CCI[j].SideDoorDefined >= 0 then + DGD.SDF = CCI[j].SideDoorDefined + end + end + end + end + end + + -- Note della tabella utilizzata ( deve essere settata prima di creare il pezzo con CreateDoor() perchè i componenti inseriti vanno ad utilizzarla) + EgtSetInfo( DGD.PZ, 'MTable', sMTable) + EgtSetInfo( DGD.PZ, 'MTablePath', sMTablePath) + -- setto il tipo di disposizione del frame + EgtSetInfo( DGD.PZ, 'FrameDispositionOnSide', DGD.Dws) + -- setto la nota per large wide door + if DGD.Part and DGD.Part > 0 then + EgtSetInfo( DGD.PZ, 'ManageLargeWideDoor', DGD.Part) + end + end + + -- Note della disposizione + EgtSetInfo( DGD.PZ, 'SwingDriveDisp', DGD.SwDD or 1) + + if bLocFoundMTable then + + ------------------------------------------------------ + ------------------------------------------------------ + -- Costruzione della porta + local bOk, nNumErr, sMessErr = CreateDoor() + ------------------------------------------------------ + ------------------------------------------------------ + + -- In caso di errore, lo segnalo + if not bOk then + if nNumErr == 0 then + DoorOutLog( EgtDoorsMsg[454], 0) + DGD.ERM = DGD.ERM .. '\n' .. EgtDoorsMsg[454] + DGD.ERR = 10 + elseif nNumErr == 1 then + DoorOutLog( EgtDoorsMsg[630], 0) + DGD.ERM = DGD.ERM .. '\n' .. EgtDoorsMsg[630] + DGD.ERR = 11 + elseif nNumErr == 2 then + DoorOutLog( sMessErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessErr + DGD.ERR = 14 + end + else + + -- Note del profilo bevel invertito + EgtSetInfo( DGD.PZ, 'OppoBevelProf', DGD.bBothOppoBevel) + -- Note del raggio profilo su hinge + EgtSetInfo( DGD.PZ, 'RadHingeProfile', DGD.RPH or 0) + -- Note del raggio profilo su lock + EgtSetInfo( DGD.PZ, 'RadLockProfile', DGD.RPL or 0) + -- Note del raggio profilo su top + EgtSetInfo( DGD.PZ, 'RadTopProfile', DGD.RPT or 0) + -- Note del raggio profilo su bottom + EgtSetInfo( DGD.PZ, 'RadBottomProfile', DGD.RPB or 0) + -- Note del piano sul profilo CV su hinge + EgtSetInfo( DGD.PZ, 'PlnHingeProfile', DGD.PPH or 0) + -- Note del piano sul profilo CV su lock + EgtSetInfo( DGD.PZ, 'PlnLockProfile', DGD.PPL or 0) + -- Note del piano sul profilo CV su top + EgtSetInfo( DGD.PZ, 'PlnTopProfile', DGD.PPT or 0) + -- Note del piano sul profilo CV su bottom + EgtSetInfo( DGD.PZ, 'PlnBottomProfile', DGD.PPB or 0) + -- note del numero di elementi inseriti nel lato cerniere (esclusi EPT per il momento) + EgtSetInfo( DGD.PZ, 'NumHingesPivots', nNumHingePivot or 0) + -- note dispsizione jambs materiale legno + EgtSetInfo( DGD.PZ, 'DisposeWJambsOnSide', DGC.Dwjs or 0) + -- note dispsizione jambs materiale acciaio + EgtSetInfo( DGD.PZ, 'DisposeSJambsOnSide', DGC.Dsjs or 0) + -- note dispsizione jambs materiale alluminio + EgtSetInfo( DGD.PZ, 'DisposeAJambsOnSide', DGC.Dajs or 0) + -- note dispsizione jambs materiale fibra di vetro + EgtSetInfo( DGD.PZ, 'DisposeFJambsOnSide', DGC.Dfjs or 0) + -- nota presenza cutout + EgtSetInfo( DGD.PZ, 'ExistsCutOut', DGD.ExistCutOut) + -- nota mancanza riduzione sfridi + EgtSetInfo( DGD.PZ, 'WholeCutOut', DGD.NotExistHatch) + end + end + + return bLocFoundMTable, bWriteWide +end + +----------------------------------------------------------------- +-- *** DDF parse and make door *** +----------------------------------------------------------------- +local function ReadAndParseDdfAndMakeDoors() + + local sOutLogMsg = '' + local sPrvKeyLine = '' + local bOpenDdf = true + local bWriteErr = false + local bLocFoundMTable + local nLimitPieces = 6 + + --------------------------------------------------- + -- Lettura parametri necessari con errori bloccanti + --------------------------------------------------- + + -- Apertura file DDF + if not OpenFile( DGD.FILE) then + DoorOutLog( EgtDoorsMsg[434], 0) + DGD.ERM = DGD.ERM .. '\n' .. EgtDoorsMsg[434] + DGD.ERR = 1 + bOpenDdf = false + end + + -- esco se trovo il codice di fine file o non è finito il file + while bOpenDdf and not EndOfFile() and not KeyFromLine( '...') and nCountPieces < nLimitPieces do + + -- Reset librerie per evitare l'errore in caso riparto da una situazione di errore dello script + ResetDoorsGlobData() + tGenInfo={} + + if not KeyFromLine( '---') then + + sPrvKeyLine = '' + + -- Lettura numero versione ddf + GetVersion() + sOutLogMsg = ' DGD.nVersion=' .. tostring( DGD.nVersion) + DoorOutLog( sOutLogMsg, 0) + + -- Lettura flag di produzione pezzo + GetProoduce() + sOutLogMsg = ' DGD.bProoduce=' .. tostring( DGD.bProoduce) + DoorOutLog( sOutLogMsg, 0) + + -- Lettura unità di misura + if not GetMeasures() then + DoorOutLog( string.format( EgtDoorsMsg[435], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[435], GetLineNumber()) + DGD.ERR = 2 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.bMM=' .. tostring( DGD.bMM) + DoorOutLog( sOutLogMsg, 0) + + -- Lettura codice identificativo + if not GetCode() then + DoorOutLog( string.format( EgtDoorsMsg[436], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[436], GetLineNumber()) + DGD.ERR = 3 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.sCode=' .. DGD.sCode + DoorOutLog( sOutLogMsg, 0) + + -- Lettura dati ordine + if not GetOrder() then + DoorOutLog( string.format( EgtDoorsMsg[437], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[437], GetLineNumber()) + DGD.ERR = 4 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.tOrder=' .. table.concat( DGD.tOrder, ',') + DoorOutLog( sOutLogMsg, 0) + + -- Lettura data + if not GetDate() then + DoorOutLog( string.format( EgtDoorsMsg[438], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[438], GetLineNumber()) + DGD.ERR = 5 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.sDate=' .. DGD.sDate + DoorOutLog( sOutLogMsg, 0) + + -- lettura tipo pezzo + if GetPiece() then + sOutLogMsg = ' DGD.sFrame=' .. ( DGD.sFrame or '') + DoorOutLog( sOutLogMsg, 0) + end + + -- lettura coordinate disposizione + if GetPosition() then + sOutLogMsg = ' DGD.tPosition=' .. EgtNumToString( DGD.tPosition[1], 4) .. ' ' .. EgtNumToString( DGD.tPosition[2], 4) .. ' ' .. EgtNumToString( DGD.tPosition[3], 4) + DoorOutLog( sOutLogMsg, 0) + end + + -- Lettura dimensioni + if not GetSize() then + DoorOutLog( string.format( EgtDoorsMsg[439], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[439], GetLineNumber()) + DGD.ERR = 6 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.dW='..EgtNumToString( DGD.dW, 4)..' DGD.dH='..EgtNumToString( DGD.dH, 4)..' DGD.dT='..EgtNumToString( DGD.dT, 4) + DoorOutLog( sOutLogMsg, 0) + + -- lettura altezza originale porta (opzionale, solo per i frame) + if GetDoorHeight() then + sOutLogMsg = ' DGD.dOH='..EgtNumToString( DGD.dOH, 4) + DoorOutLog( sOutLogMsg, 0) + end + + -- Lettura tipo di apertura + local bGetSwing, sTmpSwing = GetSwing() + if not bGetSwing then + DoorOutLog( string.format( EgtDoorsMsg[440], sTmpSwing, GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[440], sTmpSwing, GetLineNumber()) + DGD.ERR = 7 + bWriteErr = false + break + end + sOutLogMsg = ' DGD.sAliasSwng=' .. DGD.sAliasSwng + DoorOutLog( sOutLogMsg, 0) + sOutLogMsg = ' DGD.sSwing=' .. DGD.sSwing + DoorOutLog( sOutLogMsg, 0) + + -- lettura disposizione porta senza bevel + if not GetSecurSide() then + DoorOutLog( EgtDoorsMsg[543], 0) + else + sOutLogMsg = ' DGD.sSecSide=' .. DGD.sSecSide + DoorOutLog( sOutLogMsg, 0) + end + + -- lettura materiale porta + if not GetDoorMaterial() then + DoorOutLog( EgtDoorsMsg[668], 0) + else + sOutLogMsg = ' DGD.Material=' .. DGD.Material + DoorOutLog( sOutLogMsg, 0) + end + + -- lettura proprietà porta + if not GetDoorProperties() then + DoorOutLog( EgtDoorsMsg[635], 0) + else + if DGD.Properties and #DGD.Properties > 0 then + local sProp = '' + for k = 1, #DGD.Properties do + sProp = sProp .. DGD.Properties[k] .. ',' + end + sOutLogMsg = ' DGD.Properties=' .. sProp + DoorOutLog( sOutLogMsg, 0) + end + end + + -- Lettura tipo di profili + local nErrPrf = GetProfiles() + if nErrPrf == 1 then + DoorOutLog( string.format( EgtDoorsMsg[441], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[441], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 2 then + DoorOutLog( string.format( EgtDoorsMsg[613], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[613], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 3 then + DoorOutLog( string.format( EgtDoorsMsg[614], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[614], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 4 then + DoorOutLog( string.format( EgtDoorsMsg[615], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[615], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 5 then + DoorOutLog( string.format( EgtDoorsMsg[637], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[637], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 6 then + DoorOutLog( string.format( EgtDoorsMsg[660], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[660], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 7 then + DoorOutLog( string.format( EgtDoorsMsg[661], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[661], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 8 then + DoorOutLog( string.format( EgtDoorsMsg[662], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[662], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 9 then + DoorOutLog( string.format( EgtDoorsMsg[663], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[663], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 10 then + DoorOutLog( string.format( EgtDoorsMsg[664], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[664], GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + elseif nErrPrf == 11 then + DoorOutLog( string.format( EgtDoorsMsg[703], DGD.nVersion, GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[703], DGD.nVersion, GetLineNumber()) + DGD.ERR = 8 + bWriteErr = false + break + else + -- se non ci sono proprietà alla porta, con modalità probe e uno dei fianchi è lavorato, do errore per incompatibilità + if not DGD.Properties and ( DGD.PROBE > 0 and DGC.NPM == 0) and + ( DGD.tProfs.top.machining or DGD.tProfs.bottom.machining or DGD.tProfs.hingeedge.machining or DGD.tProfs.lockedge.machining) then + + DoorOutLog( EgtDoorsMsg[632], 0) + DGD.ERM = DGD.ERM .. '\n' .. EgtDoorsMsg[632] + DGD.ERR = 13 + bWriteErr = false + break + end + end + sOutLogMsg = ' DGD.tProfs.top='..DGD.tProfs.top.trimming..' '.. + tostring(DGD.tProfs.top.machining)..' '.. + EgtNumToString(DGD.tProfs.top.offset,4) + DoorOutLog( sOutLogMsg, 0) + + sOutLogMsg = ' DGD.tProfs.bottom='..DGD.tProfs.bottom.trimming..' '.. + tostring(DGD.tProfs.bottom.machining)..' '.. + EgtNumToString(DGD.tProfs.bottom.offset,4) + DoorOutLog( sOutLogMsg, 0) + + sOutLogMsg = ' DGD.tProfs.hingeedge='..DGD.tProfs.hingeedge.trimming..' '.. + tostring(DGD.tProfs.hingeedge.machining)..' '.. + EgtNumToString(DGD.tProfs.hingeedge.offset,4) + DoorOutLog( sOutLogMsg, 0) + + sOutLogMsg = ' DGD.tProfs.lockedge='..DGD.tProfs.lockedge.trimming..' '.. + tostring(DGD.tProfs.lockedge.machining)..' '.. + EgtNumToString(DGD.tProfs.lockedge.offset,4) + DoorOutLog( sOutLogMsg, 0) + + ------------------------------------------ + -- Lettura parametri ferramenta, opzionali + ------------------------------------------ + if DGD.nVersion >= 2 then + local StartHw = StringFromLine( 'hardware:') + if not StartHw then + DoorOutLog( string.format( EgtDoorsMsg[702], DGD.nVersion), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[702], DGD.nVersion) + DGD.ERR = 28 + bWriteErr = false + break + end + end + + -- Lettura sfinestrature vision cutout + if not DGD.sFrame then + if GetVisionCutOuts() then + if DGD.tVisions then + local nContVC = 1 + while nContVC <= #DGD.tVisions do + sOutLogMsg = ' DGD.tVisions.Id='..EgtNumToString(nContVC,0)..' '.. + DGD.tVisions[nContVC].shape + if DGD.tVisions[nContVC].length then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].length,4) + end + if DGD.tVisions[nContVC].width then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].width,4) + end + if DGD.tVisions[nContVC].top_rail then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].top_rail,4) + end + if DGD.tVisions[nContVC].lock_stile then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].lock_stile,4) + end + if DGD.tVisions[nContVC].radius then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].radius,4) + end + if DGD.tVisions[nContVC].center_from_top then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].center_from_top,4) + end + if DGD.tVisions[nContVC].center_from_lock then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tVisions[nContVC].center_from_lock,4) + end + if DGD.tVisions[nContVC].door_center then + sOutLogMsg = sOutLogMsg..' '..DGD.tVisions[nContVC].door_center + end + if DGD.tVisions[nContVC].split then + sOutLogMsg = sOutLogMsg..' '.. EgtIf( DGD.tVisions[nContVC].split, '1', '0') + end + if DGD.tVisions[nContVC].dir then + sOutLogMsg = sOutLogMsg..' '.. DGD.tVisions[nContVC].dir + end + DoorOutLog( sOutLogMsg, 0) + nContVC = nContVC + 1 + end + end + end + end + + if #DGD.tVisions == 0 then -- se non ho trovato sfinestrature + DoorOutLog( EgtDoorsMsg[442], 0) + end + + -- Lettura sfinestratura inferiori: louver + if not DGD.sFrame then + if GetLouverCutOut() then + if DGD.tLouvers then + local nContLC = 1 + while nContLC <= #DGD.tLouvers do + sOutLogMsg = ' DGD.tLouvers.Id='..EgtNumToString(nContLC,0) + if DGD.tLouvers[nContLC].length then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tLouvers[nContLC].length,4) + end + if DGD.tLouvers[nContLC].width then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tLouvers[nContLC].width,4) + end + if DGD.tLouvers[nContLC].bottom_rail then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tLouvers[nContLC].bottom_rail,4) + end + if DGD.tLouvers[nContLC].lock_stile then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tLouvers[nContLC].lock_stile,4) + end + if DGD.tLouvers[nContLC].door_center then + sOutLogMsg = sOutLogMsg..' '..DGD.tLouvers[nContLC].door_center + end + + DoorOutLog( sOutLogMsg, 0) + nContLC = nContLC + 1 + end + end + end + end + + if #DGD.tLouvers == 0 then -- se non ho trovato sfinestrature inferiori + DoorOutLog( EgtDoorsMsg[443], 0) + end + + -- Lettura sfinestrature inferiori: mail slot + if not DGD.sFrame then + if GetMailSlots() then + if DGD.tMailSlots then + local nContMS = 1 + while nContMS <= #DGD.tMailSlots do + sOutLogMsg = ' DGD.tMailSlots.Id='..EgtNumToString(nContMS,0)..' '.. + DGD.tMailSlots[nContMS].template + if DGD.tMailSlots[nContMS].length then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tMailSlots[nContMS].length,4) + end + if DGD.tMailSlots[nContMS].bottom_rail then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tMailSlots[nContMS].bottom_rail,4) + end + if DGD.tMailSlots[nContMS].delta_center then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tMailSlots[nContMS].delta_center,4) + end + + DoorOutLog( sOutLogMsg, 0) + nContMS = nContMS + 1 + end + end + end + end + + if #DGD.tMailSlots == 0 then -- se non ho trovato sfinestrature inferiori tipo mail slot + DoorOutLog( EgtDoorsMsg[444], 0) + end + + -- Lettura spioncini: viewer + if not DGD.sFrame then + if GetViewers() then + if DGD.tViewers then + local nContVw = 1 + while nContVw <= #DGD.tViewers do + sOutLogMsg = ' DGD.tViewers.Id='..EgtNumToString(nContVw,0)..' '.. + DGD.tViewers[nContVw].template + if DGD.tViewers[nContVw].bottom_rail then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tViewers[nContVw].bottom_rail,4) + end + if DGD.tViewers[nContVw].delta_center then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tViewers[nContVw].delta_center,4) + end + if DGD.tViewers[nContVw].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tViewers[nContVw].side + end + + DoorOutLog( sOutLogMsg, 0) + nContVw = nContVw + 1 + end + end + end + end + + if #DGD.tViewers == 0 then -- se non ho trovato spioncini viewer + DoorOutLog( EgtDoorsMsg[445], 0) + end + + -- Lettura sfinestrature flush pull + if not DGD.sFrame then + if GetFlushPulls() then + if DGD.tFlushPulls then + local nContFp = 1 + while nContFp <= #DGD.tFlushPulls do + sOutLogMsg = ' DGD.tFlushPulls.Id='..EgtNumToString(nContFp,0)..' '.. + DGD.tFlushPulls[nContFp].template + if DGD.tFlushPulls[nContFp].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushPulls[nContFp].position,4) + end + if DGD.tFlushPulls[nContFp].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushPulls[nContFp].back_set,4) + end + if DGD.tFlushPulls[nContFp].depth then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushPulls[nContFp].depth,4) + end + if DGD.tFlushPulls[nContFp].face then + sOutLogMsg = sOutLogMsg..' '..DGD.tFlushPulls[nContFp].face + end + + DoorOutLog( sOutLogMsg, 0) + nContFp = nContFp + 1 + end + end + end + end + + if #DGD.tFlushPulls == 0 then -- se non ho trovato geometrie tipo flush pull + DoorOutLog( EgtDoorsMsg[446], 0) + end + + -- Lettura dati cerniere + if not DGD.sFrame or DGD.sFrame == 'H' or DGD.sFrame == 'HE' then + if GetHinges() then + if DGD.tHinges then + local nContHg = 1 + while nContHg <= #DGD.tHinges do + sOutLogMsg = ' DGD.tHinges.Id='..EgtNumToString(nContHg,0)..' '.. + DGD.tHinges[nContHg].template + if DGD.tHinges[nContHg].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tHinges[nContHg].position,4) + end + if DGD.tHinges[nContHg].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tHinges[nContHg].back_set,4) + end + if DGD.tHinges[nContHg].thickness then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tHinges[nContHg].thickness,4) + end + + DoorOutLog( sOutLogMsg, 0) + nContHg = nContHg + 1 + end + end + end + end + + if #DGD.tHinges == 0 then -- se non ho trovato cerniere + DoorOutLog( EgtDoorsMsg[447], 0) + end + + -- Lettura dati EPT + if not DGD.sFrame or DGD.sFrame == 'H' or DGD.sFrame == 'HE' then + if GetEPT() then + if DGD.tEPTs then + local nContEPT = 1 + while nContEPT <= #DGD.tEPTs do + sOutLogMsg = ' DGD.tEPTs.Id='..EgtNumToString(nContEPT,0)..' '.. + DGD.tEPTs[nContEPT].template + if DGD.tEPTs[nContEPT].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tEPTs[nContEPT].position,4) + end + if DGD.tEPTs[nContEPT].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tEPTs[nContEPT].back_set,4) + end + + DoorOutLog( sOutLogMsg, 0) + nContEPT = nContEPT + 1 + end + end + end + end + + if #DGD.tEPTs == 0 then -- se non ho trovato EPT + DoorOutLog( EgtDoorsMsg[557], 0) + end + + -- Lettura dati serrature + if not DGD.sFrame or DGD.sFrame == 'L' or DGD.sFrame == 'LE' or DGD.nTypePz == 5 or + DGD.nTypePz == 6 then + if GetLocks() then + if DGD.tLocks then + local nContLk = 1 + while nContLk <= #DGD.tLocks do + sOutLogMsg = ' DGD.tLocks.Id='..EgtNumToString(nContLk,0)..' '.. + DGD.tLocks[nContLk].template + if DGD.tLocks[nContLk].position then + sOutLogMsg = sOutLogMsg .. ' ' .. EgtNumToString(DGD.tLocks[nContLk].position,4) + end + if DGD.tLocks[nContLk].back_set then + sOutLogMsg = sOutLogMsg .. ' ' .. EgtNumToString(DGD.tLocks[nContLk].back_set,4) + end + if DGD.tLocks[nContLk].offset then + sOutLogMsg = sOutLogMsg .. ' ' .. EgtNumToString(DGD.tLocks[nContLk].offset,4) + end + if DGD.tLocks[nContLk].side then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tLocks[nContLk].side + end + if DGD.tLocks[nContLk].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tLocks[nContLk].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContLk = nContLk + 1 + end + end + end + end + + if #DGD.tLocks == 0 then -- se non ho trovato serrature + DoorOutLog( EgtDoorsMsg[448], 0) + end + + -- Lettura dati flush bolts + if not DGD.sFrame or DGD.nTypePz == 5 or DGD.nTypePz == 6 then + if GetFlushBolts() then + if DGD.tFlushBolts then + local nContFBt = 1 + while nContFBt <= #DGD.tFlushBolts do + sOutLogMsg = ' DGD.tFlushBolts.Id='..EgtNumToString(nContFBt,0)..' '.. + DGD.tFlushBolts[nContFBt].template + if DGD.tFlushBolts[nContFBt].type then + sOutLogMsg = sOutLogMsg..' '..DGD.tFlushBolts[nContFBt].type + end + if DGD.tFlushBolts[nContFBt].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tFlushBolts[nContFBt].side + end + if DGD.tFlushBolts[nContFBt].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushBolts[nContFBt].position,4) + end + if DGD.tFlushBolts[nContFBt].offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushBolts[nContFBt].offset,4) + end + if DGD.tFlushBolts[nContFBt].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tFlushBolts[nContFBt].back_set,4) + end + if DGD.tFlushBolts[nContFBt].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tFlushBolts[nContFBt].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContFBt = nContFBt + 1 + end + end + end + end + + if #DGD.tFlushBolts == 0 then -- se non ho trovato serrature + DoorOutLog( EgtDoorsMsg[449], 0) + end + + -- Lettura dati serrature + if not DGD.sFrame or DGD.sFrame == 'L' or DGD.sFrame == 'LE' then + if GetEdgePulls() then + if DGD.tEdgePulls then + local nContEp = 1 + while nContEp <= #DGD.tEdgePulls do + sOutLogMsg = ' DGD.tEdgePulls.Id='..EgtNumToString(nContEp,0)..' '.. + DGD.tEdgePulls[nContEp].template + if DGD.tEdgePulls[nContEp].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tEdgePulls[nContEp].position,4) + end + + DoorOutLog( sOutLogMsg, 0) + nContEp = nContEp + 1 + end + end + end + end + + if #DGD.tEdgePulls == 0 then -- se non ho trovato serrature + DoorOutLog( EgtDoorsMsg[450], 0) + end + + -- Lettura dati Roller Latch + if not DGD.sFrame or DGD.sFrame == 'L' or DGD.sFrame == 'LE' or DGD.nTypePz == 5 or + DGD.nTypePz == 6 then + if GetRollerLatchs() then + if DGD.tRollerLatchs then + local nContRL = 1 + while nContRL <= #DGD.tRollerLatchs do + sOutLogMsg = ' DGD.tRollerLatchs.Id='..EgtNumToString(nContRL,0)..' '.. + DGD.tRollerLatchs[nContRL].template + if DGD.tRollerLatchs[nContRL].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tRollerLatchs[nContRL].side + end + if DGD.tRollerLatchs[nContRL].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tRollerLatchs[nContRL].position,4) + end + if DGD.tRollerLatchs[nContRL].offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tRollerLatchs[nContRL].offset,4) + end + if DGD.tRollerLatchs[nContRL].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tRollerLatchs[nContRL].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContRL = nContRL + 1 + end + end + end + end + + if #DGD.tRollerLatchs == 0 then -- se non ho trovato Roller Latchs + DoorOutLog( EgtDoorsMsg[451], 0) + end + + -- Lettura dati Pivot Hinge + if not DGD.sFrame or DGD.sFrame == 'H' or DGD.sFrame == 'HE' or DGD.nTypePz == 5 or DGD.nTypePz == 6 then + if GetPivots() then + if DGD.tPivots then + local nContPv = 1 + while nContPv <= #DGD.tPivots do + sOutLogMsg = ' DGD.tPivots.Id='..EgtNumToString(nContPv,0)..' '.. + DGD.tPivots[nContPv].template + if DGD.tPivots[nContPv].type then + sOutLogMsg = sOutLogMsg..' '..DGD.tPivots[nContPv].type + end + if DGD.tPivots[nContPv].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tPivots[nContPv].side + end + if DGD.tPivots[nContPv].radius then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tPivots[nContPv].radius,4) + end + if DGD.tPivots[nContPv].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tPivots[nContPv].position,4) + end + if DGD.tPivots[nContPv].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tPivots[nContPv].back_set,4) + end + if DGD.tPivots[nContPv].depth_f then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tPivots[nContPv].depth_f,4) + end + if DGD.tPivots[nContPv].offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tPivots[nContPv].offset,4) + end + if DGD.tPivots[nContPv].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tPivots[nContPv].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContPv = nContPv + 1 + end + end + end + end + + if #DGD.tPivots == 0 then -- se non ho trovato Pivot Hinges + DoorOutLog( EgtDoorsMsg[452], 0) + end + + -- Lettura dati stops and closers + if not DGD.sFrame or DGD.nTypePz == 5 then + if GetStopsAndClosers() then + if DGD.tStopsAndClosers then + local nContSC = 1 + while nContSC <= #DGD.tStopsAndClosers do + sOutLogMsg = ' DGD.tStopsAndClosers.Id='..EgtNumToString(nContSC,0)..' '.. + DGD.tStopsAndClosers[nContSC].template + if DGD.tStopsAndClosers[nContSC].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tStopsAndClosers[nContSC].position,4) + end + if DGD.tStopsAndClosers[nContSC].pocket_offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tStopsAndClosers[nContSC].pocket_offset,4) + end + if DGD.tStopsAndClosers[nContSC].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tStopsAndClosers[nContSC].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContSC = nContSC + 1 + end + end + end + end + + if #DGD.tStopsAndClosers == 0 then -- se non ho trovato stop and closers + DoorOutLog( EgtDoorsMsg[453], 0) + end + + -- Lettura dati over head + if not DGD.sFrame or DGD.nTypePz == 5 then + if GetOverHeads() then + if DGD.tOHeads then + local nContOH = 1 + while nContOH <= #DGD.tOHeads do + sOutLogMsg = ' DGD.tOHeads.Id='..EgtNumToString(nContOH,0)..' '.. + DGD.tOHeads[nContOH].template + if DGD.tOHeads[nContOH].pockpos then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tOHeads[nContOH].pockpos,4) + end + if DGD.tOHeads[nContOH].pocklength then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tOHeads[nContOH].pocklength,4) + end + if DGD.tOHeads[nContOH].pocket_offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tOHeads[nContOH].pocket_offset,4) + end + if DGD.tOHeads[nContOH].armpos then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tOHeads[nContOH].armpos,4) + end + if DGD.tOHeads[nContOH].armlength then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tOHeads[nContOH].armlength,4) + end + if DGD.tOHeads[nContOH].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tOHeads[nContOH].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContOH = nContOH + 1 + end + end + end + end + + if #DGD.tOHeads == 0 then -- se non ho trovato over head + DoorOutLog( EgtDoorsMsg[526], 0) + end + + -- Lettura dati strike ( non inserisce stike che stonno su frame top e bottom) + if not DGD.sFrame or DGD.sFrame == 'L' or DGD.sFrame == 'LE' or DGD.nTypePz == 5 or DGD.nTypePz == 6 then + if GetStrikes() then + if DGD.tStrikes then + local nContSt = 1 + while nContSt <= #DGD.tStrikes do + sOutLogMsg = ' DGD.tStrikes.Id='..EgtNumToString(nContSt,0)..' '.. + DGD.tStrikes[nContSt].template + if DGD.tStrikes[nContSt].position then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tStrikes[nContSt].position,4) + end + if DGD.tStrikes[nContSt].back_set then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tStrikes[nContSt].back_set,4) + end + if DGD.tStrikes[nContSt].offset then + sOutLogMsg = sOutLogMsg .. ' ' .. EgtNumToString(DGD.tStrikes[nContSt].offset,4) + end + if DGD.tStrikes[nContSt].other_door then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tStrikes[nContSt].other_door + end + + DoorOutLog( sOutLogMsg, 0) + nContSt = nContSt + 1 + end + end + end + end + + if #DGD.tStrikes == 0 then -- se non ho trovato strike + DoorOutLog( EgtDoorsMsg[535], 0) + end + + -- Lettura dati groove + if not DGD.sFrame then + if GetGrooves() then + if DGD.tGrooves then + local nContGr = 1 + while nContGr <= #DGD.tGrooves do + sOutLogMsg = ' DGD.tGrooves.Id='..EgtNumToString(nContGr,0)..' '.. + DGD.tGrooves[nContGr].template + if DGD.tGrooves[nContGr].type then + sOutLogMsg = sOutLogMsg..' '..DGD.tGrooves[nContGr].type + end + if DGD.tGrooves[nContGr].width then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].width,4) + end + if DGD.tGrooves[nContGr].depth then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].depth,4) + end + if DGD.tGrooves[nContGr].fst then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].fst,4) + end + if DGD.tGrooves[nContGr].hst then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].hst,4) + end + if DGD.tGrooves[nContGr].lst then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].lst,4) + end + if DGD.tGrooves[nContGr].groove_offset then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tGrooves[nContGr].groove_offset,4) + end + if DGD.tGrooves[nContGr].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tGrooves[nContGr].side + end + + DoorOutLog( sOutLogMsg, 0) + nContGr = nContGr + 1 + end + end + end + end + + if #DGD.tGrooves == 0 then -- se non ho trovato groove + DoorOutLog( EgtDoorsMsg[536], 0) + end + + -- Lettura dati rabbet +-- if not DGD.sFrame then + if GetRabbets() then + if DGD.tRabbets then + local nContRb = 1 + while nContRb <= #DGD.tRabbets do + sOutLogMsg = ' DGD.tRabbets.Id='..EgtNumToString(nContRb,0)..' '.. + DGD.tRabbets[nContRb].template + if DGD.tRabbets[nContRb].side then + sOutLogMsg = sOutLogMsg..' '..DGD.tRabbets[nContRb].side + end + if DGD.tRabbets[nContRb].width then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tRabbets[nContRb].width,4) + end + if DGD.tRabbets[nContRb].depth then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tRabbets[nContRb].depth,4) + end + if DGD.tRabbets[nContRb].oppo then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tRabbets[nContRb].oppo,4) + end + + DoorOutLog( sOutLogMsg, 0) + nContRb = nContRb + 1 + end + end + end +-- end + + if #DGD.tRabbets == 0 then -- se non ho trovato rabbet + DoorOutLog( EgtDoorsMsg[537], 0) + end + + -- Lettura dati Face Decoration + if not DGD.sFrame then + if GetDecorations() then + if DGD.tDecorations then + local nContDc = 1 + while nContDc <= #DGD.tDecorations do + sOutLogMsg = ' DGD.tDecorations.Id='..EgtNumToString(nContDc,0)..' '.. + DGD.tDecorations[nContDc].template + if DGD.tDecorations[nContDc].type then + sOutLogMsg = sOutLogMsg..' '..DGD.tDecorations[nContDc].type + end + if DGD.tDecorations[nContDc].depth then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tDecorations[nContDc].depth,4) + end + if DGD.tDecorations[nContDc].dft then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tDecorations[nContDc].dft,4) + end + if DGD.tDecorations[nContDc].dfb then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tDecorations[nContDc].dfb,4) + end + if DGD.tDecorations[nContDc].dfl then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tDecorations[nContDc].dfl,4) + end + if DGD.tDecorations[nContDc].dfh then + sOutLogMsg = sOutLogMsg..' '..EgtNumToString(DGD.tDecorations[nContDc].dfh,4) + end + if DGD.tDecorations[nContDc].face then + sOutLogMsg = sOutLogMsg .. ' ' .. DGD.tDecorations[nContDc].face + end + + DoorOutLog( sOutLogMsg, 0) + nContDc = nContDc + 1 + end + end + end + end + + if #DGD.tDecorations == 0 then -- se non ho trovato serrature + DoorOutLog( EgtDoorsMsg[645], 0) + end + + -- lettura nuovo gruppo options + if GetOptions() then + sOutLogMsg = ' DGD.tOptions=' .. table.concat( DGD.tOptions, ',') + DoorOutLog( sOutLogMsg, 0) + end + + -- se a questo punto il ddf non termina o non ha il separatore di pezzo '---' + -- c'è un errore nel ddf appena letto + if not CheckKeyFromLine( '---') and not CheckKeyFromLine( '...') and not EndOfFile() then + DoorOutLog( string.format( EgtDoorsMsg[604], GetLineNumber()), 0) + DGD.ERM = DGD.ERM .. '\n' .. string.format( EgtDoorsMsg[604], GetLineNumber()) + DGD.ERR = 9 + bWriteErr = false + break + end + + ------------------------------------------- + ------------------------------------------- + -- faccio la verifica sulla Mtable + ------------------------------------------- + ------------------------------------------- + + sMTable = sMTableOri + + -- per risalire al nome file della tabella, aggiungo eventuale nome materiale + -- tranne se il nome è wood + if DGD.Material and #DGD.Material > 0 and string.lower(DGD.Material) ~= 'wood' then + sMTable = sMTable .. '_' .. DGD.Material + end + + bLocFoundMTable = VerifyMtable() + + -- percorsi dei file pezzo locale + sTxtOkFile = sFileDir .. DGD.sCode .. '.tok' + sErrFile = sFileDir .. DGD.sCode .. '.txt' + sCncFile = sFileDir .. DGD.sCode .. '.cnc' + sNgeFile = sFileDir .. DGD.sCode .. '.nge' + sOriPrbFile = sFileDir .. 'data.dat' + sPrbFile = sFileDir .. DGD.sCode .. '.dat' + + -- Rimozione vecchi file log, nge e cnc e tok + EgtEraseFile( sErrFile) + EgtEraseFile( sTxtOkFile) + EgtEraseFile( sNgeFile) + EgtEraseFile( sCncFile) + + -- creo pezzo porta + if DGD.ERR <= 0 then + + nCountPieces = nCountPieces + 1 + + -- leggo il file probe (se c'è il flag di ri-calcolo porta da file probe) + local bReadFileDat = LoadDataProbeFile( sOriPrbFile, sPrbFile) + + if bReadFileDat then + + -- Controllo che la versione del file .prb non coincide con il settaggio presente nel file CurrDoorsCustomData + if DGD.PROBE == 2 and ( not tProbeDoor.OPM or not DGC.Pms or ( tProbeDoor.OPM and DGC.Pms and tProbeDoor.OPM ~= DGC.Pms)) then + local sMessageErr = string.format( EgtDoorsMsg[659], sPrbFile) -- file dat non trovato + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 26 + else + + -- Creazione della porta + bLocFoundMTable = DoorCreation() + + EgtSaveFile( sNgeFile) + DoorOutLog( ' *** Door creation completed ***', 0) + + -- se prima porta + if nTypePiece == 1 then + sFirstDoor = sNgeFile + elseif nTypePiece == 2 then + sSecondDoor = sNgeFile + elseif nTypePiece == 3 then + sFrameSx = sNgeFile + elseif nTypePiece == 4 then + sFrameDx = sNgeFile + elseif nTypePiece == 5 then + sFrameTop = sNgeFile + elseif nTypePiece == 6 then + sFrameBot = sNgeFile + end + end + else + local sMessageErr = string.format( EgtDoorsMsg[631], sPrbFile) -- file dat non trovato + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 12 + end + end + + -- Scrivo il risultato su file apposito + WriteErrFile( sErrFile) + DoorOutLog( ' Err=' .. tostring( DGD.ERR) .. '\n', 1) + bWriteErr = true + else -- se non trovata descrizione ddf + sPrvKeyLine = '---' + end + + -- se trovato separatore altro pezzo + if KeyFromLine( '---') then + if sNgeFile then + DoorOutLog( ' *** End piece file : ' .. sNgeFile ..' ***\n', 0) + sNgeFile = nil + end + DoorOutLog( ' *** Next piece into parsing file : ' .. DGD.FILE ..' ***\n', 0) + sPrvKeyLine = '---' + else + if sNgeFile then + DoorOutLog( ' *** End piece file : ' .. sNgeFile ..' ***', 0) + end + end + end -- end while + + -- se il file txt dell'errore non ancora scritto, assegno le variabili di errore degli assemblati + if not bWriteErr then + if DGD.EGR == 0 then + DGD.EGR = DGD.ERR + end + if DGD.ERM and string.len(DGD.ERM) > 0 then + if DGD.EGM then + DGD.EGM = DGD.EGM .. '\n' .. DGD.ERM + end + end + end + + -- Scrivo il risultato su file apposito + WriteErrFileAsmbl( sErrFileM) + + if not bWriteErr then + DoorOutLog( ' Err=' .. tostring( DGD.ERR) .. '\n', 1) + end + + -- Chiusura file DDF + if bOpenDdf then + CloseFile() + end + + return bLocFoundMTable +end + +----------------------------------------------------------------- +-- *** Main function *** +----------------------------------------------------------------- +local function Doors() + + -- Reset librerie per evitare l'errore in caso riparto da una situazione di errore dello script + ResetDoorsLibs() + + -- Reset dati globali + ResetDoorsGlobDataAssembly() + ResetDoorsGlobData() + -- Reset dati custom + ResetDoorsCustomData() + + local sMessageErr + -- debug per abilitare le quote nell'EgtCam5 +-- DGD.MachEn = 0 + + -- per evitare problemi nel caso che nel nome file o nella cartella sia presente 'ddf' + -- separo path nome ed estensione e poi successivamente concateno direttamente l'estensione + sFileDir, sFileName, sFileExt = EgtSplitPath( DGD.FILE) + sErrFileM = sFileDir .. sFileName .. '.txt' + sLogFile = sFileDir .. sFileName .. '.log' + sTxtOkFile = sFileDir .. sFileName .. '.tok' + + -- Rimozione vecchi file log, nge e cnc + EgtEraseFile( sLogFile) + EgtEraseFile( sErrFileM) + EgtEraseFile( sTxtOkFile) + + -- creo nuovo file log + OpenLogFile(sLogFile, 'w') + + -- variabili per gestione file MTable + local sIniFilePath = EgtGetIniFile() -- percorso del file ini dell'EgtCam5 + sMTable = EgtGetStringFromIni( 'Doors', 'CurrMTable', '', sIniFilePath) + sMTableOri = sMTable + + local tMTable + local tMachineOptions + local bFoundMTable +-- local M + + -- resetto contatore pezzi e il tipo pezzi + nCountPieces = 0 + nTypePiece = 0 + +--[[ + + -- questo è un codice ipotetico + -- la tabella attualmente non viene passata dal file batch + + -- verifico se c'è il nome tabella passato da batch +-- if DGD.NCGEN and DGD.NTB and string.len(DGD.NTB) > 0 then +-- sMTable = DGD.NTB +-- bFoundMTable = true +-- else + + -- verifico se esiste il nome file + if sMTable and string.len(sMTable) > 0 then + bFoundMTable = true + end +-- end + + -- se nome MTable presente + if bFoundMTable and DGD.MachEn > 0 then + + -- verifico se esiste il file + sMTablePath = sBaseDir..'MTables\\'..sMTable..'.mtl' + + if EgtExistsFile(sMTablePath) then + + sMTablePath = sBaseDir..'MTables\\' + M = require( sMTable) + + if M then + tMachineData = M.MMachineData + if not tMachineData then + sMessageErr = string.format( EgtDoorsMsg[489], sMTable) -- dati macchina non validi + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 25 + WriteErrFile( sErrFileM) + bFoundMTable = false + end + else + sMessageErr = string.format( EgtDoorsMsg[490], sMTable) -- tabella non trovata + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 24 + WriteErrFile( sErrFileM) + bFoundMTable = false + end + else + sMessageErr = string.format( EgtDoorsMsg[487], sMTablePath) -- non c'è il file della tabella + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 23 + WriteErrFile( sErrFileM) + bFoundMTable = false + end + elseif DGD.MachEn > 0 then + sMessageErr = string.format( EgtDoorsMsg[487], sMTable) -- il nome del file della tabella non è valido + DoorOutLog( sMessageErr, 0) + DGD.ERM = DGD.ERM .. '\n' .. sMessageErr + DGD.ERR = 22 + WriteErrFile( sErrFileM) + end +]]-- + +-- if ( bFoundMTable and DGD.MachEn > 0) or DGD.MachEn == 0 then + if DGD.MachEn >= 0 then + + -- Segnalo inizio interpretazione file + DoorOutLog( ' *** Start parsing file : ' .. DGD.FILE ..' ***', 0) + + -- controllo variabile che dovrebbe provenire dal prod + if not DGD.PROBE then DGD.PROBE = 0 end + -- controllo variabile che dovrebbe provenire dal CurrDoorsCustomData + if not DGC.NPM then DGC.NPM = 0 end + + -- se DGD.NPM = 1 ma settata nuova interpretazione, forzo il parametro DGC.Pms = 1 + if DGC.NPM > 0 then + DGC.Pms = 1 + -- se DGD.NPM = 2 forzo il parametro DGC.PROBE = 1 + if DGC.NPM == 2 then + DGD.PROBE = 1 + end + end + + -- controllo variabile che dovrebbe provenire dal CurrDoorsCustomData + if not DGC.Pms then DGC.Pms = 0 end + + -- Lettura file DDF e creazione geometria porta + bFoundMTable = ReadAndParseDdfAndMakeDoors() + + if bFoundMTable then + + -- se non è lanciato dal batch e ci sono più pezzi li carico in un unico progetto + if nCountPieces > 1 and DGD.ERR <= 0 then + + EgtNewFile() + DGD.PZ = EgtGroup( GDB_ID.ROOT) + EgtSetName( DGD.PZ, sFileName) + EgtSetCurrPartLayer( DGD.PZ, GDB_ID.NULL) + local nIdDummyPart = EgtGetFirstPart() + local nIdFrameSx, nIdDoor1, nIdDoor2, nIdFrameDx, nIdFrameTop, nIdFrameBot + local dOffsLeft = 0 + + if sFirstDoor and EgtInsertFile( sFirstDoor) then + -- non muovo la prima porta + nIdDoor1 = EgtGetLastPart() + EgtSetInfo( nIdDoor1, 'Assembly', 'first') + EgtSetInfo( nIdDoor1, 'MoveedTo', {0,0,0}) + local dWidthPiece = EgtGetInfo( nIdDoor1, 'W', 'd') + dOffsLeft = dWidthPiece + -- setto nota modalità probe + EgtSetInfo( nIdDoor1, 'ProbeMode', DGD.PROBE) + -- setto nota postprocessor probe mode setting + EgtSetInfo( nIdDoor1, 'PostProbeSet', DGC.Pms) + EgtSetInfo( nIdDoor1, 'NewProbeMean', DGC.NPM) + end + + if sSecondDoor and EgtInsertFile( sSecondDoor) then + -- rototraslazione del pezzo + nIdDoor2 = EgtGetLastPart() + EgtSetInfo( nIdDoor2, 'Assembly', 'second') + local dWidthPiece = EgtGetInfo( nIdDoor2, 'W', 'd') + local dThickPiece = EgtGetInfo( nIdDoor2, 'T', 'd') + if dOffsLeft > 0 then + dOffsLeft = dOffsLeft + 10 + end + + EgtMove( nIdDoor2, Point3d( dOffsLeft,0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdDoor2, 'MoveedTo', {dOffsLeft,0,0}) + -- setto nota modalità probe + EgtSetInfo( nIdDoor2, 'ProbeMode', DGD.PROBE) + -- setto nota postprocessor probe mode setting + EgtSetInfo( nIdDoor2, 'PostProbeSet', DGC.Pms) + EgtSetInfo( nIdDoor2, 'NewProbeMean', DGC.NPM) + -- aggiorno offset per eventuale prossimo pezzo + dOffsLeft = dOffsLeft + dWidthPiece + end + + if sFrameSx and EgtInsertFile( sFrameSx) then + -- rototraslazione del pezzo + nIdFrameSx = EgtGetLastPart() + EgtSetInfo( nIdFrameSx, 'Assembly', 'framesx') + local dWidthPiece = EgtGetInfo( nIdFrameSx, 'W', 'd') + local dThickPiece = EgtGetInfo( nIdFrameSx, 'T', 'd') + EgtMove( nIdFrameSx, Point3d(-( dWidthPiece + dThickPiece),0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameSx, 'MoveedTo', {-( dWidthPiece + dThickPiece),0,0}) + end + + if sFrameDx and EgtInsertFile( sFrameDx) then + -- rototraslazione del pezzo + nIdFrameDx = EgtGetLastPart() + EgtSetInfo( nIdFrameDx, 'Assembly', 'framedx') + local dWidthPiece = EgtGetInfo( nIdFrameDx, 'W', 'd') + local dThickPiece = EgtGetInfo( nIdFrameDx, 'T', 'd') + if dOffsLeft > 0 then + EgtMove( nIdFrameDx, Point3d(( dOffsLeft + dThickPiece),0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameDx, 'MoveedTo', {( dOffsLeft + dThickPiece),0,0}) + else + EgtMove( nIdFrameDx, Point3d( dThickPiece,0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameDx, 'MoveedTo', {dThickPiece,0,0}) + end + dOffsLeft = dOffsLeft + dWidthPiece + dThickPiece + end + + if sFrameTop and EgtInsertFile( sFrameTop) then + -- rototraslazione del pezzo + nIdFrameTop = EgtGetLastPart() + EgtSetInfo( nIdFrameTop, 'Assembly', 'frametop') + local dWidthPiece = EgtGetInfo( nIdFrameTop, 'W', 'd') + local dThickPiece = EgtGetInfo( nIdFrameTop, 'T', 'd') + if dOffsLeft > 0 then + EgtMove( nIdFrameTop, Point3d(( dOffsLeft + dThickPiece),0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameTop, 'MoveedTo', {( dOffsLeft + dThickPiece),0,0}) + else + EgtMove( nIdFrameTop, Point3d( dThickPiece,0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameTop, 'MoveedTo', {dThickPiece,0,0}) + end + dOffsLeft = dOffsLeft + dWidthPiece + dThickPiece + end + + if sFrameBot and EgtInsertFile( sFrameBot) then + -- rototraslazione del pezzo + nIdFrameBot = EgtGetLastPart() + EgtSetInfo( nIdFrameBot, 'Assembly', 'framebot') + local dWidthPiece = EgtGetInfo( nIdFrameBot, 'W', 'd') + local dThickPiece = EgtGetInfo( nIdFrameBot, 'T', 'd') + if dOffsLeft > 0 then + EgtMove( nIdFrameBot, Point3d(( dOffsLeft + dThickPiece),0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameBot, 'MoveedTo', {( dOffsLeft + dThickPiece),0,0}) + else + EgtMove( nIdFrameBot, Point3d( dThickPiece,0,0) - ORIG(), GDB_RT.GRID) + EgtSetInfo( nIdFrameBot, 'MoveedTo', {dThickPiece,0,0}) + end + end + + if nIdFrameSx or nIdDoor1 or nIdDoor2 or nIdFrameDx or nIdFrameBot then + EgtErase(nIdDummyPart) + end + + -- setto la griglia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + sNgeFile = sFileDir .. sFileName .. '.nge' + EgtSaveFile( sNgeFile) + elseif nCountPieces == 1 and DGD.ERR <= 0 then + + if sFrameSx then + local nIdPiece = EgtGetLastPart() + EgtSetInfo( nIdPiece, 'Assembly', 'framesx') + EgtSetInfo( nIdPiece, 'MoveedTo', {0,0,0}) + elseif sFrameDx then + local nIdPiece = EgtGetLastPart() + EgtSetInfo( nIdPiece, 'Assembly', 'framedx') + EgtSetInfo( nIdPiece, 'MoveedTo', {0,0,0}) + elseif sFrameTop then + local nIdPiece = EgtGetLastPart() + EgtSetInfo( nIdPiece, 'Assembly', 'frametop') + EgtSetInfo( nIdPiece, 'MoveedTo', {0,0,0}) + elseif sFrameBot then + local nIdPiece = EgtGetLastPart() + EgtSetInfo( nIdPiece, 'Assembly', 'framebot') + EgtSetInfo( nIdPiece, 'MoveedTo', {0,0,0}) + end + + -- setto nota modalità probe + local nIdPiece = EgtGetLastPart() + EgtSetInfo( nIdPiece, 'ProbeMode', DGD.PROBE) + -- setto nota postprocessor probe mode setting + EgtSetInfo( nIdPiece, 'PostProbeSet', DGC.Pms) + EgtSetInfo( nIdPiece, 'NewProbeMean', DGC.NPM) + + -- setto la griglia top + EgtSetGridFrame( Frame3d( 0,0,0, GDB_FR.TOP)) + + sNgeFile = sFileDir .. sFileName .. '.nge' + EgtSaveFile( sNgeFile) + end + + -- Se richiesta generazione lavorazioni da file batch e non ci sono stati errori + if DGD.NCGEN and DGD.ERR <= 0 then + + if not dofile( sBaseDir..'Machining.lua') then -- se machining va male + if string.len(DGD.EMC) > 0 then + DoorOutLog( DGD.EMC, 0) + else + DoorOutLog( EgtDoorsMsg[455], 0) + end + DGD.ERM = DGD.ERM .. '\n' .. EgtDoorsMsg[455] + if DGD.ERR <= 0 then + DGD.ERR = 20 + end + DoorOutLog( ' Err=' .. tostring( DGD.ERR) .. '\n', 1) + else + DoorOutLog( ' ' .. EgtDoorsMsg[498], 0) + EgtOutText( EgtDoorsMsg[498]) + end + end + end + end + + -- chiudo file log + CloseLogFile() + + -- Reset librerie + ResetDoorsLibs() + package.loaded.EgtDoorsBase = nil + + if DGD.EGR and DGD.EGR ~= 0 and DGD.ERR ~= DGD.EGR then + DGD.ERR = DGD.EGR + elseif DGD.EGR and DGD.EGR ~= 0 then + DGD.ERR = DGD.EGR + end + + DGC = nil + return DGD.ERR + +end +DGD.Doors = Doors + +return {} + diff --git a/Main_Assemb.lua b/Main_Assemb.lua new file mode 100644 index 0000000..a73345f --- /dev/null +++ b/Main_Assemb.lua @@ -0,0 +1,60 @@ +-- +-- 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 +-- +-- Main_Assemb.lua by EgalWare s.r.l. 2017.10.01 +-- Main disposizione assemblato a raggruppamento + +-- 2022.07.27 V1.002 FM Modification to use compiled code + +-- Intestazioni +require( 'EgtBase') +_ENV = EgtProtectGlobal() +EgtEnableDebug( false) + +if not _G.DGD then + _G.DGD = {} +end + +-- 2022/12/27 commentate queste 4 linee perchè funziona anche senza il require EgtDoorsBase e EgtDoorsData +-- local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() +-- EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') +-- require( 'EgtDoorsBase') +-- require( 'EgtDoorsData') + +-- Tavola di passaggio valori +local STU = {} +-- i parametri passati durante la creazione di una nuova componente +STU.Assembl = 1 +_G.STU = STU + + +----------------------------------------------------------------- +-- *** Main function *** +----------------------------------------------------------------- +--se true raggruppato se false disposto +function STU.Assembled() + + local sNgeFile = EgtGetCurrFilePath() + local sRequireCompoName = '_AssemblyDisp' + + -- lancio il componente base + local MHgen = require( sRequireCompoName) + local bOkD = MHgen.AssemblyDispose( STU.Assembl) +-- EgtDraw() + EgtZoom( SCE_ZM.ALL, false) + EgtSaveFile( sNgeFile) + +end +DGD.Assembled = Assembled + +return {} + diff --git a/Version.lua b/Version.lua new file mode 100644 index 0000000..f439ba7 --- /dev/null +++ b/Version.lua @@ -0,0 +1,4 @@ +-- Version.lua by EgalWare s.r.l. 2025/03/18 +-- Gestione della versione di Doors + +VERSION = '2.7c1'