-- -- EEEEEEEEEE GGGGGG wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwww wwww -- EEEE GGGG GGGG wwww wwww wwww -- EEEE GGGG wwww wwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww -- EEEE GGGG GGGG wwww wwwwwwww wwww -- EEEE GGGG GGGG wwww wwww wwww wwww -- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww -- EEEEEEEEEE GGGGGG wwwwwww wwwwwww -- -- by EgalWare s.r.l. 10/07/2016 -- Machining generation for Doors program machine Multiax N1622 -- 2017.06.01 V1.011 FM Manage machining optimization -- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece -- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining -- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole -- 2017.12.07 V1.014 FM Change hinge shuttle assignement with 3 hinges: 60% always on shuttle near door reference, now V1.3 -- 2017.12.08 V1.015 FM Manage two new probe pointposition , before and after the hinge/pivot to probe always on left of hinge (according to disposition) -- 2017.12.16 V1.016 FM Change the percentage of shuttle assignement to variable dPercentDoorLength (by Adam L. requests) -- 2017.12.28 V1.016 FM Set note about hinge side machining -- 2017.12.28 V1.016 FM Set note about hinge side profile -- 2017.12.28 V1.016 FM Set note about door shift on Y with hinge not machined profile on reference -- 2017.12.28 V1.016 FM Set note about door probe error on hinge not machined profile on reference -- 2017.12.28 V1.016 FM Set note about lock side machining -- 2018.02.26 V1.0b1 FM Manage door dimension checking -- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces -- 2018.10.18 V1.0b3 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles -- 2018.10.23 V1.0b4 FM Manage rough machining -- 2019.01.14 V1.0b5 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set -- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name) -- 2019.01.23 V1.0b6 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files. -- 2019.01.24 V1.0b7 FM Extend cases to machine with AdjustHeadChisel operation, -- use new settings to use with this extended operation: NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL -- 2019.03.27 V1.0b8 FM Manage check door/jamb dimension by function CheckPieceDimension -- 2019.03.27 V1.0b9 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values -- 2019.03.27 V1.0b9 FM Modify error messages format into CheckPieceDimension -- 2019.03.27 V1.0c1 FM Manage estimate time -- 2019.03.29 V1.0c2 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles -- 2019.04.08 V1.0c3 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines -- Now it uses 1 line for antisplint blade and 1 line for normal blade -- 2019.04.08 V1.0c3 FM Manage Blade groove function AdjustBladeVertCurve -- 2019.04.30 v1.0c4 FM Manage function AdjustASplintWithBlade to manage anti-splint paths when machine groove by blade -- 2019.04.30 v1.0c4 FM Manage function AdjustHeadOnASplint to manage hinge anti-splint paths when machine groove by blade -- 2019.05.28 v1.0c5 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings -- 2019.07.22 V1.0c7 FM Manage better the updoor/underdoor machinings counter that generate flags values -- 2019.08.27 V1.0c8 FM Manage underneath machining checking (by machining note 'UD_CHECK') to disable vacuums -- (use new underneath distance by variable dDistInterferUnder) -- 2019.11.05 V1.0c9 FM Manage setup files -- 2020.03.19 V1.0d0 FM Fix error on check door dimension into CheckPieceDimension (when door is shifted by Bullnose profile on hinge side) -- 2021.03.18 V1.0d1 FM Add new variables to CurrCamInfo that was managed inside this (dVacOffsY, dMobOffsY, dLeftDistX, dRightDistX, MaxOverMat, StepOverMat) -- 2021.04.06 V1.0d1 FM Fix error on rename lock profile with _LK suffix -- 2021.04.07 V1.0d2 FM Manage new CurrCamInfo parameter (ForceDirMachHinge) to force the hinge machining direction (descending or ascending) -- 2021.04.20 V1.0d3 FM Manage new CurrCamInfo parameter (MaxPosMobBar) to limit the mobile ba to a max value with wide door -- 2021.05.03 V2.101 FM Manage simulation in background to verify collisions, if something collide, not generate CNC program -- 2021.05.04 V2.102 FM Manage new CurrCamInfo parameter (nDisableAutoCncName) to disable the automatic cnc name composed when generate cnc by GENERATE button -- to have always the same cnc file name -- 2021.05.21 V2.103 FM Manage new CurrCamInfo parameter (EnableCollisionDetect) to manage the collision detection -- 2021.10.13 V2.104 FM Add variables from CurrCamInfo for define safeety zone around pods -- 2021.10.26 V2.104 FM Manage FD Wedge Cup (FDWC) profile -- 2021.10.28 V2.105 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter -- 2021.11.23 V2.107 FM Manage option side probing. Expand function number of CurrDoorCustomData DGC.Pms: 3 side probe on all hardware (for NE machines) ; -- 4: side probe on all hardware except hardware on hinge side (for machines with shuttles) -- 2022.01.17 V2.108 FM Manage Split door cut by new CurrCamInfo parameter sCutDirectionAdmitted: = 'H' for cut along door Height; -- = 'W' for cut along door Width -- 2022.05.03 V2.109 FM use table paremeter tMainTabPar.NVP instead of variable bNoVertProf. This allow to unify Machining_4 and Machinin_8 processor -- 2022.11.15 V2.112 FM Manage side groove region as throu path and not as blind region -- 2023.01.20 V2.114 FM Modification to use compiled code -- 2023.03.07 V2.115 FM Fix error on manage region into StartVacVerify function -- 2023.03.29 V2.116 FM Fix error on calculate rough paths on Convex profile -- 2023.03.31 V1.117 FM Manage offsetted path ( by path note) to extra path of Convex profile -- 2023.04.03 V2.118 FM Manage Scrap piece removing -- 2023.05.12 V2.119 FM Manage virtual milling option into collision avoid check -- 2023.05.24 V2.120 FM Manage by new function AdjustVertAsOnHeads to modify anti split paths (of door heads) to be vertical on bevelled sides -- 2023.09.07 V2.121 FM Manage new file .tok (it's a copy of .txt file) to say Dprod when the generation is finished -- 2023.09.15 V2.122 FM Write shift value note OffSetPhase... -- 2023.09.16 V2.123 FM Manage invert paths on convex profile when door is dispose bevel up -- 2023.09.19 V2.124 FM Modify door disposition: if door has top or bottom trimmed side, dispose the door on right reference -- 2023.10.19 V2.125 FM Manage new parameter tMainTabPar.SVP to manage sand machining with 5xis head or not -- 2023.10.25 V2.126 FM Manage new parameter tMainTabPar.DSL to add extra length on profiling machining on hinge and lock sides (if sand machining found) -- 2023.11.16 V2.127 FM Manage new parameter tMainTabPar.DPSL to add extra length on sand machining on hinge and lock sides (if sand machining found) -- 2023.12.01 V2.125 FM Manage small planes on Convex profile -- 2024.05.30 V2.126 FM Manage new parameter tMainTabPar.NWD ( NarrowWidth CurrCamInfo parameter) to manage narrowest door to machine with only one head -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) local MachiningLoc = {} -- Librerie particolari local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir() EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') require( 'EgtDoorsBase') require( 'EgtDoorsData') local EgtDoorsMsg = require( 'EgtDoorsMsg') local MB = require( 'MachiningBase') -- Impostazioni Cam per consentire forature con utensile più piccolo EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) EgtMdbSave() -- Criterio di disposizione porta contro riferimenti, se fisso o guidato dalla disposizione porta -- 0: in base alla disposizione porta, 1: forzato solo a sinistra; -1: forzato solo a destra local FORCEDISPMODE = -1 -- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) local NO_WORK_UNDERSQUARE = false -- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) local NO_WORK_UPSQUARE = false -- Definizione possibilità di lavorare testa chisel rimanendo solo orizzontale o seguendo il bevel ( per teste non shuttle) local CHISEL_ONLY_HORIZONTAL = false -- variabili generazione lavorazioni local GEN_MACH = false local NOT_GEN_MACH = true -- Variabile distanza minima tra pezzo finito e ventosa (in X) local DIST_MIN_VAC_L = 5.5 local DIST_MIN_VAC_R = 7.5 local KIND_DISP_MODE = 1 -- 1: fixture, prende i sottopezzi dalla cartella fixture; 0: machine, alza i sottopezzi dal disegno della macchina -- variabile per applicare sempre la lavorazione degli anti-scheggia fatti con gli shuttle ( >= 4 inserisce solo quelle necessarie, < 4 inserisce tutte) -- in caso il groove sia fatto con lama local MAXMACH = 4 -- variabile che indica se sono state inserite lavorazioni da sotto local bMachUnder -- variabile dimensione porta considerata lunga che segna il diverso parcheggio dello shuttle 1 come è settata nella macro P5INIT local Big_Dorr_Height local tVacType = { 'VAC_158_43_H55', 'VAC_78_43_H55'} -- la sequenza è specchiata: il primo indice è riferito alla prima ventosa a destra, l'ultimo indice all'ultima ventosa a sinistra local tMapVac = { 1, 2, 2, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1} local bSandFound = false ----------------------------------------------------------------- -- *** Error write file *** ----------------------------------------------------------------- local function WriteErrFile( sFileErr, sDispMsg) local nIdFile = io.open( sFileErr, 'w') if nIdFile then if DGD.ERR == 0 then if DGD.ERM and #DGD.ERM > 0 then nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) else nIdFile:write( 'Err=' .. tostring( DGD.ERR)) end else if DGD.EMC and #DGD.EMC > 0 then nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.EMC) else nIdFile:write( 'Err=' .. tostring( DGD.ERR)) end end if sDispMsg and #sDispMsg > 0 then nIdFile:write('\n' .. sDispMsg) end nIdFile:close() end end ----------------------------------------------------------------- -- *** Add machining combine in table for second part *** ----------------------------------------------------------------- local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) if tSecMcng then if #tSecMcng > 0 then local bFound = false MTMachLine.Row = nIndexTab for k = 1, #tSecMcng do if MTMachLine == tSecMcng[k] then bFound = true end end -- se non trovato lo inserisco if not bFound then table.insert( tSecMcng,MTMachLine) end else MTMachLine.Row = nIndexTab table.insert( tSecMcng,MTMachLine) end end return tSecMcng end local function SetInfoTable( tListEnt, sNameInfo, nValInfo) for j = 1, #tListEnt do if tListEnt[j] then EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) end end end ----------------------------------------------------------------- -- *** Apply Machining by Mach number *** ----------------------------------------------------------------- local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed ) local dOverL = EgtGetInfo( tEndId[1], 'OL') local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd') local sProbeSide = EgtGetInfo( tEndId[1], 'ProbeSide') -- ProbeMachXY local nSetMaxElev = EgtGetInfo( tEndId[1], 'SetMaxElev', 'i') local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) local sSetMaxElev local sProbeSideCode -- determino in base alla direzione dell'entità quale codice sProbeSide dare alla lavorazione if sProbeSide and not bNotGenMachining then sProbeSideCode = 'CPBP' -- CORR_POS_BY_PROBE end -- if nSetMaxElev and not bNotGenMachining then sSetMaxElev = 'MaxElev=0.0' end if nMach == 1 then local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, tMainTabPar.DPSL, tMainTabPar.NWD) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) end -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale bSandFound = true end end -- se non genero la lavorazione if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMach) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- cerco se nelle note ho quella per l'aggregato da sotto if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto SetInfoTable( tEndId, 'UnderneathMach', true) bMachUnder = true end end end end elseif nMach == 2 then local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, tMainTabPar.DPSL, tMainTabPar.NWD) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) end -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale bSandFound = true end end -- se non genero la lavorazione if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMachUp) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- cerco se nelle note ho quella per l'aggregato da sotto if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto SetInfoTable( tEndId, 'UnderneathMach', true) bMachUnder = true end end end end elseif nMach == 3 then local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, sProbeSideCode, nil, sSetMaxElev, dOverR, bSandFound, tMainTabPar.DSL, tMainTabPar.DPSL, tMainTabPar.NWD) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) end -- leggo in ogni caso le note per indivuduare una lavorazione di tipo SAND if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local sSandFind, _ = sNotesMach:find( 'SAND', 1, true) if sSandFind then -- se trovata lavorazione di carteggiatura abilito il flag globale bSandFound = true end end -- se non genero la lavorazione if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMachDw) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- cerco se nelle note ho quella per l'aggregato da sotto if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true) if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto SetInfoTable( tEndId, 'UnderneathMach', true) bMachUnder = true end end end end end return bOk, nNumMach, tMachining end ----------------------------------------------------------------- -- *** Calc Machining for same group *** ----------------------------------------------------------------- local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed ) local nParendId = EgtGetParent(nEndId) local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo local sLocMachId local bNotGenMachining = true -- ordinare lavorazioni navette come scritto su foglio nella documentazione for i = 1, #tLocTable do if tLocTable[i].On ~= 0 then sLocMachId = tLocTable[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) -- Applico le lavorazioni for j = 1, #EntList do local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 if ( tLocTable[i].Oper == 'AdjustHead' or tLocTable[i].Oper == 'AdjustHeadOnASplint') and nMachCk > 0 and nMachCk < 10 then -- assegno la stessa nota nMach dell'entità del gruppo EgtSetInfo( EntList[j], 'Mach', nMach) -- duplico entià local nNewEntId = MB.MakeGhostCopy( EntList[j]) -- carico id entità in una tabella local tListSameMach = {} table.insert( tListSameMach, nNewEntId) bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end end end end return bOk, nNumMach end ----------------------------------------------------------------- -- *** Add Machining for same group *** ----------------------------------------------------------------- local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach, dBladePerpLeadIn, dPercRedFeed) local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo -- ordinare lavorazioni navette come scritto su foglio nella documentazione for i = 1, #tLocTable do -- Recupero le entità local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) -- Applico le lavorazioni for j = 1, #EntList do local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end if nMachCk > 0 and nMachCk < 10 then local nNewEntId = EntList[j] local sMachining = EgtGetInfo( nNewEntId, 'Machining') if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) -- se più di 1 entità le ordino if #tListSameMach > 1 then tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end return bOk, nNumMach end ----------------------------------------------------------------- -- *** Movimento ventose *** ----------------------------------------------------------------- local ThroughId, BlindId ----------------------------------------------------------------- local function StartVacVerify( nIdSolid, bFlipped, dThDoor) -- regioni passante e cieca non definite EgtErase( ThroughId or GDB_ID.NULL) ThroughId = nil EgtErase( BlindId or GDB_ID.NULL) BlindId = nil -- recupero le regioni sopra e sotto della porta messa in macchina local UpId, DwId local DwIdExtraBlind = {} local sExtraBlindRegName local DwIdExtraGrvBlind = {} local sExtraGrvBlindRegName local dZedToMove -- se porta ribaltata if bFlipped then -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) sExtraBlindRegName = 'FLAT_UP_BLIND' DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) sExtraGrvBlindRegName = 'FLAT_UP_SD_BLIND' DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) dZedToMove = dThDoor else -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) sExtraBlindRegName = 'FLAT_DW_BLIND' DwIdExtraBlind = MB.FindGeomWithName( nIdSolid, sExtraBlindRegName, false) sExtraGrvBlindRegName = 'FLAT_DW_SD_BLIND' DwIdExtraGrvBlind = MB.FindGeomWithName( nIdSolid, sExtraGrvBlindRegName, false) dZedToMove = 0 end -- creo le regioni complementari local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT) local CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end EgtSurfFrSubtract( CompUpId, UpId) if not EgtExistsObj( CompUpId) then CompUpId = nil end local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT) local CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) -- faccio una copia per gli altri controlli local DownRegId = nil if CompDwId then DownRegId = EgtCopyGlob( CompDwId, nIdSolid) EgtInvertSurf( DownRegId) end local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end EgtSurfFrSubtract( CompDwId, DwId) if not EgtExistsObj( CompDwId) then CompDwId = nil end if CompDwId then EgtInvertSurf( CompDwId) end -- calcolo le regioni passante e cieca local ThroughRegId = nil local BlindRegId = nil -- se ci sono entrambe le regioni if CompUpId and CompDwId then -- per ottenere la regione passante faccio intersezione tra sopra e sotto EgtSurfFrIntersect( CompUpId, CompDwId) if EgtExistsObj( CompUpId) then ThroughRegId = CompUpId end -- per ottenere la regione cieca faccio differenza tra sotto e passante if ThroughRegId then EgtSurfFrSubtract( CompDwId, ThroughRegId) if EgtExistsObj( CompDwId) then BlindRegId = CompDwId end else BlindRegId = CompDwId end -- se c'è solo la regione sotto è già quella delle lavorazioni cieche elseif CompDwId then BlindRegId = CompDwId -- se c'è solo la sopra, non interessa e la cancello elseif CompUpId then EgtErase( CompUpId) end -- sistemazioni finali if ThroughRegId or #DwIdExtraGrvBlind then ThroughId = EgtGroup( GDB_ID.ROOT) EgtSetName( ThroughId, 'THROUGH') EgtSetColor( ThroughId, RED()) EgtSetLevel( ThroughId, GDB_LV.TEMP) local nChunk = 0 if ThroughRegId then while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do nChunk = nChunk + 1 end end -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) for l = 1, #DwIdExtraGrvBlind do local nIdBl = DwIdExtraGrvBlind[l] if nIdBl then -- faccio la copia e la muovo alla Z bassa local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) if nTempBlndReg then -- prendo il punto iniziale local pCenTmp = EgtCP( nTempBlndReg) if pCenTmp then EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) end -- estraggo i contorni e li aggiungo al gruppo blind nChunk = 0 while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, ThroughId) do nChunk = nChunk + 1 end -- cancello la copia locale EgtErase( nTempBlndReg) end end end EgtErase( ThroughRegId) -- EgtSetName( ThroughRegId, 'THROUGH') -- EgtSetColor( ThroughRegId, RED()) -- EgtSetLevel( ThroughRegId, GDB_LV.TEMP) end if BlindRegId or #DwIdExtraBlind > 0 then BlindId = EgtGroup( GDB_ID.ROOT) EgtSetName( BlindId, 'BLIND') EgtSetColor( BlindId, BLUE()) EgtSetLevel( BlindId, GDB_LV.TEMP) local nChunk = 0 if BlindRegId then while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do nChunk = nChunk + 1 end end -- aggiungo le regioni extra presenti (calcolate dai singoli componenti) for l = 1, #DwIdExtraBlind do local nIdBl = DwIdExtraBlind[l] if nIdBl then -- faccio la copia e la muovo alla Z bassa local nTempBlndReg = EgtCopyGlob ( nIdBl, nIdSolid) if nTempBlndReg then -- prendo il punto iniziale local pCenTmp = EgtCP( nTempBlndReg) if pCenTmp then EgtMove( nTempBlndReg, Point3d(0,0,dZedToMove) - Point3d(0,0,pCenTmp:getZ())) end -- estraggo i contorni e li aggiungo al gruppo blind nChunk = 0 while EgtExtractSurfFrChunkLoops( nTempBlndReg, nChunk, BlindId) do nChunk = nChunk + 1 end -- cancello la copia locale EgtErase( nTempBlndReg) end end end if BlindRegId then EgtErase( BlindRegId) -- EgtSetName( BlindRegId, 'BLIND') -- EgtSetColor( BlindRegId, BLUE()) -- EgtSetLevel( BlindRegId, GDB_LV.TEMP) end end if DownRegId then FaceDwId = EgtGroup( GDB_ID.ROOT) EgtSetName( FaceDwId, 'DWREG') EgtSetColor( FaceDwId, BLUE()) EgtSetLevel( FaceDwId, GDB_LV.TEMP) local nChunk = 0 while EgtExtractSurfFrChunkLoops( DownRegId, nChunk, FaceDwId) do nChunk = nChunk + 1 end EgtErase( DownRegId) -- EgtSetName( DownRegId, 'DWREG') -- EgtSetColor( DownRegId, GREEN()) -- EgtSetLevel( DownRegId, GDB_LV.TEMP) end end ----------------------------------------------------------------- local function ExecVacVerify( ptVac, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, sAngGrooveNote, nIdSolid, bFlipped, ptVacId) -- verifica con le regioni passanti local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) while nId do local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- se distanza inferiore al limite ... if dDist < dDistInterferThru then return false end end nId = EgtGetNext( nId) end -- verifica con le regioni cieche nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) while nId do local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- se distanza inferiore al limite ... if dDist < dDistInterferBlind then return false end end nId = EgtGetNext( nId) end -- se ho delle lavorazioni da sotto if bMachUnder then local tUnderList = {} tUnderList = MB.FindGeomWithNote( Pz, 'UnderneathMach', 'b', true, tUnderList) for i = 1, #tUnderList do local ptNear = EgtNP( tUnderList[i], ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- se distanza inferiore al limite ... if dDist < dDistInterferUnder then return false end end end end -- se ho groove su top angolo if sAngGrooveNote and #sAngGrooveNote > 0 then local tGrooveOnAng = EgtSplitString( sAngGrooveNote) if tGrooveOnAng and #tGrooveOnAng > 0 then for i = 1, #tGrooveOnAng do -- prendo la prima geometria del layer local nGrvId = EgtGetFirstInGroup( tGrooveOnAng[i]) if nGrvId then local ptNear = EgtNP( nGrvId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- controllo che la ventosa sia al di fuori della regione local DwId local bDistBtwRegion -- se porta ribaltata if bFlipped then -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) else DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) end if DwId then bDistBtwRegion = EgtSurfFrTestExternal( DwId, ptVacId, 0.1) end -- se punto ventosa esterno alla regione e distanza inferiore al limite ... if bDistBtwRegion and dDist > min( dDistInterferThru, dDistInterferBlind, dDistInterferUnder) then return false end end end end end end -- nessuna interferenza return true end ----------------------------------------------------------------- local function ExecVacShapeVerify( ptVac, sNameVac, tabOri, dDistThru, dDistBlind, dDistCont, bCodeMobileVac, dRotVal, dMove2, sAngGrooveNote, nIdSolid, bFlipped, ptVacId) local nShapeId local nShapeBlindId local nAreaId local dMoveLoc = EgtIf( bCodeMobileVac, dMove2, 0) local dRotLoc = EgtIf( bCodeMobileVac, dRotVal, 0) local dMaxMov = 0 local nRetErr = 0 local nCustomType -- inserisco la ventosa e ne ottengo l'id local nFixVac = EgtAddFixture( sNameVac, ( ptVac - tabOri), dRotLoc, dMoveLoc) if nFixVac then -- cerco l'id della geometria shape if bCodeMobileVac then nAreaId = EgtGetFirstNameInGroup( nFixVac, 'MOBILE') else nAreaId = EgtGetFirstNameInGroup( nFixVac, 'AREA') end -- leggo la nota del typo custom nCustomType = EgtGetInfo( nFixVac, 'CustomType', 'i') if nAreaId then if bCodeMobileVac then -- se mobile leggo la nota di movimento massimo dMaxMov = EgtGetInfo( nAreaId, 'MAXMOV', 'd') or 0 end -- cerco il nome della regione nShapeId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE') -- cerco il nome della regione dedicata alle geometrie cieche nShapeBlindId = EgtGetFirstNameInGroup( nAreaId, 'SHAPE_BL') -- se non ho la doppia regione prendo l'unica if nShapeId and not nShapeBlindId then nShapeBlindId = nShapeId end else if nFixVac then -- se inserita ventosa la rimuovo EgtRemoveFixture( nFixVac) end nRetErr = 1 return false, nRetErr end end -- se ho la regione provo a verificare if nShapeId then -- se ventosa mobile controllo se la distanza di movimento è superiore a quella ammessa if bCodeMobileVac and dMoveLoc > dMaxMov then EgtRemoveFixture( nFixVac) return false, nRetErr end -- verifica se regione ventosa interferisce con le regioni passanti local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) -- EgtSaveFile() while nId do local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistThru) if bDistBtwRegion then -- se interferisce cancello ventosa ed esco EgtRemoveFixture( nFixVac) return false, nRetErr end nId = EgtGetNext( nId) end -- verifica se regione ventosa interferisce con le regioni cieche nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) while nId do local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeBlindId, nId, dDistBlind) if bDistBtwRegion then -- se interferisce cancello ventosa ed esco EgtRemoveFixture( nFixVac) return false, nRetErr, true end nId = EgtGetNext( nId) end -- verifica se regione ventosa interferisce con le regioni contorno nId = EgtGetFirstInGroup( FaceDwId or GDB_ID.NULL) while nId do local bDistBtwRegion = not EgtSurfFrTestExternal( nShapeId, nId, dDistCont) if bDistBtwRegion then -- se interferisce cancello ventosa ed esco EgtRemoveFixture( nFixVac) return false, nRetErr end nId = EgtGetNext( nId) end else -- regione non trovata if nFixVac then -- se inserita ventosa la rimuovo EgtRemoveFixture( nFixVac) end nRetErr = 2 return false, nRetErr end -- se ho groove su top angolo if sAngGrooveNote and #sAngGrooveNote > 0 then local tGrooveOnAng = EgtSplitString( sAngGrooveNote) if tGrooveOnAng and #tGrooveOnAng > 0 then for i = 1, #tGrooveOnAng do -- prendo la prima geometria del layer local nGrvId = EgtGetFirstInGroup( tGrooveOnAng[i]) if nGrvId then local ptNear = EgtNP( nGrvId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- controllo che la ventosa sia al di fuori della regione local DwId local bDistBtwRegion -- se porta ribaltata if bFlipped then -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) else DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) end if DwId then bDistBtwRegion = EgtSurfFrTestExternal( DwId, ptVacId, 0.1) end -- se punto ventosa esterno alla regione e distanza inferiore al limite ... if bDistBtwRegion and dDist > min( dDistInterferThru, dDistInterferBlind, dDistInterferUnder) then if nFixVac then -- se inserita ventosa la rimuovo EgtRemoveFixture( nFixVac) end nRetErr = 3 return false, nRetErr end end end end end end -- nessuna interferenza if nFixVac then -- se inserita ventosa la rimuovo EgtRemoveFixture( nFixVac) end return true, nRetErr, nil, nCustomType end ----------------------------------------------------------------- local function EndVacVerify() -- cancello regioni passante e cieca EgtErase( ThroughId or GDB_ID.NULL) ThroughId = nil EgtErase( BlindId or GDB_ID.NULL) BlindId = nil EgtErase( FaceDwId or GDB_ID.NULL) FaceDwId = nil end ----------------------------------------------------------------- local function MoveVac( nId, dVal) local dOldVal = EgtGetInfo( nId, 'Val', 'd') EgtMove( nId, Vector3d( 0, 0, dVal - dOldVal), GDB_RT.GLOB) EgtSetInfo( nId, 'Val', dVal) end ----------------------------------------------------------------- local function AddMoveShowHideVac( nMode, nGroupId, sNameVac, sNameCol, dVal, sVacName, pPointApp) local nVac local nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameVac) if nMode == 1 then -- se disposizione fixture EgtSetAlpha( nId, 20) -- imposto trasparenza poco visibile -- inserisco la ventosa nVac = EgtAddFixture( sVacName, pPointApp, 0) elseif nMode == 0 then -- disposizione machine EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità MoveVac( nId, dVal) -- muovo anche la base nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sNameCol) MoveVac( nId1, dVal) else EgtSetAlpha( nId, 100) -- imposto trasparenza massima visibilità end return nVac end ----------------------------------------------------------------- local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) -- Box solido: lo ottengo dalla somma delle varie superfici della porta local tListFaces = {} if nProbeMode == 2 then table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) else table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) end table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE')) -- aggiungo anche il layer AUX escludendo il testo if nAuxLayer then local nIdGeom = EgtGetFirstInGroup(nAuxLayer) local nTypeEnt while nIdGeom do -- se elemento passato è un testo lo escludo nTypeEnt = EgtGetType( nIdGeom) if nTypeEnt ~= GDB_TY.EXT_TEXT then table.insert( tListFaces, nIdGeom) end nIdGeom = EgtGetNext(nIdGeom) end end local b3fx = BBox3d() -- inizializzo il box nullo for i = 1, #tListFaces do if tListFaces[i] then local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT) b3fx:Add(b3f1) end end return b3fx end ----------------------------------------------------------------- local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth, dMaxDoorWidth, dMinDoorThick, dMaxDoorThick) local bFailDim = false local sErrMess = '' local dLimitToCheck dLimitToCheck = dMinDoorLength - abs(ShiftXOri) if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end dLimitToCheck = dMaxDoorLength - abs(ShiftXOri) if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr), EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end -- dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri) dLimitToCheck = dMinDoorWidth + abs(ShiftYOri) if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end -- dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri) dLimitToCheck = dMaxDoorWidth + abs(ShiftYOri) if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)), EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end dLimitToCheck = dMinDoorThick if dThickDoor < dLimitToCheck then -- se spessore inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end dLimitToCheck = dMaxDoorThick if dThickDoor > dLimitToCheck then -- se spessore superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = '\n'.. sErrMess end end return bFailDim end ----------------------------------------------------------------- -- *** Funzione di generazione lavorazioni *** ----------------------------------------------------------------- function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) -- local nTime -- -- inizializzo il contatore -- EgtStartCounter() -- macchina e tabella di default -- tabella parametri d'uso per variabili CurrcamInfo tMainTabPar = {} --macchina e tabella di default tMainTabPar.MN = 'Multiax-' -- Machinings Tables local MachiningsTable = 'MachStdTable' local MachiningsTableOrd = 'MachStdTable_Ord' -- Define door disposition ( on left: 1, on right : -1) local nDispMode = -1 -- References on table (respect Zero machine) -- Y Table tMainTabPar.OR1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH tMainTabPar.OR2 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH -- shift value local vShift = Vector3d(0,0,0) local vShiftVac = Vector3d(0,0,0) tMainTabPar.SH1 = Vector3d(0,0,0) local vNullShift = Vector3d(0,0,0) tMainTabPar.SHL = Vector3d(0,0,0) -- variabile per posizione media della porta per il cambio navette local dPosShuttleChange = 40 * GEO.ONE_INCH -- tabella raggi profili su ogni lato local tsRadiusProf = {} local tsPlaneProf = {} -- utilizzo la tabella dati cam local sPathCurrMachtabOri = 'CurrCamInfo' local mCamData = require( sPathCurrMachtabOri) -- variabili pezzo singolo local nPz local sAssemb -- variabile check dimensioni porta local bFailDim = false -- resetto la macchinata (riporto il pezzo in area disegno) EgtResetCurrMachGroup() -- elimino percorsi eventualmente creati dal Mach -- cancello tutti i percorsi ghost local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end -- se la variabile è una tabella, estrapolo solo la porta local PzIsTab = type(tPz) == 'table' if PzIsTab then for v = 1, #tPz do Pz = tPz[v] sAssemb = tsAssemb[v] -- se non ha nota o nota della prima porta esco if not sAssemb or ( sAssemb and sAssemb == 'first') then break end end else Pz = tPz sAssemb = tsAssemb end -------------------------------------------------------------------------------- -- Dati della porta local sDoorCode = EgtGetInfo( Pz, 'Code') local dWidthDoor = EgtGetInfo( Pz, 'W', 'd') local dLengthDoor = EgtGetInfo( Pz, 'H', 'd') local dThickDoor = EgtGetInfo( Pz, 'T', 'd') local sSwing = EgtGetInfo( Pz, 'Swing') MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente local sSecure = EgtGetInfo( Pz, 'Secure') local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') local sTopTrim = EgtGetInfo( Pz, 'top_trimming') local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' ) tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd') tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd') tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd') tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd') tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd') tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd') tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd') tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd') local nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 local nPostProbeSet = EgtGetInfo( Pz, 'PostProbeSet', 'i') or 0 local dNumHingesPivots = EgtGetInfo( Pz, 'NumHingesPivots', 'd') or 0 local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 -- Box pezzo local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') local Aux = EgtGetFirstNameInGroup( Pz, 'AUX') local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT) -- Box solido: lo ottengo dalla somma delle varie superfici della porta local b3Solid = BBox3d() -- inizializzo il box nullo b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) -- Project path, name, extension local sFilePath = EgtGetCurrFilePath() local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) ------------------------------------------------------ -- se codice porta contiene comandi speciali -- che non producono la generazione del part program della porta ma dei part program speciali if sDoorCode then local sCode = string.lower(sDoorCode) if sCode == 'p1' or sCode == 'p2' or sCode == 'p3' or sCode == 'p4' or sCode == 'p5' or sCode == 'p6' then EgtSetInfo( Pz, 'SpecialCmd', sCode) end end ------------------------------------------------------ -------------------------------------------------------------------------------- -- *** settaggi CAM *** -- Mtable 1 if not MachiningsTable then -- se non c'è il nome della MTable esco DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato return false end EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') local TAB if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then TAB = require( MachiningsTable) if not TAB then DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file return false end else DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato return false end local MachinesName = TAB.MMachineData if not MachinesName then DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable return false end -- *** settaggi CAM *** -- Mtable 2 MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') local TABORD if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then TABORD = require( MachiningsTableOrd) if not TABORD then DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file return false end else DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file return false end -- imposto i dati macchina secondo le informazioni del file cam tMainTabPar.MN = mCamData[nNumMachFromCam].MachName tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth tMainTabPar.MnDW = mCamData[nNumMachFromCam].MaxDoorThick tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick tMainTabPar.FUS = mCamData[nNumMachFromCam].ForceShuttleUse tMainTabPar.FDMH = mCamData[nNumMachFromCam].ForceDirMachHinge tMainTabPar.FDH = mCamData[nNumMachFromCam].ForceDisableHood tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef tMainTabPar.VOY = mCamData[nNumMachFromCam].dVacOffsY or 57.5 tMainTabPar.MOY = mCamData[nNumMachFromCam].dMobOffsY or 201.6 tMainTabPar.LDX = mCamData[nNumMachFromCam].dLeftDistX or 118.35 tMainTabPar.RDX = mCamData[nNumMachFromCam].dRightDistX or 170.125 tMainTabPar.MPMB = mCamData[nNumMachFromCam].MaxPosMobBar or 1155 tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining tMainTabPar.GCDN = mCamData[nNumMachFromCam].GenCncAsDdfName or 0 tMainTabPar.DACN = mCamData[nNumMachFromCam].DisableAutoCncName or 0 tMainTabPar.BPLI = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4) tMainTabPar.PRF = mCamData[nNumMachFromCam].PercRedFeed or 0.3 FORCEDISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or FORCEDISPMODE -- SideDoorDispose tMainTabPar.DTG = mCamData[nNumMachFromCam].SafetyDistVacThru or 12 tMainTabPar.DBG = mCamData[nNumMachFromCam].SafetyDistVacBlind or 45 tMainTabPar.DUG = mCamData[nNumMachFromCam].SafetyDistVacUnder or 55 tMainTabPar.DSG = mCamData[nNumMachFromCam].SafetyDistVacSide or 1 tMainTabPar.ECD = mCamData[nNumMachFromCam].EnableCollisionDetect or 0 -- new tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels or 0 -- new tMainTabPar.PTK = mCamData[nNumMachFromCam].dProbeThickness or 0 -- new tMainTabPar.NVP = mCamData[nNumMachFromCam].ProfBy5AaxisHead == 1 -- new tMainTabPar.SVP = mCamData[nNumMachFromCam].SandingBy5AxisHead == 1 -- new tMainTabPar.CDA = mCamData[nNumMachFromCam].sCutDirectionAdmitted or '' -- new tMainTabPar.BDH = mCamData[nNumMachFromCam].BigDoorHeight or 1800.0 -- new tMainTabPar.NWD = mCamData[nNumMachFromCam].NarrowWidth or 253.9 -- new tMainTabPar.RSM = mCamData[nNumMachFromCam].RemoveScrapMode or 0 -- new tMainTabPar.MSV = mCamData[nNumMachFromCam].MinScrapValue or 0 -- new tMainTabPar.DSL = mCamData[nNumMachFromCam].dDistSandLength or 1700 -- new tMainTabPar.DPSL = mCamData[nNumMachFromCam].dDistPreSandLength or 1550 -- new tMainTabPar.FDD = mCamData[nNumMachFromCam].ForceDisposByDust or 0 -- new -- se non devo generare il cn esco subito if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable return true end -- setto come generare il nome del file cnc (di default è uguale al nome del parametro interno ad ddf) if tMainTabPar.GCDN == 0 then -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi sFileName = sDoorCode end -- per prima cosa provo ad eliminare il file .tok per il prod EgtEraseFile( sFileDir..sFileName..'.tok') local MTable = TAB.MTable local MTableOrd = TABORD.MTable -- variabile principale per definizione disposizione porta a destra o sinistra local sLocMachId local bOk = true local bFirstStep = true local bShiftedDoor = false local sDispMode local sTotDispMode = '' local sNumGroup = '' local bWork = true -- variabili utilizzate dentro al ciclo local nMchId local sTab local tabOri local Ori local ColA local nRaw local bMoveRaw local bPush local bFlip local bTopOnRight -- variabili per disposizione sottopezzi local dMobOffs local dVacOffs local dDistMinX local dDistMaxX local dVacOn local dInterAx local OffsXSovr = 0 local OffsYSovr = 0 local dDistInterferThru local dDistInterferBlind local dDistInterferUnder local dDistInterferSide -- variabile per tool setup local MSetup local sSetup -- variabili calcolo box local b3SolidOnTab local pMin local pMax -- variabili conteggio lavorazioni profilatura bevel e saltate local nNumMachSkip = 0 local bLocMach local sMachProf local bWorkUnder = true -- variabile per conteggio lavorazioni local nNumMach local nNumSkip local tSecMachTab = {} -- variabili per fase local nNumPhase local nNumCycle = 1 -- variabili per gestione ripresa porta local bFlipFirst local bTopOnRightFirst local sProfiles = '' local nNumGeomBottom = 0 local nNumGeomTop = 0 local nNumGeomBottomHole = 0 local nNumGeomTopHole = 0 -- variabili per geometrie lato Hinge local nNumTopGeom = 0 local nNumBottomGeom = 0 -- variabile piazzamento porta local sLight -- variabile direzione riordino gruppi local nDirReorderGroups -- tabella lavorazioni local tLocMach = {} local tLocMachOrd = {} local tSplitDoorEnt = {} local tSplitDataInf = {} local bGetSplitCuts = false local nNumProbeZ -- Set Current Machine: si setta sulla fase 1 EgtSetCurrMachine( tMainTabPar.MN) ------------------------------------------------------------------------------------------------------- -- per questa macchina è importante differenziare il nome del profilo lato lock rispetto al lato hinge -- in modo che venga lavorato prima il lato hinge e poi il lock ------------------------------------------------------------------------------------------------------- -- Recupero le entità local nLockProf -- se serratura è a destra cerco il nome dl profilo corrispondente a quel lato if bAtRight then nLockProf = EgtGetFirstNameInGroup( Pz, 'Right') else nLockProf = EgtGetFirstNameInGroup( Pz, 'Left') end local EntListHg = MB.FindEntities( nLockProf) sLockTrim = sLockTrim..'_LK' -- rinomino tutte le entità del gruppo for j = 1, #EntListHg do local sNameEnt = EgtGetName( EntListHg[j]) if not string.find( sNameEnt, '_LK') then sNameEnt = sNameEnt .. '_LK' end EgtSetName( EntListHg[j], sNameEnt) end -- faccio tutte le fasi ( probabilmente solo una perché non sono previsti ribaltamenti) while bWork do -- nTime = EgtStopCounter() -- if not DGD or not DGD.NCGEN then -- EgtOutBox( string.format( '1 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') -- end -- -- inizializzo il contatore -- EgtStartCounter() sDispMode = '' bMachUnder = nil nNumGroup = nNumGroup + 1 -- Set Machining Group if not sAssemb then -- se pezzo unico nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) else nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) end -- nTime = EgtStopCounter() -- if not DGD or not DGD.NCGEN then -- EgtOutBox( string.format( '2 tempo calcolato sec: %s', (nTime/1000)), 'Time1', 'Time1') -- end -- -- inizializzo il contatore -- EgtStartCounter() if nMchId then if tMainTabPar.DACN == 1 then local sLocNumGroup = '' if nNumGroup > 1 then sLocNumGroup = '_'..EgtNumToString(nNumGroup,0) end EgtSetInfo( nMchId, 'NcName', sFileName .. sLocNumGroup .. '.cnc') end -- assegno al gruppo di lavoro l'info relativo allo stato del controllo collisione EgtSetInfo( nMchId, 'EnableCollisionDetect', tMainTabPar.ECD) -- assegno al gruppo di lavoro la lunghezza minima porta EgtSetInfo( nMchId, 'LongDoorLimit', tMainTabPar.BDH) -- Simulation for collision check if tMainTabPar.ECD == 1 then EgtSetInfo( nMchId, 'Vm', '1') end end nNumPhase = EgtGetCurrPhase() ----------------------------------------------------------------------- -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo ----------------------------------------------------------------------- -- se check macchina settato per non gestire grezzo if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then dLeftOffs = 0 dRightOffs = 0 dTopOffs = 0 dBottomOffs = 0 end ColA = Color3d( 255, 165, 0, 15) nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs, dBottomOffs, 0), nRaw) -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, -- decido su quale lato disporre la porta per evitare inutili ribaltamenti -- ricavo minimo e massimo del solido del pezzo b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) pMin = b3SolidOnTab:getMin() pMax = b3SolidOnTab:getMax() tLocMach = MTable tLocMachOrd = MTableOrd sMachProf = '' -- in base ai valori di sovramateriale sui lati, se tutti sono al di sotto di 3 volte il valore di attivazione della sgrossatura -- allora disabilito lo scrapmode if dLeftOffs < tMainTabPar.MSV and dRightOffs < tMainTabPar.MSV and dTopOffs < tMainTabPar.MSV and dBottomOffs < tMainTabPar.MSV then tMainTabPar.RSM = 0 end -- prendo nota dei profili tipo bevel e bull nose -- verifico se cave da sotto o da sopra -- verifico se trovate lavorazioni applicate con 'shift' local nUnderGeom for i = 1, #tLocMach do if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId -- se non c'è il campo macchina setto di default la 1 if not sLocMachId then sLocMachId = 1 end -- se macchina corrispondente if sLocMachId == nNumMachFromTable then local sUpperProfName = string.upper(tLocMach[i].Name) -- prendo i profili bevel direttamente dalla tabella if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then if not string.find( sProfiles, sUpperProfName) then sProfiles = sProfiles .. sUpperProfName .. ',' end end -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) -- Test delle lavorazioni for j = 1, #EntList do -- OPERAZIONI if tLocMach[i].Oper == 'AdjustThrouIsle' then bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) if bLocMach then if nUnderGeom and nUnderGeom == 1 then nNumGeomBottom = nNumGeomBottom + 1 elseif nUnderGeom and nUnderGeom == -1 then nNumGeomTop = nNumGeomTop + 1 end end elseif tLocMach[i].Oper == 'AdjustVertHole' then bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) if bLocMach then if nUnderGeom and nUnderGeom == 1 then nNumGeomBottom = nNumGeomBottom + 1 nNumGeomBottomHole = nNumGeomBottomHole + 1 elseif nUnderGeom and nUnderGeom == -1 then nNumGeomTop = nNumGeomTop + 1 nNumGeomTopHole = nNumGeomTopHole + 1 end end end end end end end ----------------------- -- *** Disposizione *** ----------------------- -- controllo se ho profili bullnose sul lato hinge (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) if ( sHingeTrim == '1B' or sHingeTrim == '2B') then -- se profilo cerniere è bullnose bShiftedDoor = true end -- controllo se ho profili bullnose sul lato serratura (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE) if ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK') then -- se profilo serratura indicato è bullnose vShiftVac = tMainTabPar.SHL else vShiftVac = vNullShift end -- Scelta della tavola sTab = 'Tab' EgtSetTable( sTab) -- Origine tavola corrente rispetto a Zero macchina tabOri = EgtGetTableRef( 1) -- Rotazione porta in base alla macchina bMoveRaw = false -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf -- se non c'è il parametro considero la porta come se avesse bevel down -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or sSwing == 'LH' or sSwing == 'LHA' or sSwing == 'LHI' then bPush = true else bPush = false end local sNumPhase if nNumPhase and nNumPhase < 10 then sNumPhase = '0'.. tostring( nNumPhase) elseif nNumPhase then sNumPhase = tostring( nNumPhase) else sNumPhase = '0' end local bOkDisp = false nNumProbeZ = 0 -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, -- se non ha bevel nemmeno il lato serratura considero il parametro secure -- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel e da lavorare if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel -- verifico se i profili risultanti sono presenti in tabella if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or ( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end -- se profilo serratura indicato bevel (e da lavorare) -- if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK') and bLockMach and not bOkDisp then if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB_LK') and not bOkDisp then -- verifico se i profili risultanti sono presenti in tabella if sLockTrim == 'BD_LK' and bPush and string.find( sProfiles, 'BU_LK,') then bOkDisp = true elseif sLockTrim == 'BDEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then bOkDisp = true elseif sLockTrim == 'BD_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then bOkDisp = true elseif sLockTrim == 'BDEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then bOkDisp = true elseif sLockTrim == 'BU_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then bOkDisp = true elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then bOkDisp = true elseif sLockTrim == 'BU_LK' and bPush and string.find( sProfiles, 'BU_LK,') then bOkDisp = true elseif sLockTrim == 'BUEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- a meno che ho il profilo opposto, in questo caso non ribalto la porta, altrimenti devo ribaltare la porta -- e la parte top va posizionata in modo che il lato cerniere sia davanti if ( ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') and bPush) or ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and not bPush and not bOppoBevelProf) or ( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and bPush and bOppoBevelProf) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end -- se profilo top indicato bevel (e da lavorare) if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then -- verifico se i profili risultanti sono presenti in tabella if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or ( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end -- se profilo top indicato bevel (e da lavorare) if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then -- verifico se i profili risultanti sono presenti in tabella if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or ( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end -- in caso non ci sia nessun profilo bevel verifico il parametro Secure if not bOkDisp then -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo altrimenti do errore if sSecure and string.upper(sSecure) == '0' then -- se parametro da CurrcamInfo non è valido do errore if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[590] break else sSecure = tMainTabPar.LS end end -- se lato secure va sopra il ribaltamento è obbligato if sSecure and string.upper(sSecure) == 'UP' then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end elseif sSecure and string.upper(sSecure) == 'DN' then bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) quella di considerare la porta bevel down -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) else if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down if bPush then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- se porta a tirare non la ribalto perché si presta già ad essere bevel down else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end else -- in base alle geometrie trovate ribalto o meno la porta if nNumGeomBottom > nNumGeomTop then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end elseif nNumGeomTop >= nNumGeomBottom then bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end else -- altrimenti vecchio metodo bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end end end end end -- faccio le rotazioni della porta if bFlip then EgtRotateRawPart( nRaw, Y_AX(), 180) sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479] else sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480] end if bTopOnRight then EgtRotateRawPart( nRaw, Z_AX(), -90) sDispMode = sDispMode .. EgtDoorsMsg[481] else EgtRotateRawPart( nRaw, Z_AX(), 90) sDispMode = sDispMode .. EgtDoorsMsg[482] end if bShiftedDoor then sDispMode = sDispMode .. EgtDoorsMsg[510] end sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' ----------------------------------------------------------------------------------------------- -- Scelta della disposizione e di conseguenza dell'origine (ora espressa rispetto Zero Tavola) ----------------------------------------------------------------------------------------------- if FORCEDISPMODE == 0 then -- disposizione segue il top della porta if bTopOnRight then nDispMode = -1 else -- 19.09.2023 richiesta di MarkHoffman per problemi di pesenza della polvere: se la porta ha lato top e/o bottom lavorate, la disposizione della porta -- deve essere fatta a destra if tMainTabPar.FDD > 0 and ( bTopMach or bBottomMach) then nDispMode = -1 else nDispMode = 1 end end else nDispMode = FORCEDISPMODE end Ori = EgtIf( nDispMode > 0, tMainTabPar.OR1, tMainTabPar.OR2) -- se porta da traslare setto lo shift da applicare if bShiftedDoor then vShift = tMainTabPar.SH1 else vShift = vNullShift end Ori = Ori + vShift -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto if nProbeMode == 1 then if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') end -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end -- rinomino i rimenenti if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') end -- mi tengo via il numero di probe in Z nNumProbeZ = #DelList -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtSetName( DelList[j], 'ProbePoint') end -- se non c'è probe mode (prod) e abilitata la tastatura di fianco filtro le geometrie che si trovano sopra e sotto elseif nProbeMode == 0 and nPostProbeSet >= 3 then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') end -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end -- rinomino i rimenenti if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_secure') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint_keyway') end -- mi tengo via il numero di probe sul fianco nNumProbeZ = #DelList -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtSetName( DelList[j], 'ProbeSidePoint') end else -- se non c'è il probe point elimino tutti i percorsi di probe (in Z) DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ProbeSidePoint') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end end ------------------------------------------------------------------ -- calcolo delta Y in base al profilo e al ribaltamento del pezzo ------------------------------------------------------------------ local vExtraYDelta local dExtraY = 0 local dExtraYOppo = 0 local dDeltaProbe = 0 local dDeltaProf = 0 local dDeltaProfOppo = 0 -- variabili per note relative al lato hinges local nHingeMach = 0 -- setto default non lavorato local nLockMach = 0 -- setto default non lavorato local nSideType = -1 -- 0 per profili SQ or FDWC local nSideOppoType = -1 -- 0 per profili SQ -- verifico profilo in battuta (hinge) if sHingeTrim == 'SQ' or sHingeTrim == 'EB' or sHingeTrim == 'FDWC' then nSideType = 0 -- se disposizione bevel down uso il riferimento in alto elseif sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then nSideType = 1 if dThickDoor > tMainTabPar.AR then dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 end -- calcolo errore del probe tastando a metà spessore -- dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY -- se abilitato il side probe if nProbeMode == 0 and nPostProbeSet >= 3 then -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe dDeltaProf = tMainTabPar.EZPB * TAN3 else -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) end dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se disposizione bevel up uso il riferimento in basso elseif sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then nSideType = 2 dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 -- calcolo errore del probe tastando a metà spessore -- dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY -- se abilitato il side probe if nProbeMode == 0 and nPostProbeSet >= 3 then -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe dDeltaProf = (( dThickDoor - tMainTabPar.EZPB) * TAN3) else -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) end dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo bull nose verifico in base al raggio elseif sHingeTrim == '1B' or sHingeTrim == '2B' or sHingeTrim == '3B' or sHingeTrim == '4B' then nSideType = 3 -- calcolo punto massimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = 0 -- se punto max è sotto il minimo riferimento if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf -- se punto max è sopra il massimo riferimento elseif dAltProf > tMainTabPar.AR then dAltcalc = dAltProf - tMainTabPar.AR end -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y if dAltcalc > 0 then dExtraY = tsRadiusProf[1] - sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) end -- calcolo errore del probe tastando a metà spessore dDeltaProbe = -dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo convex verifico in base al raggio elseif sHingeTrim == 'CV' then nSideType = 4 -- calcolo punto minimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = (tMainTabPar.TR/2) -- calcolo il delta Y massimo del minimo ingombro profilo local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-((dAltProf-tsPlaneProf[1])*(dAltProf-tsPlaneProf[1]))) -- se riferimento è sul max ingombro porta if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then dAltcalc = 0 -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = tMainTabPar.AR - dAltProf -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR end -- calcolo il delta Y if dAltcalc > 0 then dExtraY = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltcalc*dAltcalc)) - dMaxInsPrf end -- calcolo errore del probe tastando a metà spessore dDeltaProbe = tsRadiusProf[1] - (dExtraY + dMaxInsPrf) -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY end -- verifico profilo opposto alla battuta (lock) if sLockTrim == 'SQ_LK' or sLockTrim == 'EB_LK' then nSideOppoType = 0 -- se disposizione bevel down uso il riferimento in alto elseif sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK' then nSideOppoType = 1 -- se abilitato il side probe if nProbeMode == 0 and nPostProbeSet >= 3 then -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe dDeltaProfOppo = tMainTabPar.EZPB * TAN3 else -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) end -- se disposizione bevel up uso il riferimento in basso elseif sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then nSideOppoType = 2 -- se abilitato il side probe if nProbeMode == 0 and nPostProbeSet >= 3 then -- calcolo errore del probe tastando dallo spessore - il parametro z extra probe dDeltaProfOppo = (( dThickDoor - tMainTabPar.EZPB) * TAN3) else -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) end -- se profilo bull nose verifico in base al raggio elseif sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK' then nSideOppoType = 3 -- se profilo convex verifico in base al raggio elseif sLockTrim == 'CV_LK' then nSideOppoType = 4 local dAltProfOppo local dAltProfOppoTh local dExtraYOppoTh -- se abilitato il side probe if nProbeMode == 0 and nPostProbeSet >= 3 then -- calcolo punto minimo ingombro profilo dAltProfOppoTh = dThickDoor/2 - tsPlaneProf[2] -- calcolo errore del probe tastando a spessore completo - extra z dAltProfOppo = (dThickDoor/2) - tMainTabPar.EZPB - tsPlaneProf[2] -- calcolo il delta Y massimo del minimo ingombro profilo dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) dExtraYOppoTh = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppoTh*dAltProfOppoTh)) -- calcolo errore del probe tastando dallo spessore - quota extra z dDeltaProfOppo = dExtraYOppo - dExtraYOppoTh else -- calcolo punto minimo ingombro profilo dAltProfOppo = dThickDoor/2 - tsPlaneProf[2] -- calcolo il delta Y massimo del minimo ingombro profilo dExtraYOppo = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProfOppo*dAltProfOppo)) -- calcolo errore del probe tastando a metà spessore dDeltaProfOppo = tsRadiusProf[2] - dExtraYOppo end end -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota if bHingeMach then dExtraY = 0 nHingeMach = 1 dDeltaProbe = 0 dDeltaProf = 0 end -- se profilo lock da lavorare setto la variabile per la nota if bLockMach then dExtraYOppo = 0 nLockMach = 1 dDeltaProfOppo = 0 end vExtraYDelta = Vector3d(0,-dExtraY,0) -- scrivo le note EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) EgtSetInfo( Pz, 'DoorProbeThick', tMainTabPar.PTK) EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) EgtSetInfo( Pz, 'SideDisposition', nDispMode) -- scrivo nota disabilitazione cuffia EgtSetInfo( Pz, 'ForceDisableHood', tMainTabPar.FDH) -- scrivo nota lavorazione lato hinge EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) -- scrivo nota tipo profilo lato hinge EgtSetInfo( Pz, 'SideHingeProf', nSideType) -- scrivo profilo lato in battuta EgtSetInfo( Pz, 'SideProfOnRef', nSideType) -- scrivo profilo lato opposto EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) -- scrivo nota lavorazione lato lock EgtSetInfo( Pz, 'SideLockMach', nLockMach) -- scrivo la nota relativa al controllo collisioni EgtSetInfo( Pz, 'EnableCollisionDetect', tMainTabPar.ECD) -- scrivo nota con numero geometrie di ProbeZ o probeXY (in base ai settaggi di nProbeMode e nPostProbeSet) EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) -- assegno al gruppo di lavoro la lunghezza minima porta EgtSetInfo( Pz, 'LongDoorLimit', tMainTabPar.BDH) -- scrivo nota flag modalita remove scrap EgtSetInfo( Pz, 'RemoveScrapMode', tMainTabPar.RSM) -- assegno al gruppo di lavoro la larghezza di riferimento per considerarla stretta e lavorarla con una sola fresa EgtSetInfo( Pz, 'NarrowDoorLimit', tMainTabPar.NWD) -- sommo il delta spostamento Ori = Ori + vExtraYDelta -- Muovo porta con l'angolo indicato dal tipo di disposizione nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, EgtIf( nDispMode > 0, MCH_CR.BL, MCH_CR.BR)) -- memorizzo i flag per le fasi successive bFlipFirst = bFlip bTopOnRightFirst = bTopOnRight if not bMoveRaw then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[474] -- Error positioning raw part on table break end EgtSetInfo( Pz, 'MachineNameFromCurrCamInfo', tMainTabPar.MN) if bShiftedDoor then -- salvo una nota con le info della disposizione traslata EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'SHIFT') EgtSetInfo( Pz, 'OffSetPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) else -- salvo una nota con le info della disposizione normale EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, 'NORMAL') EgtSetInfo( Pz, 'OffSetPhase' .. '_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, vShiftVac) end if bFlip then -- se porta capovolta if bTopOnRight then -- se top a destra -- il lato sinistro è quello delle hinges OffsYSovr = dLeftOffs OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) else -- se top a sinistra -- il lato destro è quello delle hinges OffsYSovr = dRightOffs OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) end else -- altrimenti non è capovolta if bTopOnRight then -- se top a destra -- il lato destro è quello delle hinges OffsYSovr = dRightOffs OffsXSovr = EgtIf( nDispMode > 0, dBottomOffs, dTopOffs) else -- se top a sinistra -- il lato sinistro è quello delle hinges OffsYSovr = dLeftOffs OffsXSovr = EgtIf( nDispMode > 0, dTopOffs, dBottomOffs) end end -- Controllo dimensioni pezzo -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr, vShift:getX(), vShift:getY(), tMainTabPar.MnDL, tMainTabPar.MxDL, tMainTabPar.MnDW, tMainTabPar.MxDW, tMainTabPar.MnDT, tMainTabPar.MnDW) if bFailDim then DGD.ERR = 19 -- cancello il file tok EgtEraseFile( sFileDir..sFileName..'.tok') -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..'.txt') -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( DGD.EMC, 0) EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation end return false end ------------------------------------------------------------------------------------------------------------- -- abilito/disabilito geometrie probe in base alla lavorazione del lato hinge e alla disposizione sulla tavola ------------------------------------------------------------------------------------------------------------- if bHingeMach then -- se profilo hinge è da lavorare rinomino nome entita -- Recupero le entità probe local ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) end ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_POS') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) end ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_NEG') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Hinge_Probe' ) end -- Recupero le entità pivot ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) end ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_POS') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) end ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_NEG') -- ciclo su tutte le entità trovate for j = 1, #ProbeList do EgtSetName( ProbeList[j], 'NO_Pivot_Probe' ) end -- recupero entità probe di fianco ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 1 then EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) end end -- profilo hinge non lavorato else -- il probe deve essere sempre quello a sinistra rispetto al piazzamento -- considerando lo swing perché le cerniere a seconda di questo vengono ruotate e il probe _POS e _NED risultano -- scambiati rispetto al top della porta local sProbeHingeToFind = '' local sProbeHingeDis = '' local sProbePivotToFind = '' local sProbePivotDis = '' if nDispMode > 0 then -- se disposizione a sinistra if ( bPush and bAtRight) or ( not bPush and not bAtRight) then sProbeHingeToFind = 'Hinge_Probe_NEG' sProbeHingeDis = 'NO_Hinge_Probe_NEG' else sProbeHingeToFind = 'Hinge_Probe_POS' sProbeHingeDis = 'NO_Hinge_Probe_POS' end sProbePivotToFind = 'Pivot_Probe_NEG' sProbePivotDis = 'NO_Pivot_Probe_NEG' else -- disposizione a destra if ( bPush and bAtRight) or ( not bPush and not bAtRight) then sProbeHingeToFind = 'Hinge_Probe_POS' sProbeHingeDis = 'NO_Hinge_Probe_POS' else sProbeHingeToFind = 'Hinge_Probe_NEG' sProbeHingeDis = 'NO_Hinge_Probe_NEG' end sProbePivotToFind = 'Pivot_Probe_POS' sProbePivotDis = 'NO_Pivot_Probe_POS' end local ProbeList = MB.FindEntitiesWithName( Pz, sProbeHingeToFind) for j = 1, #ProbeList do EgtSetName( ProbeList[j], sProbeHingeDis) end ProbeList = MB.FindEntitiesWithName( Pz, sProbePivotToFind) for j = 1, #ProbeList do EgtSetName( ProbeList[j], sProbePivotDis) end -- se non da lavorare e profilo bevel dn cambio lo spessore a: spessore probe + extra probe z if sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then -- recupero entità probe di fianco ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 1 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') end end -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z elseif sHingeTrim == '1B' or sHingeTrim == '2B' or sHingeTrim == '3B' or sHingeTrim == '4B' or sHingeTrim == '5B' or sHingeTrim == '6B' or sHingeTrim == '7B' or sHingeTrim == '8B' then -- recupero entità probe di fianco ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 1 then EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) end end else -- recupero entità probe di fianco ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 1 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) -- se profilo bevel up assegno nota if sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') end end end end end if bLockMach then -- se profilo lock è da lavorare rinomino nome entita -- recupero entità probe di fianco su lato secure local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 3 then EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) end end -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z elseif not bLockMach and ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 3 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') end end -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta + extra probe z elseif not bLockMach and ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK' or sLockTrim == '5B_LK' or sLockTrim == '6B_LK' or sLockTrim == '7B_LK' or sLockTrim == '8B_LK') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 3 then EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) end end -- in tutti gli altri profili setto l'affondamento a extra probe z elseif not bLockMach then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 3 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) -- se profilo bevel up assegno nota if sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK' then EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') end end end end if bTopMach then -- se profilo top è da lavorare rinomino nome entita -- recupero entità probe di fianco su lato secure local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 2 then EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) end end -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z elseif not bTopMach and ( sTopTrim == 'BD' or sTopTrim == 'BDEB') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 2 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') end end -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta elseif not bTopMach and ( sTopTrim == '1B' or sTopTrim == '2B' or sTopTrim == '3B' or sTopTrim == '4B' or sTopTrim == '5B' or sTopTrim == '6B' or sTopTrim == '7B' or sTopTrim == '8B') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 2 then EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) end end -- in tutti gli altri profili setto l'affondamento a extra probe z elseif not bTopMach then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 2 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) -- se profilo bevel up assegno nota if sTopTrim == 'BU' or sTopTrim == 'BUEB' then EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') end end end end if bBottomMach then -- se profilo top è da lavorare rinomino nome entita -- recupero entità probe di fianco su lato secure local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 4 then EgtSetName( ProbeList[j], 'NO_ProbeSidePoint' ) end end -- se non da lavorare e profilo bevel dn cambio lo spessore allo spessore probe + extra probe z elseif not bBottomMach and ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 4 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) EgtSetInfo( ProbeList[j], 'ProfSide', 'BD') end end -- se profilo non lavorato e di tipo bullnose cambio lo spessore a metà porta elseif not bBottomMach and ( sBottomTrim == '1B' or sBottomTrim == '2B' or sBottomTrim == '3B' or sBottomTrim == '4B' or sBottomTrim == '5B' or sBottomTrim == '6B' or sBottomTrim == '7B' or sBottomTrim == '8B') then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 4 then EgtModifyCurveThickness( ProbeList[j], -( dThickDoor/2 + tMainTabPar.EZPB)) end end -- in tutti gli altri profili setto l'affondamento a extra probe z elseif not bBottomMach then -- recupero entità probe di fianco local ProbeList = MB.FindEntitiesWithName( Pz, 'ProbeSidePoint') local eProSide -- ciclo su tutte le entità trovate for j = 1, #ProbeList do eProSide = EgtGetInfo( ProbeList[j], 'SideApplied', 'i') or 0 if eProSide == 4 then EgtModifyCurveThickness( ProbeList[j], -tMainTabPar.EZPB) -- se profilo bevel up assegno nota if sBottomTrim == 'BU' or sBottomTrim == 'BUEB' then EgtSetInfo( ProbeList[j], 'ProfSide', 'BU') end end end end -- *** Lavorazioni *** -- setto variabili in funzione della disposizione porta local bMakeGhost = true -- se esiste la forzatura sulla direzione lavorazione cerniere if tMainTabPar.FDMH and abs( tMainTabPar.FDMH) == 1 then nDirReorderGroups = tMainTabPar.FDMH -- altrimenti come in precedenza, in base alla disposizione lato top porta else nDirReorderGroups = nDispMode end local dPercentDoorLength --------------------------------------------------------------------------------------------------------------------------- -- 06/05/2021 in base al seguente avvenimento: porta lunga 3025 con 4 cerniere, 2 per ogni shuttle, e con una groove che -- sborda sul lato cerniere. Alla chiamata della DANGER_L (nel Processo4) lo shuttle 1 a sinistra chiede di parcheggiare -- nella posizione calcolata (L88) nel P5INIT che è a pacco con lo shuttle 2 nella parte destra della porta. L'arbitro non -- da il consenso al parcheggio perchè la posizione è ancora occupata dallo shuttle 2 che sta lavorando e quindi manda -- in parcheggio lo shuttle 1 fuori (tutto a sinistra) ma che, data la lunghezza elevata della porta, quando il gruppo 4 -- andando a lavorare la groove vicino al lato hinge, rischia di collidere con lo shuttle 1. -- Quindi per ovviare al problema è stato stabilito, in accordo con Carlo Viviani, di controllare per prima -- la dimensione della porta, e se la lunghezza porta è maggiore del valore stabilito nella macro P5INIT nella variabile -- L116 (ad oggi al valore 1800mm) allora la percentuale di distribuzione cerniere passa a 45% (su questa macchina) dalla -- parte dove la porta è riferita (cioè 45% da sinistra se porta disposta a sinistra, 45% da destra se porta riferita a destra), -- in questo modo lo shuttle più vicino al riferimento porta lavora meno dello shuttle opposto così, se viene chiamato -- un danger sul lato opposto a riferimento ci sono più probabilità che lo shuttle vicino al riferimento abbia già finito -- e la richiesta di parcheggio interno per lo shuttle opposto trova lo spazio disponibile. --------------------------------------------------------------------------------------------------------------------------- if dLengthDoor >= tMainTabPar.BDH then dPercentDoorLength = 0.45 -- 45% sempre dalla parte dove è riferita -- EgtIf( nDispMode > 0, 0.52, 0.48) else ------------------------------------------------------------------------------------------- -- Su richiesta del cliente (Adam Linch) in data 06/12/2017 la ripartizione delle tre cerniere è la seguente: ------------------------------------------------------------------------------------------- -- 2 cerniere allo shuttle corrispondente al lato di riferimento porta. V1.3 -- quanto viene dopo è stato cambiato -- assegno una percentuale di 0.6 sempre verso lo shuttle di sinistra (Viviani 30/01/2017) -- se disposta a sinistra assegno 0.6 da sinistra, se disposta a destra assegno 0.4 da destra, il risultato è quindi -- sempre 0.6 da sinistra -- ma con 3 cerniere o 3 pivot, inverto la percentuale, cioè sempre 0.4 da sinistra V1.2 -- V1.1 --local dPercentDoorLength = EgtIf( nDispMode > 0, 0.6, 0.4) -- V1.1 -- V1.2 --local dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.4, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) -- V1.2 -- V1.3 dPercentDoorLength = EgtIf( nDispMode > 0, EgtIf( dNumHingesPivots == 3 ,0.6, 0.4), EgtIf( dNumHingesPivots == 3, 0.6,0.4)) -- V1.3 end -- Se uso shuttle forzato su uno dei due shuttle cambio la percentuale if tMainTabPar.FUS then if tMainTabPar.FUS == 1 then dPercentDoorLength = 0 elseif tMainTabPar.FUS == 2 then dPercentDoorLength = 1 else tMainTabPar.FUS = 0 end else tMainTabPar.FUS = 0 end -- scrivo la nota EgtSetInfo( Pz, 'ForceShuttle', tMainTabPar.FUS) -- calcolo una direzione locale perchè se ha segno opposto e la porta è disposta sul lato opposto, viene fatto un errore nel calcolo della posizione di scambio local nLocalDirReorderGroup = EgtIf( nDirReorderGroups == nDispMode, nDirReorderGroups, -nDirReorderGroups) -- quanto segue nella sottostante spiegazione è stato cambiato ---- determino la posizione del cambio shuttle utilizzando un coefficente di 0.4 verso destra se il posizionamento è a destra ---- e un coefficente di 0.6 verso destra se il posizionamento è a sinistra, in modo ---- da favorire lo shuttle che è dalla parte del riferimento ( a destra con assegnazione nMach a 2 e a sinistra con assegnazione nMach a 3) dPosShuttleChange = EgtIf( nDispMode > 0, tMainTabPar.OR1:getX(), tMainTabPar.OR2:getX()) + ( dLengthDoor * dPercentDoorLength * nLocalDirReorderGroup) + ( OffsXSovr * nLocalDirReorderGroup) + tabOri:getX() --verifico se la porta è da considerarsi stretta if dWidthDoor <= tMainTabPar.NWD then -- tMainTabPar.DSL = 0 -- tMainTabPar.DPSL = 200 -- riassegno il valore della variabile tMainTabPar.NWD = true -- scrivo la nota che indica la porta stretta EgtSetInfo( Pz, 'NarrowestDoor', tMainTabPar.NWD) else -- riassegno il valore della variabile tMainTabPar.NWD = false end -- ricavo minimo e massimo del solido del pezzo b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT) pMin = b3SolidOnTab:getMin() pMax = b3SolidOnTab:getMax() local tOrderGrp = {} -- print Machining table -- solo il primo giro: aggiusto i profili bevel per essere coerente con la sequenza di tabella -- riordino i gruppi geometrici che hanno l'operazione AdjustHead o AdjustHeadOnASplint in ordine di X decrescente for i = 1, #tLocMach do -- print Machining table DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) -- Applico le lavorazioni for j = 1, #EntList do -- OPERAZIONI if tLocMach[i].Oper then if tLocMach[i].Oper == 'AdjustBevel' then local sNewName _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP, nil, true) elseif tLocMach[i].Oper == 'AdjustBevelToSand' then local sNewName _, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.SVP, nil, true) elseif tLocMach[i].Oper == 'AdjustHead' or tLocMach[i].Oper == 'AdjustHeadOnASplint' then -- nDirReorderGroups = -1 = ordine decrescente ( da dx a sx <--); nDirReorderGroups = 1 ordine crescente ( da sx a dx -->) MB.ReorderGroup( EntList[j], tOrderGrp, nDirReorderGroups) -- Nuova ma non va bene -- MB.ReorderGroup( EntList[j], tOrderGrp, EgtIf( nDispMode > 0 , - nDirReorderGroups, nDirReorderGroups)) -- sempre decrescente; end end end end end end -- conteggio lavorazioni saltate nNumMachSkipResult = 0 -- variabile per conteggio lavorazioni nNumMach = 0 nNumSkip = 0 -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto if bFlip then local nValAppo = nNumGeomBottom nNumGeomBottom = nNumGeomTop nNumGeomTop = nValAppo nValAppo = nNumGeomBottomHole nNumGeomBottomHole = nNumGeomTopHole nNumGeomTopHole = nValAppo end -- Machining adding, only for selected machine -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni for i = 1, #tLocMach do if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) -- Applico le lavorazioni for j = 1, #EntList do local bAdjustHead = false local nNewIdEnt -- OPERAZIONI if tLocMach[i].Oper then if tLocMach[i].Oper == 'AdjustBevel' or tLocMach[i].Oper == 'AdjustBevelToSand' then local sNewName if tLocMach[i].Oper == 'AdjustBevel' then bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.NVP, bMakeGhost, nil, tMainTabPar.NWD) else bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, tMainTabPar.SVP, bMakeGhost, nil, tMainTabPar.NWD) end if bLocMach then local bInsLav = false -- faccio il test per vedere se la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end -- se la lavorazione è applicabile if bInsLav then -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if sEdge then if #sMachProf > 0 then sMachProf = sMachProf .. ',' .. sEdge else sMachProf = sEdge end -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura if string.lower( sEdge) == 'left' then local dOffsLoc = 0 if bAtRight then if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sHingeTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[1] local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[1] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end elseif not bAtRight then if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then dOffsLoc = dThickDoor * TAN3 elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[2] local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[2] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end end MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'right' then local dOffsLoc = 0 if bAtRight then if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then dOffsLoc = dThickDoor * TAN3 elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[2] local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[2] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end elseif not bAtRight then if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sHingeTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[1] local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[1] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end end MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'top' then local dOffsLoc = 0 if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sTopTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[3] local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[3] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'bottom' then local dOffsLoc = 0 if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 end MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) end end end else bOk = false end elseif tLocMach[i].Oper == 'AdjustVertCurve' then bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) elseif tLocMach[i].Oper == 'AdjustRoughCurve' then local bInvertOnZPos = false -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if string.lower( sEdge) == 'left' then if bAtRight then if sHingeTrim == 'CV' then bInvertOnZPos = true end elseif not bAtRight then if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then bInvertOnZPos = true end end elseif string.lower( sEdge) == 'right' then if bAtRight then if sLockTrim == 'CV' or sLockTrim == 'CV_LK' then bInvertOnZPos = true end elseif not bAtRight then if sHingeTrim == 'CV' then bInvertOnZPos = true end end elseif string.lower( sEdge) == 'top' then if sTopTrim == 'CV' then bInvertOnZPos = true end elseif string.lower( sEdge) == 'bottom' then if sBottomTrim == 'CV' then bInvertOnZPos = true end end bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true, bInvertOnZPos) elseif tLocMach[i].Oper == 'AdjustThrouCurve' then bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, nil, nil, tMainTabPar.NWD) if bLocMach then local bInsLav = false -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end if bInsLav then -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if sEdge then if #sMachProf > 0 then sMachProf = sMachProf .. ',' .. sEdge else sMachProf = sEdge end end -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura if string.lower( sEdge) == 'left' then local dOffsLoc = 0 if bAtRight then if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sHingeTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[1] local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[1] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end elseif not bAtRight then if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then dOffsLoc = dThickDoor * TAN3 elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[2] local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[2] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end end MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'right' then local dOffsLoc = 0 if bAtRight then if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then dOffsLoc = dThickDoor * TAN3 elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[2] local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[2] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end elseif not bAtRight then if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sHingeTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[1] local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[1] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end end MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'top' then local dOffsLoc = 0 if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 elseif sTopTrim == 'CV' then -- calcolo minimo ingombro profilo local dAltProf = dThickDoor/2 - tsPlaneProf[3] local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf)) dOffsLoc = tsRadiusProf[3] - dMaxInsPrf -- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc) end MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) elseif string.lower( sEdge) == 'bottom' then local dOffsLoc = 0 if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then dOffsLoc = dThickDoor * TAN3 end MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, nil, dOffsLoc, tMainTabPar.RSM) end end else bOk = false end elseif tLocMach[i].Oper == 'AdjustThrouIsle' then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) if not bLocMach then -- se operazione fallita bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 local sResMach if nMach == 1 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end if not bInsLav then if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- se nome lavorazione non nullo, incremento i contatori if sResMach and #sResMach > 0 then -- aumento di 1 il numero di lavorazioni skippate nNumMachSkip = nNumMachSkip + 1 -- ricambio la nota come non lavorabile in questa fase EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end else -- se è andata a buon punto vedo di sottrarle ai contatori degli skip if nMach == 1 then if nNumGeomTop > 0 then nNumGeomTop = nNumGeomTop - 1 end elseif nMach == 2 then if nNumGeomBottom > 0 then nNumGeomBottom = nNumGeomBottom - 1 end end end end elseif tLocMach[i].Oper == 'AdjustProbeMill' and nProbeMode == 0 and nPostProbeSet > 2 then local sMachRetured bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeMill( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, tMainTabPar.PTK, tMainTabPar.EZPB) if not bLocMach then bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile if bOk then local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 nLocMach = nMach if nMach == 1 then bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt, true) elseif nMach == 3 then bInsLav, sMachRetured = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end if not bInsLav then if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- se c'è nome lavorazione aumento di 1 il numero di lavorazioni skippate if sMachRetured then nNumMachSkip = nNumMachSkip + 1 end -- ricambio la nota come non lavorabile in questa fase if nMach == 1 then EgtSetInfo( nNewIdEnt, 'Mach', 11) elseif nMach == 2 then EgtSetInfo( nNewIdEnt, 'Mach', 13) elseif nMach == 3 then EgtSetInfo( nNewIdEnt, 'Mach', 12) end -- se nome lavorazione non nullo, incremento i contatori if sMachRetured then -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end else -- se è andata a buon punto setto nota alla porta EgtSetInfo( Pz, 'ExistsProbeXY', true) -- presenza del probe in XY end else EgtSetInfo( nNewIdEnt, 'Mach', 31) end end elseif tLocMach[i].Oper == 'AdjustHorizDrillX' then bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true, 0) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorizDrillY' then bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true, 0) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorizAS' then bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustMortise' then bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustBevelChisel' then bLocMach,_, nNewIdEnt = MB.AdjustBevelChisel( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHeadChisel' then bLocMach, nNewIdEnt, nNumMachSkipResult = MB.AdjustHeadChisel( EntList[j], bMakeGhost, CHISEL_ONLY_HORIZONTAL, nNumMachSkip, NO_WORK_UPSQUARE, NO_WORK_UNDERSQUARE) if not bLocMach then bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult end elseif tLocMach[i].Oper == 'AdjustVertHole' then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) if not bLocMach then bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 local sResMach if nMach == 1 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end if not bInsLav then if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- se nome lavorazione non nullo, incremento i contatori if sResMach and #sResMach > 0 then -- aumento di 1 il numero di lavorazioni skippate nNumMachSkip = nNumMachSkip + 1 -- ricambio la nota come non lavorabile in questa fase EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end else -- se è andato a buon fine, verifico di sottrarlo agle variabili skip if nMach == 1 then if nNumGeomTopHole > 0 then nNumGeomTopHole = nNumGeomTopHole - 1 nNumGeomTop = nNumGeomTop - 1 end elseif nMach == 2 then if nNumGeomBottomHole > 0 then nNumGeomBottomHole = nNumGeomBottomHole - 1 nNumGeomBottom = nNumGeomBottom - 1 end end end end elseif tLocMach[i].Oper == 'AdjustHole' then bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHead' then bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHead( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange) bAdjustHead = true if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHeadOnASplint' then bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHeadOnASplint( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nil, nDispMode, bFlip, MAXMACH) bAdjustHead = true if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost) elseif tLocMach[i].Oper == 'AdjustASplintWithBlade' then bOk, nNewIdEnt = MB.AdjustASplintWithBlade( EntList[j], bMakeGhost, nDispMode, bFlip) elseif tLocMach[i].Oper == 'AdjustSplitDoor' and nProbeMode ~= 1 then if not bGetSplitCuts then tSplitDoorEnt = EntList table.insert( tSplitDataInf, { tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, nNumMach, bMakeGhost}) bGetSplitCuts = true end elseif tLocMach[i].Oper == 'AdjustConeCleanPaths' and nProbeMode ~= 1 then bOk, nNewIdEnt = MB.AdjustConeCleanPaths( EntList[j], bMakeGhost) elseif tLocMach[i].Oper == 'AdjustVertAsOnHeads' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustVertAsOnHeads( EntList[j], bMakeGhost) if not bLocMach then bOk = false end end else -- se nessuna operazione nNewIdEnt = MB.MakeGhostCopy( EntList[j]) end -- LAVORAZIONI local nMach if nNewIdEnt then nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 else nMach = 0 end if nMach > 30 and nMach < 40 then nMach = nMach - 30 end if bAdjustHead and nMach > 0 and nMach < 4 then -- se navette -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme bOk, nNumMach = FindAndCalcGroupMachining( EntList[j], nNewIdEnt, tLocMach, nNumMachFromTable, nMach, nNumGroup, nNumMach, bOk, tMainTabPar.BPLI, tMainTabPar.PRF) elseif nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno -- carico id entità in una tabella local tListSameMach = {} table.insert( tListSameMach, nNewIdEnt) bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, NOT_GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) else if not bAdjustHead then DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') .. EgtDoorsMsg[596]..tostring( nNumPhase), 0) nNumSkip = nNumSkip + 1 end end end end end end local i = 1 while i <= #tLocMachOrd do -- carico tutto il gruppo in una tabella local tGroup = {} local nNumGrp = tLocMachOrd[i].Group local sProperty = tLocMachOrd[i].Property tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty) if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0 if sProperty == 'MinDist' or sProperty == 'FromXPosToXNeg' then -- ottimizzare alla minima distanza -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) local LastMch = EgtGetLastOperation() local EndLastMach -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then EgtSetCurrMachining( LastMch) EndLastMach = EgtGetMachiningEndPoint() end local tMachining = {} -- creo lavorazioni del gruppo for k = 1, #tGroup do -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') local bAdjustHead = false -- Applico le lavorazioni for j = 1, #EntList do -- LAVORAZIONI local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMach = nMach - 30 -- se lavorazione corretta ottengo 1 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 local sMachining = EgtGetInfo( EntList[j], 'Machining') -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima if nMach > 0 and nMach < 4 then nMach = 1 end -- se lavorazione esiste e corrisponde e numero lavorazione è = 1 if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) -- se più di 1 entità le ordino if #tListSameMach > 1 then if sProperty == 'FromXPosToXNeg' then tListSameMach = MB.OrderEnt( tListSameMach, nil, 1) else tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) end EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH, tMachining, tMainTabPar.BPLI, tMainTabPar.PRF) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end -- ordino le lavorazioni if #tMachining > 1 then -- Tavole per fresature da ordinare local TabMill = {} local TabMStEnP = {} local TabZMach = {} for k = 1, #tMachining do -- Se appartiene alla fase corrente e fresatura non vuota if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then EgtSetCurrMachining( tMachining[k][1]) local ptStart = EgtGetMachiningStartPoint() local ptEnd = EgtGetMachiningEndPoint() if ptStart and ptEnd then table.insert( TabMill, tMachining[k][1]) table.insert( TabMStEnP, { ptStart, ptEnd}) MB.InsZedByTool( TabZMach, tMachining, k) end end end -- calcolo ordinamento EgtSpInit() for k = 1, #TabMill do EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) end local vMillOrd if sProperty == 'FromXPosToXNeg' then EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,10000,0,0,90,90) vMillOrd = EgtSpCalculate(SHP_TY.OPEN) else if EndLastMach then EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) else EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) end vMillOrd = EgtSpCalculate(SHP_TY.OPEN) end EgtSpTerminate() -- applico ordinamento calcolato -- parto da LastMch precedente if vMillOrd then for k = 1, #vMillOrd do EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) LastMch = TabMill[vMillOrd[k]] end end end elseif sProperty == 'Shuttle' then -- lavorazione con shuttle -- per ogni layer padre nella lista fatta con il reordergroup for k = 1, #tOrderGrp do -- Recupero la prima entità del layer padre local EntList = MB.FindEntities( tOrderGrp[k][1], true) -- LAVORAZIONI local nMach = 1 -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme bOk, nNumMach = MakeGroupMachining( EntList, tOrderGrp[k][1], tGroup, nMach, nNumGrp, nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach, tMainTabPar.BPLI, tMainTabPar.PRF) end elseif sProperty == 'Layer' then -- lavorazione layer -- ottengo tutte le entità del gruppo local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE') -- Applico le lavorazioni for j = 1, #EntListGrp do local nParendId = EgtGetParent(EntListGrp[j]) -- Recupero la prima entità del layer padre local EntList = MB.FindEntities( nParendId, true) -- LAVORAZIONI local nMach = 1 -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp, nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach, tMainTabPar.BPLI, tMainTabPar.PRF) end elseif sProperty == '' then -- proprietà nulla -- creo lavorazioni del gruppo for k = 1, #tGroup do -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE') local bAdjustHead = false -- Applico le lavorazioni for j = 1, #EntList do -- LAVORAZIONI local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMach = nMach - 30 -- se lavorazione corretta ottengo 1 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 local sMachining = EgtGetInfo( EntList[j], 'Machining') -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima if nMach > 0 and nMach < 4 then nMach = 1 end if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) -- se più di 1 entità le ordino if #tListSameMach > 1 then tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach, tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end end elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore DGD.ERR = -15 if DGD.EMC and #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza else DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza end if DGD.ERM and #DGD.ERM > 0 then DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza else DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza end end i = i + 1 end ---------------------------------------- -- Inserimento riferimenti e ventose ---------------------------------------- -- Offset ventose da bordo pezzo in Y dVacOffs = tMainTabPar.VOY -- Offset barra riferimenti mobile da riferimenti quando posizione 0 dMobOffs = tMainTabPar.MOY + dVacOffs -- Lunghezza minima per alzare prima ventosa da bordo sinistro dDistMinX = tMainTabPar.LDX + 40 + DIST_MIN_VAC_L -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) -- Lunghezza minima per alzare prima ventosa da bordo destro dDistMaxX = tMainTabPar.RDX + 40 + DIST_MIN_VAC_R -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza) -- Posizione ventose in alto dVacOn = 75 -- Interasse ventose dInterAx = 232 -- distanza interferenza con cave passanti dDistInterferThru = tMainTabPar.DTG -- modificato da 20 a 12 il 26/10/2017 su richiesta di Mark dDistInterferBlind = tMainTabPar.DBG dDistInterferUnder = tMainTabPar.DUG dDistInterferSide = tMainTabPar.DSG -- Ventose local nTabId = EgtGetTableId( 'Tab') local nMobId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE') local nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') local nDispId = EgtGetPhaseDisposition( nNumPhase) -- se gruppi richiesti non trovati if not nMobId or not nFixId then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[675]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' break end -- Posizionamento barra mobile local dOldVal = EgtGetInfo( nMobId, 'Val', 'd') -- calcolo nuova posizione con: larghezza finita porta ( uso getDimX perché presa prima della disposizione porta) + -- 2 volte il sovramateriale a contatto con il riferimento in basso - distanza ventose - offset barra local dNewVal = b3Solid:getDimX() + OffsYSovr + OffsYSovr + vShift:getY() + vShiftVac:getY() - dVacOffs - dMobOffs -- controllo che la posizione non supera la posizione massima raggiungibile dalla barra mobile if dNewVal > tMainTabPar.MPMB then dNewVal = tMainTabPar.MPMB end EgtMove( nMobId, Vector3d( 0, dNewVal - dOldVal, 0), GDB_RT.GLOB) EgtSetInfo( nMobId, 'Val', dNewVal) EgtSetInfo( nDispId, 'MOB', dNewVal) -- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa local dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( nDispMode > 0, dDistMinX, dDistMaxX) -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto StartVacVerify( Ls, bFlip, dThickDoor) -- verifico se presente groove applicato a top su angolo local sAngGrooveNote = EgtGetInfo( Pz, 'GrooveOnAngle', 's') -- ciclo sulle ventose local nInd = 1 local nIndVac local nNumTotVacRow = 13 local nCountFailed = 0 local nIniFailed = 0 local nMiddleFailed = 0 local nEndFailed = 0 local nMaxIniFailed = 0 local nMaxMiddleFailed = 0 local nMaxEndFailed = 0 while dCalcLen > 0 and nInd <= nNumTotVacRow do nIndVac = EgtIf( nDispMode > 0, nInd, ( nNumTotVacRow - nInd + 1)) local sInd = tostring( nIndVac) -- eseguo verifica local nCenFixId = EgtGetFirstNameInGroup( nFixId, 'CEN'..sInd) local pPntFix = EgtSP( nCenFixId, GDB_ID.ROOT) local bBlindColl = false local bCanUpFix, nVacErr, bBlindColl, nCustType = ExecVacShapeVerify( pPntFix, tVacType[tMapVac[nInd]], tabOri, dDistInterferThru, dDistInterferBlind, dDistInterferSide, false, 0, 0, EgtIf( nInd < 3, sAngGrooveNote, nil), Ls, bFlip, nCenFixId) if not bCanUpFix and nVacErr > 0 then if nVacErr == 1 then DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) elseif nVacErr == 3 then DoorOutLog( 'Vacuul external of top angle path: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '.', 0) else DoorOutLog( 'Region SHAPE not found into vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) end end -- local bCanUpFix = ExecVacVerify( pPntFix, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), -- Ls, bFlip, nCenFixId) local nCenMobId = EgtGetFirstNameInGroup( nMobId, 'CEN'..sInd) local pPntMob = EgtSP( nCenMobId, GDB_ID.ROOT) local bCanUpMob bCanUpMob, nVacErr, bBlindColl, nCustType = ExecVacShapeVerify( pPntMob, tVacType[tMapVac[nInd]], tabOri, dDistInterferThru, dDistInterferBlind, dDistInterferSide, false, 0, 0, EgtIf( nInd < 3, sAngGrooveNote, nil), Ls, bFlip, nCenMobId) if not bCanUpFix and nVacErr > 0 then if nVacErr == 1 then DoorOutLog( 'Group Mobile or Area not found into Vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) elseif nVacErr == 3 then DoorOutLog( 'Vacuul external of top angle path: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '.', 0) else DoorOutLog( 'Region SHAPE not found into vacuum model: '.. ttBaseDataVac[nCountTypeVac][nNumB][2] .. '. Please update vacuum nge model', 0) end end -- local bCanUpMob = ExecVacVerify( pPntMob, dDistInterferThru, dDistInterferBlind, dDistInterferUnder, EgtIf( nInd < 3, sAngGrooveNote, nil), -- Ls, bFlip, nCenMobId) -- eventuale movimento if bCanUpFix and bCanUpMob then local nIdFix = AddMoveShowHideVac( KIND_DISP_MODE, nFixId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, tVacType[tMapVac[nInd]], ( pPntFix - tabOri)) local nIdMov = AddMoveShowHideVac( KIND_DISP_MODE, nMobId, 'VAC'..sInd, 'ROD'..sInd, dVacOn, tVacType[tMapVac[nInd]], ( pPntMob - tabOri)) -- salvo lo stato e info modalità disposizione EgtSetInfo( nDispId, 'VAC'..sInd, dVacOn) EgtSetInfo( nDispId, 'KIND_DISP_MODE'..sInd, KIND_DISP_MODE) -- EgtSetInfo( nDispId, 'FIXIDS'..sInd, nIdFix) -- EgtSetInfo( nDispId, 'MOBIDS'..sInd, nIdMov) EgtSetInfo( nDispId, 'FIXPOS'..sInd, ( pPntFix - tabOri)) EgtSetInfo( nDispId, 'MOBPOS'..sInd, ( pPntMob - tabOri)) -- interrompo le serie negative if nInd > 1 then nCountFailed = 0 if nMaxIniFailed < nIniFailed then nMaxIniFailed = nIniFailed end if nMaxMiddleFailed < nMiddleFailed then nMaxMiddleFailed = nMiddleFailed end if nMaxEndFailed < nEndFailed then nMaxEndFailed = nEndFailed end nIniFailed = 0 nMiddleFailed = 0 nEndFailed = 0 end else EgtRemoveInfo( nDispId, 'VAC'..sInd) EgtRemoveInfo( nDispId, 'KIND_DISP_MODE'..sInd) AddMoveShowHideVac( 2, nFixId, 'VAC'..sInd) -- rendo visibile ventosa AddMoveShowHideVac( 2, nMobId, 'VAC'..sInd) -- rendo visibile ventosa nCountFailed = nCountFailed + 1 if nInd == 1 then -- setto solo il fallimento iniziale nIniFailed = nCountFailed elseif nInd == nNumTotVacRow or ( dCalcLen - dInterAx) <= 0 then -- setto solo quello finale e annullo il medio nEndFailed = nCountFailed if nMaxEndFailed < nEndFailed then nMaxEndFailed = nEndFailed end nMiddleFailed = 0 else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati if nIniFailed > 0 then nIniFailed = nCountFailed elseif nEndFailed > 0 then nEndFailed = nCountFailed - 1 else nMiddleFailed = nCountFailed end end end -- aggiorno la lunghezza di calcolo e l'indice dCalcLen = dCalcLen - dInterAx nInd = nInd + 1 end -- elimino geometrie per verifica EndVacVerify() -- riassegno la quantità di file che effettivamente potrebbero essere alzate nInd = nInd - 1 -- casi di scarse ventose if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then -- tutte le ventose basse DGD.EMC = ' ' .. EgtDoorsMsg[531] bOk = false break elseif nInd > 0 and nMaxIniFailed / nInd > 0.35 then -- ventose iniziali ( parte destra) local nNumMsg = EgtIf( nDispMode > 0, 532, 534) DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false break elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then -- ventose intermedie DGD.EMC = ' ' .. EgtDoorsMsg[533] bOk = false break elseif nInd > 0 and nMaxEndFailed / nInd > 0.35 then -- ventose finale ( parte sinistra) local nNumMsg = EgtIf( nDispMode > 0, 534, 532) DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false break elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then -- somma di vari intervalli DGD.EMC = ' ' .. EgtDoorsMsg[531] bOk = false break end ------------------------------------------------- -- gestione messaggi LIGHT: red, yellow, green ------------------------------------------------- -- se ho geometrie da entrambe le parti la luce è red if nNumGeomBottom > 0 and nNumGeomTop > 0 then sLight = 'RED' -- se non ho geometrie la luce è green elseif nNumGeomBottom == 0 and nNumGeomTop == 0 then sLight = 'GREEN' -- se una delle due ha delle geometrie else -- in caso di geometrie tutte sotto luce yellow if nNumGeomBottom > 0 then sLight = 'YELLOW' -- in caso di geometrie tutte sopra luce green elseif nNumGeomTop > 0 then sLight = 'GREEN' end end -- *** Tools Setup *** -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri local bSetUp = EgtImportSetup() local tListError local sListTool = '' if bSetUp then -- se importato quello di default sSetup = EgtGetDefaultSetupName() -- verifico se l'attrezzaggio è idoneo bSetUp, tListError = EgtVerifyCurrSetup() -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default if bSetUp then -- assegno nota con il nome del file setup assegnato EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) else -- preparo la lista degli utensili mancanti sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] for k = 1, #tListError do sListTool = sListTool .. '\n ' .. tListError[k] end end end -- se fallito quello di default o utensili mancanti provo quello indicato nel CurrCamInfo if not bSetUp then local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default local nContImport = 0 -- ciclo tra quelli disponibili for k = 1, 8 do if not bSetUp then if k == 1 then sSetup = mCamData[nNumMachFromCam].Setup1 elseif k == 2 then sSetup = mCamData[nNumMachFromCam].Setup2 elseif k == 3 then sSetup = mCamData[nNumMachFromCam].Setup3 elseif k == 4 then sSetup = mCamData[nNumMachFromCam].Setup4 elseif k == 5 then sSetup = mCamData[nNumMachFromCam].Setup5 elseif k == 6 then sSetup = mCamData[nNumMachFromCam].Setup6 elseif k == 7 then sSetup = mCamData[nNumMachFromCam].Setup7 elseif k == 8 then sSetup = mCamData[nNumMachFromCam].Setup8 end -- se nome attrezzaggio non è vuoto if sSetup and #sSetup > 0 then bSetUp = EgtImportSetup(sSetup) end if bSetUp then -- se importato il fle da CurrCamInfo nContImport = nContImport + 1 -- verifico se l'attrezzaggio è idoneo bSetUp, tListError = EgtVerifyCurrSetup() if bSetUp then -- se è andato bene -- assegno nota con il nome del file setup assegnato EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) break else -- se utensili mancanti prendo la lista e passo al successivo sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] for k = 1, #tListError do sListTool = sListTool .. '\n ' .. tListError[k] end end else -- se non importato carico il messaggio di errore e passo al successivo sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) end end end -- se nessuno è andato bene verifico se il primo era stato importato if not bSetUp then if ( sDefSetUp and #sDefSetUp > 0) or nContImport > 0 then if DGD.EMC and #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551] else DGD.EMC = ' ' .. EgtDoorsMsg[551] end bOk = false if #sListTool > 0 then DGD.EMC = DGD.EMC .. sListTool end break else -- setup default non definito -- assegno ugualmente un attrezzaggio vuoto EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) end else -- ha importato il file da CurrCamInfo -- verifico se l'attrezzaggio è idoneo bSetUp, tListError = EgtVerifyCurrSetup() if bSetUp then -- se è andato bene -- assegno nota con il nome del file setup assegnato EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) else -- se utensili mancanti sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', 1) sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] for k = 1, #tListError do sListTool = sListTool .. '\n ' .. tListError[k] end DGD.EMC = DGD.EMC .. sListTool bOk = false break end end end -- se nessuna geometria skippata esco if nNumMachSkip and nNumMachSkip == 0 then bWork = false end -- se lavorazioni skippate abilito il ribaltamento porta in altra fase if nNumMachSkip and nNumMachSkip > 0 then nNumMachSkip = 0 -- resetto per il prossimo giro -- per interrompere il giro forzatamente ( perché nessun ribaltamento) setto bWork bWork = false end nNumCycle = nNumCycle + 1 -- se deve uscire dal ciclo, prima di farlo, eseguo l'eventuale split della porta if not bWork then -- gestione taglio longitudinale split door -- assegnamento variabili -- se è una porta e nessuna lavorazione da sotto if not sAssemb and nNumGeomBottom == 0 then local EntList = tSplitDoorEnt if #EntList == 1 then -- acquisisco nota direzione taglio e la confronto con il parametro del currcaminfo local sDirCut = EgtGetInfo( EntList[1], 'DirectionCut', 's') if sDirCut and ( ( sDirCut == 'H' and string.find( tMainTabPar.CDA, 'H')) or ( sDirCut == 'W' and string.find( tMainTabPar.CDA, 'W'))) then bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[1], tSplitDataInf[1][7]) if bLocMach then local bInsLav = false local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 nLocMach = nMach if nMach == 1 then -- carico id entità in una tabella local tListSameMach = {} table.insert( tListSameMach, nNewIdEnt) bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tSplitDataInf[1][1], tSplitDataInf[1][2], tSplitDataInf[1][3], tSplitDataInf[1][4], tSplitDataInf[1][5], bOk, tSplitDataInf[1][6], false, NGEN_MACH, nil, tMainTabPar.BPLI, tMainTabPar.PRF) end else bOk = false end end -- se ho più di un taglio do errore elseif #EntList > 1 then -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then if DGD.EMC and #DGD.EMC > 0 then EgtOutBox( DGD.EMC .. '\n' .. EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) else EgtOutBox( EgtDoorsMsg[695], EgtDoorsMsg[476], EgtDoorsMsg[477]) end else -- scrivo messaggio nei file log DoorOutLog( EgtDoorsMsg[695], 0) end -- Salvo progetto EgtSaveFile() return false, nNumGroup end end end end -- end while --bOk = false -- per forzare l'errore if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end -- Eventuale messaggio di errore if not bOk then DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina DGD.ERR = 20 DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) -- stampo gli errori del machiningBase if DGD.EMC and #DGD.EMC > 0 then DoorOutLog( DGD.EMC, 0) end DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation -- cancello il file tok EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') -- cancello il file cn e il txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con l'errore WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD if DGD.EMC and #DGD.EMC > 0 then EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation else EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation end end -- Salvo progetto EgtSaveFile() return false, nNumGroup end -- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale) EgtApplyAllMachinings( false, false) -- Salvo progetto EgtSaveFile() -- nTime = EgtStopCounter() -- if not DGD or not DGD.NCGEN then -- EgtOutBox( string.format( '3 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') -- end -- -- inizializzo il contatore -- EgtStartCounter() -- controllo collisioni local bSimOk -- Simulation for collision check if tMainTabPar.ECD == 1 then DoorOutLog( ' +++ Simulating with collision check >>>', 0) EgtOutText( 'Start hidden simulation to find collision, It keep some time') local nErr, sErr bSimOk, nErr, sErr = EgtSimulate() if not bSimOk then if nErr == MCH_SHE.INIT then DGD.ERR = 33 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[686], sErr) EgtOutBox( string.format(EgtDoorsMsg[686], sErr), 'Simulation', 'Simulation') elseif nErr == MCH_SHE.COLLISION then DGD.ERR = 33 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[687], sErr) EgtOutBox( string.format(EgtDoorsMsg[687], sErr), 'Collision', 'Collision') elseif nErr == MCH_SHE.OUTSTROKE then DGD.ERR = 33 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[688], sErr) EgtOutBox( string.format(EgtDoorsMsg[688], sErr), 'Outstroke', 'Outstroke') else DGD.ERR = 33 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[689], sErr) EgtOutBox( string.format(EgtDoorsMsg[689], sErr), 'Simulation', 'Simulation') end end EgtOutText( 'hidden simulation finished') else bSimOk = true end -- nTime = EgtStopCounter() -- if not DGD or not DGD.NCGEN then -- EgtOutBox( string.format( '4 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') -- end -- -- inizializzo il contatore -- EgtStartCounter() if bSimOk then -- Estimation bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath) -- NC code generation bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath) else bOk = false -- luce di caricamento porta if sLight then DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM end end if bOk then if not DGD.ERR then DGD.ERR = 0 end -- luce di caricamento porta if sLight then DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM end DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) if not DGD.NCGEN then if DGD.ERM and #DGD.ERM > 0 then DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori end end DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log -- cancello il file tok EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) -- copio il file txt con nuova estensione .tok EgtCopyFile( sFileDir..sFileName..sNumGroup..'.txt', sFileDir..sFileName..sNumGroup..'.tok') else -- se la simulazione è stata corretta ma errore nella generazione if bSimOk then DGD.ERR = 20 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) end -- cancello il file tok EgtEraseFile( sFileDir..sFileName..sNumGroup..'.tok') -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') -- se la simulazione è stata corretta ma errore nella generazione if bSimOk then -- scrivo messaggio nei file log DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation end else if not DGD.NCGEN then if DGD.ERM and #DGD.ERM > 0 then DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori end end -- scrivo messaggio nei file log DoorOutLog( EgtDoorsMsg[690], 0) -- Error on simulation -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) EgtOutBox( EgtDoorsMsg[690], EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on simulation end end return false, nNumGroup end -- nTime = EgtStopCounter() -- if not DGD or not DGD.NCGEN then -- EgtOutBox( string.format( '5 tempo calcolato sec: %s', (nTime/1000)), 'Timex', 'Timex') -- end -- reset librerie locali package.loaded[MachiningsTable] = nil package.loaded[MachiningsTableOrd] = nil return true, nNumGroup end return MachiningLoc