-- -- 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. -- 2025.03.19 V2.7c2 DS Corretto ordinamento lavorazioni con una o più lavorazioni senza percorso di lavoro. -- 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 nNumMachFromCam ~= 2 and ( 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 = {} local TabMachining = {} 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}) table.insert( TabMachining, tMachining[k]) MB.InsZedByTool( TabZMach, TabMachining, #TabMachining) 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 : -- tutte le ventose basse if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then DGD.EMC = ' ' .. EgtDoorsMsg[531] bOk = false break -- ventose iniziali ( parte destra) elseif nInd > 0 and nMaxIniFailed / nInd > 0.35 then local nNumMsg = EgtIf( nDispMode > 0, 532, 534) DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false break -- ventose intermedie elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then DGD.EMC = ' ' .. EgtDoorsMsg[533] bOk = false break -- ventose finali ( parte sinistra) elseif nInd > 0 and nMaxEndFailed / nInd > 0.35 then local nNumMsg = EgtIf( nDispMode > 0, 534, 532) DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false break -- somma di vari intervalli elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then 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