-- -- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT -- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT -- EEEE GGGG GGGG TTTT -- EEEE GGGG TTTT -- EEEEEEE GGGG GGGGGGG TTTT -- EEEEEEE GGGG GGGGGGG TTTT -- EEEE GGGG GGGG TTTT -- EEEE GGGG GGGG TTTT -- EEEEEEEEEE GGGGGGGGGG TTTT -- EEEEEEEEEE GGGGGG TTTT -- -- by EgalTech s.r.l. 2017/03/29 -- Machining generation for Doors program machine CMS PK -- 2017/06/05 V1.011 DS Fix main cycle at 10 times -- 2017/06/13 V1.012 FM Manage machining optimization -- 2017/06/13 V1.012 FM Fix bug on calculate box and row piece -- 2017/06/30 V1.013 FM Manage optimization and assignement of more paths to one machining -- 2017/11/17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole -- 2018/02/26 V1.0b1 FM Manage piece dimension checking -- 2018/03/01 V1.0b2 FM use a table tMainTabPar instead of many variables ( more than 200 variables) -- 2018/03/22 V1.0b3 FM Manage checking effective lock/hinge side machining and adjust the second disposition. Before not recognize if -- lock/hinge side was machined or not in 1st phase -- 2018/03/23 V1.0b4 FM Manage parameter for probe extra Z position and adjust probe error values -- 2018/03/23 V1.0b4 FM Fix problem on second phase disposition by side path notes -- 2018/05/04 V1.0b5 FM Fix write 2nd phase disposition notes when first phase is empty and substitute by second phase -- 2018/05/09 V1.0b6 FM Fix error message on vacuums disposition -- 2018/05/09 V1.0b6 FM Calculate the solid box without extra surfaces -- 2018/06/18 V1.0b7 FM Manage door in probe mode and rebuilded -- 2018/06/22 V1.0b8 FM Manage second phase on rebuilded door and fix some bugs -- 2018/06/26 V1.0b9 FM Manage to use 2 bars with small width door -- 2018/06/27 V1.0c1 FM write note about number of probez geometries and if generate one of their machinings -- 2018/07/16 V1.0c2 FM Manage manual pin disposition on table bar disposition -- 2018/07/17 V1.0c3 FM Manage vacuum disposition: in case it uses only 2 bars use the vacuum for 3rd bar on 2nd bar -- 2018/07/24 V1.0d1 FM Read Properties (start managing properties) -- 2018/08/22 V1.0d2 FM Fix error on calculare roughing on bevel side profiles local MachiningLoc = {} -- Intestazioni require( 'EgtBase') _ENV = EgtProtectGlobal() EgtEnableDebug( false) -- Librerie particolari local sBaseDir = EgtGetSourceDir() EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua') require( 'EgtDoorsBase') require( 'EgtDoorsData') local EgtDoorsMsg = require( 'EgtDoorsMsg') local MB = require( 'MachiningBase') -- Impostazioni Cam per consentire forature con utensile più piccolo EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50) EgtMdbSave() -- Definizione disposizione pezzi ( a sinistra : 1, a destra : -1) local DISPMODE = -1 -- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra) local NO_WORK_UNDERSQUARE = false -- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra) local NO_WORK_UPSQUARE = true -- variabili genarazione lavorazioni local GEN_MACH = false local NOT_GEN_MACH = true -- Variabile distanza minima tra pezzo finito e ventosa (in X) local DIST_MIN_VAC = 5.5 -- variabili disposizione porta local bPush local bFlip ----------------------------------------------------------------- -- *** Error write file *** ----------------------------------------------------------------- local function WriteErrFile( sFileErr, sDispMsg) local nIdFile = io.open( sFileErr, 'w') if nIdFile then if DGD.ERR == 0 then if DGD.ERM and #DGD.ERM > 0 then nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM) else nIdFile:write( 'Err=' .. tostring( DGD.ERR)) end else if DGD.EMC and #DGD.EMC > 0 then nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. DGD.EMC) else nIdFile:write( 'Err=' .. tostring( DGD.ERR)) end end if sDispMsg and #sDispMsg > 0 then nIdFile:write('\n' .. sDispMsg) end nIdFile:close() end end ----------------------------------------------------------------- -- *** calculate door disposition by parameters *** ----------------------------------------------------------------- local function CalcTopPosition( nTopSideDriveDisp, bAtRight) local bTopOnRight if nTopSideDriveDisp and nTopSideDriveDisp == 1 then bTopOnRight = true elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then bTopOnRight = false else if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end end return bTopOnRight end ----------------------------------------------------------------- -- *** Add Machining in table for second part *** ----------------------------------------------------------------- local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab) if tSecMcng then if #tSecMcng > 0 then local bFound = false MTMachLine.Row = nIndexTab for k = 1, #tSecMcng do if MTMachLine == tSecMcng[k] then bFound = true end end -- se non trovato lo inserisco if not bFound then table.insert( tSecMcng,MTMachLine) end else MTMachLine.Row = nIndexTab table.insert( tSecMcng,MTMachLine) end end return tSecMcng end ----------------------------------------------------------------- -- *** Vacuums disposition *** ----------------------------------------------------------------- local ThroughId, BlindId ----------------------------------------------------------------- -- Function to correct Manual position axis linearity function GetCorrectedIndexedAxis( dMobVal) local PTableCorr = {{1, 366.210}, {2, 388.210}, {3, 416.210}, {4, 439.710}, {5, 467.210}, {6, 491.210}, {7, 516.210}, {8, 541.210}, {9, 567.210}, {10, 594.210}, {11, 617.210}, {12, 644.210}, {13, 668.710}, {14, 692.710}, {15, 718.710}, {16, 743.710}, {17, 769.710}, {18, 795.710}, {19, 821.210}, {20, 844.710}, {21, 871.210}, {22, 896.210}, {23, 922.210}, {24, 948.210}, {25, 972.710}, {26, 998.210}, {27, 1023.210}, {28, 1047.710}, {29, 1072.210}, {30, 1097.710}, {31, 1122.210}, {32, 1147.210}} -- Verifico che il valore passato sia raggiungibile if #PTableCorr < 2 or dMobVal < PTableCorr[1][2] or dMobVal > PTableCorr[#PTableCorr][2] then return end -- Cerco l'intervallo della tabella in cui cade il valore local nI = 1 while nI <= #PTableCorr and dMobVal > PTableCorr[nI][2] do nI = nI + 1 end -- calcolo la posizione del foro più vicina local dIndexBar local dNewVal if ( PTableCorr[nI][2] - dMobVal) >= ( dMobVal - PTableCorr[nI - 1][2]) then -- se misura più vicina la foro inferiore dNewVal = PTableCorr[nI - 1][2] dIndexBar = nI - 1 else dNewVal = PTableCorr[nI][2] dIndexBar = nI end return dNewVal, dIndexBar end ----------------------------------------------------------------- local function StartVacVerify( nIdSolid, bFlipped, nProbeMode) -- regioni passante e cieca non definite EgtErase( ThroughId or GDB_ID.NULL) ThroughId = nil EgtErase( BlindId or GDB_ID.NULL) BlindId = nil -- recupero le regioni sopra e sotto della porta messa in macchina local UpId, DwId local UpId2, DwId2 -- se porta ribaltata if bFlipped then if nProbeMode == 2 then -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) -- superficie a contatto con le ventose DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) -- superficie sopra UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) else -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) end else if nProbeMode == 2 then -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) -- superficie a contatto con le ventose DwId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_DW_2', true) -- superficie sopra UpId2 = MB.FindGeomWithName( nIdSolid, 'FLAT_UP_2', true) else -- superficie a contatto con le ventose DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true) -- superficie sopra UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true) end end -- creo le regioni complementari local CompUpId if nProbeMode == 2 then local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') local nCurveId = EgtExtractSurfFrChunkLoops( UpId2, 0, nRecId) -- prendo il contorno della regione piena CompUpId = EgtSurfFlatRegion( nIdSolid, nCurveId) -- creo regione rettangolare piena else local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.STANDARD) CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB) -- creo regione rettangolare piena end local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT) local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT) if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end EgtSurfFrSubtract( CompUpId, UpId) if not EgtExistsObj( CompUpId) then CompUpId = nil end local CompDwId if nProbeMode == 2 then local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') local nCurveId = EgtExtractSurfFrChunkLoops( DwId2, 0, nRecId) CompDwId = EgtSurfFlatRegion( nIdSolid, nCurveId) else local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.STANDARD) CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB) end local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT) local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT) if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end EgtSurfFrSubtract( CompDwId, DwId) if not EgtExistsObj( CompDwId) then CompDwId = nil end if CompDwId then EgtInvertSurf( CompDwId) end -- calcolo le regioni passante e cieca local ThroughRegId = nil local BlindRegId = nil -- se ci sono entrambe le regioni if CompUpId and CompDwId then -- per ottenere la regione passante faccio intersezione tra sopra e sotto EgtSurfFrIntersect( CompUpId, CompDwId) if EgtExistsObj( CompUpId) then ThroughRegId = CompUpId end -- per ottenere la regione cieca faccio differenza tra sotto e passante if ThroughRegId then EgtSurfFrSubtract( CompDwId, ThroughRegId) if EgtExistsObj( CompDwId) then BlindRegId = CompDwId end else BlindRegId = CompDwId end -- se c'è solo la regione sotto è già quella delle lavorazioni cieche elseif CompDwId then BlindRegId = CompDwId -- se c'è solo la sopra, non interessa e la cancello elseif CompUpId then EgtErase( CompUpId) end -- sistemazioni finali if ThroughRegId then ThroughId = EgtGroup( GDB_ID.ROOT) EgtSetName( ThroughId, 'THROUGH') EgtSetColor( ThroughId, RED()) EgtSetLevel( ThroughId, GDB_LV.TEMP) local nChunk = 0 while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do nChunk = nChunk + 1 end EgtErase( ThroughRegId) --EgtSetName( ThroughRegId, 'THROUGH') --EgtSetColor( ThroughRegId, RED()) --EgtSetLevel( ThroughRegId, GDB_LV.TEMP) end if BlindRegId then BlindId = EgtGroup( GDB_ID.ROOT) EgtSetName( BlindId, 'BLIND') EgtSetColor( BlindId, BLUE()) EgtSetLevel( BlindId, GDB_LV.TEMP) local nChunk = 0 while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do nChunk = nChunk + 1 end EgtErase( BlindRegId) --EgtSetName( BlindRegId, 'BLIND') --EgtSetColor( BlindRegId, BLUE()) --EgtSetLevel( BlindRegId, GDB_LV.TEMP) end end ----------------------------------------------------------------- local function ExecVacVerify( ptVac, dDistVac) -- verifica con le regioni passanti local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL) while nId do local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- se distanza inferiore al limite ... if dDist < dDistVac + 15 then return false end end nId = EgtGetNext( nId) end -- verifica con le regioni cieche nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL) while nId do local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT) if ptNear then local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) + ( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2])) -- se distanza inferiore al limite ... if dDist < dDistVac + 45 then return false end end nId = EgtGetNext( nId) end -- nessuna interferenza return true end ----------------------------------------------------------------- local function EndVacVerify() -- cancello regioni passante e cieca EgtErase( ThroughId or GDB_ID.NULL) ThroughId = nil EgtErase( BlindId or GDB_ID.NULL) BlindId = nil end -------------------------------------------------------------------------------- -- * Abilitazione/disabilitazione geometrie * local function ShowHideGeom( nGroupId, sName, dVal) local nId = EgtGetFirstNameInGroup( nGroupId, sName) if nId then local dOldVal = EgtGetInfo( nId, 'Val', 'd') or 0.1 if dVal ~= dOldVal then if dVal > 0.5 then EgtSetStatus( nId, GDB_ST.ON) else EgtSetStatus( nId, GDB_ST.OFF) end EgtSetInfo( nId, 'Val', dVal) end end end local function SetInfoTable( tListEnt, sNameInfo, nValInfo) for j = 1, #tListEnt do if tListEnt[j] then EgtSetInfo( tListEnt[j], sNameInfo, nValInfo) end end end local function CheckExtSideMach( tListEnt) local sEdgeNote for j = 1, #tListEnt do if tListEnt[j] then sEdgeNote = EgtGetInfo( tListEnt[j], 'EdgeDoor') or '' if sEdgeNote == 'T' then -- se lavorato lato top DGD.MTS = 1 elseif sEdgeNote == 'B' then -- se lavorato lato bottom DGD.MBS = 1 elseif sEdgeNote == 'H' then -- se lavorato lato hinge DGD.MHS = 1 elseif sEdgeNote == 'L' then -- se lavorato lato lock DGD.MLS = 1 end end end end ----------------------------------------------------------------- -- *** Apply Machining by Mach number *** ----------------------------------------------------------------- local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach, sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote, bNotGenMachining, tMachining ) local dOverL = EgtGetInfo( tEndId[1], 'OL') local sKeepBackSet = EgtGetInfo( tEndId[1], 'KeepBackSet') local nOffsetDel = EgtIf( bNotGenMachining, 20, 0) local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0) local sKeepBackSetCode -- determino in base alla disposizione quale codice KeepBackSet dare alla lavorazione if sKeepBackSet and not bNotGenMachining then if (bPush and bFlip) or ( not bPush and not bFlip) then -- se lato narrow è in basso (BD) if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per non correggere Z sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per correggere Z sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) end else -- altrimenti lato narrow è in alto (BU) if sKeepBackSet == 'c' then -- se devo stare in centro allo spessore porta setto per correggere Z di metà valore medio sKeepBackSetCode = 'CORR_Z_PROBE=1' -- codice moltiplicativo del valore di correzione (media/2) elseif sKeepBackSet == 'n' then -- se mantenere su lato narrow, setto per correggere Z sKeepBackSetCode = 'CORR_Z_PROBE=2' -- codice moltiplicativo del valore di correzione (media/2) elseif sKeepBackSet == 'w' then -- se mantenere su lato wide, setto per non correggere Z sKeepBackSetCode = 'CORR_Z_PROBE=0' -- codice moltiplicativo del valore di correzione (media/2) end end end if nMach == 1 then local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) end if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMach) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- verifico se lavorati lati esterni porta CheckExtSideMach(tEndId) end end elseif nMach == 2 then local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) end if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMachUp) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- verifico se lavorati lati esterni porta CheckExtSideMach(tEndId) end end elseif nMach == 3 then local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName, bNotGenMachining, sKeepBackSetCode) if nRes < 0 then -- se la lavorazione ha fallito bOk = false if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end elseif nRes == 0 then -- se lavorazione mancante if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end if bNotGenMachining then -- setto nota per non lavorarla di nuovo nemmeno nella generazione reale SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail) end else -- lavorazione ok if bModifyMacNote then -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) end if bNotGenMachining then nNumMach = nNumMach + 1 -- setto nota per non lavorarla di nuovo SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel) SetInfoTable( tEndId, 'Machining', sMachDw) else if tMachining then table.insert( tMachining,{nMachId,sToolName}) end -- verifico se lavorati lati esterni porta CheckExtSideMach(tEndId) end end end return bOk, nNumMach, tMachining end ----------------------------------------------------------------- -- *** Calc Machining for same group *** ----------------------------------------------------------------- local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach, nNumGroup, nNumMach, bOk ) local nParendId = EgtGetParent(nEndId) local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo local sLocMachId local bNotGenMachining = true -- ordinare lavorazioni navette come scritto su foglio nella documentazione for i = 1, #tLocTable do if tLocTable[i].On ~= 0 then sLocMachId = tLocTable[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name) -- Applico le lavorazioni for j = 1, #EntList do local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1 if tLocTable[i].Oper == 'AdjustHead' and nMachCk > 0 and nMachCk < 10 then -- assegno la stessa nota nMach dell'entità del gruppo EgtSetInfo( EntList[j], 'Mach', nMach) -- duplico entià local nNewEntId = MB.MakeGhostCopy( EntList[j]) -- carico id entità in una tabella local tListSameMach = {} table.insert( tListSameMach, nNewEntId) bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, bNotGenMachining) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end end end end return bOk, nNumMach end ----------------------------------------------------------------- -- *** Add Machining for same group *** ----------------------------------------------------------------- local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup, nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach ) local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo -- ordinare lavorazioni navette come scritto su foglio nella documentazione for i = 1, #tLocTable do -- Recupero le entità local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName) -- Applico le lavorazioni for j = 1, #EntList do local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end if nMachCk > 0 and nMachCk < 10 then local nNewEntId = EntList[j] local sMachining = EgtGetInfo( nNewEntId, 'Machining') if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true) -- se più di 1 entità le ordino if #tListSameMach > 1 then tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach, tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true, GEN_MACH) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end return bOk, nNumMach end ----------------------------------------------------------------- -- *** calc disposition references *** ----------------------------------------------------------------- local function CalcDispositionRef( bLeftPiece, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) local dExtraX, dExtraY, nCorner if DISPMODE > 0 then -- se disposizione a sinistra della tavola if bTopOnRight then -- se top a destra dExtraX = -dBottomOffs if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then nCorner = MCH_CR.BL dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) else nCorner = MCH_CR.TL dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) end else -- se top a sinistra dExtraX = -dTopOffs if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then nCorner = MCH_CR.TL dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) else nCorner = MCH_CR.BL dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) end end else -- altrimenti disposizione a destra della tavola if bTopOnRight then -- se top a destra dExtraX = dTopOffs if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then nCorner = MCH_CR.BR dExtraY = EgtIf( bFlip, -dLeftOffs, -dRightOffs) else nCorner = MCH_CR.TR dExtraY = EgtIf( bFlip, dRightOffs, dLeftOffs) end else -- se top a sinistra dExtraX = dBottomOffs if ( bPush and bLeftPiece) or ( not bPush and not bLeftPiece) then nCorner = MCH_CR.TR dExtraY = EgtIf( bFlip, dLeftOffs, dRightOffs) else nCorner = MCH_CR.BR dExtraY = EgtIf( bFlip, -dRightOffs, -dLeftOffs) end end end return dExtraX, dExtraY, nCorner end ----------------------------------------------------------------- -- *** calc disposition subpieces *** ----------------------------------------------------------------- local function CalcDispositionSubPieces( nNumB, nRowId, bFixSameVac, tsBaseNameVac, tsBaseNamePnt, sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, dLenCalc) local ptPos -- punto posizioni ventose local tbCanUp = {} -- tabella punti controlli barra, gli indici tabella sono i punti di controllo per ogni ventosa local tPosSubPiece = {} local tPosRowSubPieceRow = {} local nCenterId if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then tbCanUp[1] = false -- giusto per far fallire il controllo successivo else -- controllo la ventosa normale nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_1') tbCanUp[1] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt1[nNumB]) -- 41.275 nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_2') ptPos = EgtSP( nCenterId, GDB_ID.ROOT) tbCanUp[2] = ExecVacVerify( ptPos, tdBaseRadiusPnt1[nNumB]) nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt[nNumB]..sInd..'_3') tbCanUp[3] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt1[nNumB]) end -- se fallisce provo con quella piccola if not ( tbCanUp[1] and tbCanUp[2] and tbCanUp[3]) and tnNumVacInsert[nNumB] == 2 then nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_1') tbCanUp[1] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt2[nNumB]) -- 31.750 nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_2') ptPos = EgtSP( nCenterId, GDB_ID.ROOT) tbCanUp[2] = ExecVacVerify( ptPos, tdBaseRadiusPnt2[nNumB]) nCenterId = EgtGetFirstNameInGroup( nRowId, tsBaseNamePnt2[nNumB]..sInd..'_3') tbCanUp[3] = ExecVacVerify( EgtSP( nCenterId, GDB_ID.ROOT), tdBaseRadiusPnt2[nNumB]) -- se anadata a buon fine e la configurazione disposizione è per mantenere uniformi le ventose if tbCanUp[1] and tbCanUp[2] and tbCanUp[3] then tnNumKindVac[nNumB] = 2 if bFixSameVac and string.len( tsBaseNameVac[nNumB]) == 0 then tsBaseNameVac[nNumB] = tsBaseNameVac_2[nNumB] tsBaseNameVacSld[nNumB] = tsBaseNameVacSld_2[nNumB] tdYCommpos[nNumB] = ptPos:getY() end end else -- già la prima è andata bene if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then tnNumKindVac[nNumB] = 2 else tnNumKindVac[nNumB] = 1 end end -- eventuale abilitazione parte fissa if tbCanUp[1] and tbCanUp[2] and tbCanUp[3] then -- se sottopezzo da inserire local nCodVac -- se righe con ventose uniformi if ( bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0) or tnNumKindVac[nNumB] == 2 then nCodVac = 2 elseif tnNumKindVac[nNumB] == 1 then nCodVac = 1 end -- inserisco la ventosa sul fisso tPosSubPiece[1] = ptPos tPosSubPiece[2] = nCodVac tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} -- interrompo le serie negative if nInd > 1 then tnCountFailed[nNumB] = 0 if tnMaxIniFailed[nNumB] < tnIniFailed[nNumB] then tnMaxIniFailed[nNumB] = tnIniFailed[nNumB] end if tnMaxMiddleFailed[nNumB] < tnMiddleFailed[nNumB] then tnMaxMiddleFailed[nNumB] = tnMiddleFailed[nNumB] end if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] end tnIniFailed[nNumB] = 0 tnMiddleFailed[nNumB] = 0 tnEndFailed[nNumB] = 0 end else -- sottopezzo non inserito tPosSubPiece[1] = '' tPosSubPiece[2] = 0 tPosRowSubPieceRow = { tPosSubPiece[1], tPosSubPiece[2]} tnCountFailed[nNumB] = tnCountFailed[nNumB] + 1 if nInd == 1 then -- setto solo il fallimento iniziale tnIniFailed[nNumB] = tnCountFailed[nNumB] elseif nInd == nNumTotVacRow or dLenCalc <= 0 then -- setto solo quello finale e annullo il medio tnEndFailed[nNumB] = tnCountFailed[nNumB] if tnMaxEndFailed[nNumB] < tnEndFailed[nNumB] then tnMaxEndFailed[nNumB] = tnEndFailed[nNumB] end tnMiddleFailed[nNumB] = 0 else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati if tnIniFailed[nNumB] > 0 then tnIniFailed[nNumB] = tnCountFailed[nNumB] elseif tnEndFailed[nNumB] > 0 then tnEndFailed[nNumB] = tnCountFailed[nNumB] - 1 else tnMiddleFailed[nNumB] = tnCountFailed[nNumB] end end end return tPosRowSubPieceRow end ----------------------------------------------------------------- -- *** disposition subpieces *** ----------------------------------------------------------------- local function DispositionSubPieces( nNumB, nIndVac, tPosRowSubPieceRow, bFixSameVac, tsBaseNameVac, tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, tsBaseNameVacSld_2, nIndOri, tabOri, tsNoteRow, nDispId) local tnCodVac = tPosRowSubPieceRow[nIndVac] local sCodVac local sNameV, sNameVSld if tnCodVac then -- se codice presente if tnCodVac[2] == 0 then sCodVac = '0_' else if bFixSameVac and string.len( tsBaseNameVac[nNumB]) > 0 then -- se fissa sulla seconda sNameV = tsBaseNameVac[nNumB] sNameVSld = tsBaseNameVacSld[nNumB] sCodVac = '2_' tnCodVac[1] = Point3d{ tnCodVac[1]:getX(), tdYCommpos[nNumB], tnCodVac[1]:getZ()} elseif tnCodVac[2] == 1 then sNameV = tsBaseNameVac_1[nNumB] sNameVSld = tsBaseNameVacSld_1[nNumB] sCodVac = '1_' elseif tnCodVac[2] == 2 then sNameV = tsBaseNameVac_2[nNumB] sNameVSld = tsBaseNameVacSld_2[nNumB] sCodVac = '2_' end -- inserisco la ventosa sul fisso local sNameVac = EgtIf( fmod( nIndOri, 2) == 1, sNameVSld, sNameV) local nFixVac = EgtAddFixture( sNameVac, ( tnCodVac[1] - tabOri), 0) EgtSetInfo( nDispId, 'POS'..tostring( nNumB)..'_'..tostring( nIndVac), ( tnCodVac[1] - tabOri)) EgtSetInfo( nDispId, 'MOD'..tostring( nNumB)..'_'..tostring( nIndVac), sNameVac) EgtSetInfo( nDispId, 'COD'..tostring( nNumB)..'_'..tostring( nIndVac), sCodVac) end tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. sCodVac, sCodVac .. tsNoteRow[nNumB]) else tsNoteRow[nNumB] = EgtIf( DISPMODE > 0, tsNoteRow[nNumB] .. '0_', '0_' .. tsNoteRow[nNumB]) EgtRemoveInfo( nDispId, 'POS'..tostring( nNumB)..'_'..tostring( nIndVac)) EgtRemoveInfo( nDispId, 'MOD'..tostring( nNumB)..'_'..tostring( nIndVac)) EgtRemoveInfo( nDispId, 'COD'..tostring( nNumB)..'_'..tostring( nIndVac)) end end local function CheckEnoughVacuums( nInd, nIdVac, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, bUseOnly2Bars) local bOk = true local sMess = '' if nIdVac == 0 then -- se codice per porta if bUseOnly2Bars then -- in caso di due barre, inferiore e media if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd)) then -- tutte le ventose basse sMess = ' ' .. EgtDoorsMsg[531] bOk = false elseif nInd > 0 and ( tnMaxIniFailed[1] / nInd > 0.25) and ( tnMaxIniFailed[2] / nInd > 0.25) then -- ventose iniziali ( parte sinistra) local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and ( tnMaxMiddleFailed[2] / nInd > 0.45) then -- ventose centrali sMess = ' ' .. EgtDoorsMsg[533] bOk = false elseif nInd > 0 and ( tnMaxEndFailed[1] / nInd > 0.25) and ( tnMaxEndFailed[2] / nInd > 0.25) then -- ventose finali ( parte destra) local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) then -- somma di vari intervalli sMess = ' ' .. EgtDoorsMsg[531] bOk = false end else -- casi di scarse ventose: solo per le file esterne, quella centrale non la considero perchè è capitato che -- la porta rimaneva su solo per la fila centrale if nInd > 0 and (( tnMaxIniFailed[1] == nInd or tnMaxMiddleFailed[1] == nInd or tnMaxEndFailed[1] == nInd) or -- ( tnMaxIniFailed[2] == nInd or tnMaxMiddleFailed[2] == nInd or tnMaxEndFailed[2] == nInd) or ( tnMaxIniFailed[3] == nInd or tnMaxMiddleFailed[3] == nInd or tnMaxEndFailed[3] == nInd)) then -- tutte le ventose basse sMess = ' ' .. EgtDoorsMsg[531] bOk = false elseif nInd > 0 and ( tnMaxIniFailed[1] / nInd > 0.25) and -- ( tnMaxIniFailed[2] / nInd > 0.25) and ( tnMaxIniFailed[3] / nInd > 0.25) then -- ventose iniziali ( parte sinistra) local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif nInd > 0 and ( tnMaxMiddleFailed[1] / nInd > 0.45) and -- ( tnMaxMiddleFailed[2] / nInd > 0.45) and ( tnMaxMiddleFailed[3] / nInd > 0.45) then -- ventose centrali sMess = ' ' .. EgtDoorsMsg[533] bOk = false elseif nInd > 0 and ( tnMaxEndFailed[1] / nInd > 0.25) and -- ( tnMaxEndFailed[2] / nInd > 0.25) and ( tnMaxEndFailed[3] / nInd > 0.25) then -- ventose finali ( parte destra) local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif (( tnMaxIniFailed[1] + tnMaxMiddleFailed[1] + tnMaxEndFailed[1]) >= nInd/2) and -- (( tnMaxIniFailed[2] + tnMaxMiddleFailed[2] + tnMaxEndFailed[2]) >= nInd/2) and (( tnMaxIniFailed[3] + tnMaxMiddleFailed[3] + tnMaxEndFailed[3]) >= nInd/2) then -- somma di vari intervalli sMess = ' ' .. EgtDoorsMsg[531] bOk = false end end else -- altrimenti frame -- casi di scarse ventose: solo per la fila 1 if nInd > 0 and ( tnMaxIniFailed[nIdVac] == nInd or tnMaxMiddleFailed[nIdVac] == nInd or tnMaxEndFailed[nIdVac] == nInd) then sMess = ' ' .. EgtDoorsMsg[531] bOk = false elseif nInd > 0 and ( tnMaxIniFailed[nIdVac] / nInd > 0.25) then local nNumMsg = EgtIf( DISPMODE > 0, 532, 534) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif nInd > 0 and ( tnMaxMiddleFailed[nIdVac] / nInd > 0.45) then sMess = ' ' .. EgtDoorsMsg[533] bOk = false elseif nInd > 0 and ( tnMaxEndFailed[nIdVac] / nInd > 0.25) then local nNumMsg = EgtIf( DISPMODE > 0, 534, 532) sMess = ' ' .. EgtDoorsMsg[nNumMsg] bOk = false elseif (( tnMaxIniFailed[nIdVac] + tnMaxMiddleFailed[nIdVac] + tnMaxEndFailed[nIdVac]) >= nInd/2) then sMess = ' ' .. EgtDoorsMsg[531] bOk = false end end return bOk, sMess end local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer) -- Box solido: lo ottengo dalla somma delle varie superfici della porta local tListFaces = {} if nProbeMode == 2 then table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2')) else table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW')) end table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT')) table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP')) -- aggiungo anche il layer AUX escludendo il testo if nAuxLayer then local nIdGeom = EgtGetFirstInGroup(nAuxLayer) local nTypeEnt while nIdGeom do -- se elemento passato è un testo lo escludo nTypeEnt = EgtGetType( nIdGeom) if nTypeEnt ~= GDB_TY.EXT_TEXT then table.insert( tListFaces, nIdGeom) end nIdGeom = EgtGetNext(nIdGeom) end end local b3fx = BBox3d() -- inizializzo il box nullo for i = 1, #tListFaces do if tListFaces[i] then local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.STANDARD) b3fx:Add(b3f1) end end return b3fx end ----------------------------------------------------------------- -- *** Funzione di generazione lavorazioni *** ----------------------------------------------------------------- function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup) -- macchina e tabella di default -- tabella parametri d'uso per variabili CurrcamInfo tMainTabPar = {} -- Machine name tMainTabPar.MN = 'Multiax-' -- id 1 -- Machinings Table local MachiningsTable = 'MachStdTable' local MachiningsTableOrd = 'MachStdTable_Ord' -- References on table (respect Zero machine) -- Y Table -- shift value local vShift = Vector3d(0,0,0) local vShiftVac = Vector3d(0,0,0) local vNullShift = Vector3d(0,0,0) -- utilizzo la tabella dati cam local sPathCurrMachtabOri = 'CurrCamInfo' local mCamData = require( sPathCurrMachtabOri) -- resetto la macchinata (riporto il pezzo in area disegno) EgtResetCurrMachGroup() -- elimino percorsi eventualmente creati dal Mach -- cancello i percorsi ghost e tutti i percorsi di sgrossatura local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end -------------------------------------------------------------------------------- -- Dati del pezzo (porta, frame) local tsProperties = {} local sCode, sSwing, sSecure, sHingeTrim, sLockTrim, sTopTrim, sBottomTrim local dWidthDoor, dLengthDoor, dThickDoor, dRadiusPrf, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs local bHingeMach, bLockMach, bTopMach, bBottomMach, bAtRight, bSwingDriveDisp local nProbeMode -- Box pezzo local Ls local Aux local b3Part, b3Solid local tb3Part = {} local tb3Solid = {} -- Project path, name, extension local sFilePath = EgtGetCurrFilePath() local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath) -- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi -- sFileName = sCode local sErrFile = sFileDir .. sFileName .. '.txt' -------------------------------------------------------------------------------- -- variabili CAM local TAB local MachinesName -- *** settaggi CAM *** -- Mtable 2 local TABORD -------------------------------------------------------------------------------- -- variabili sottopezzi local nTabId, nMobId1, nMobId2, nFixId, nDispId local dFixval, dOldVal, dNewVal_2, dNewVal_1, dCalcLen, nIndexPin -------------------------------------------------------------------------------- -- assegnazione variabili CurrCamInfo -- imposto i dati macchina secondo le informazioni del file cam tMainTabPar.MN = mCamData[nNumMachFromCam].MachName -- id 1 MachName tMainTabPar.MxDL = mCamData[nNumMachFromCam].MaxDoorLength -- id 2 dMaxDoorLength tMainTabPar.MnDL = mCamData[nNumMachFromCam].MinDoorLength -- id 3 dMinDoorLength tMainTabPar.MxDW = mCamData[nNumMachFromCam].MaxDoorWidth -- id 4 dMaxDoorWidth tMainTabPar.MnDW = mCamData[nNumMachFromCam].MinDoorWidth -- id 5 dMinDoorWidth tMainTabPar.MxDT = mCamData[nNumMachFromCam].MaxDoorThick -- id 6 dMaxDoorThick tMainTabPar.MnDT = mCamData[nNumMachFromCam].MinDoorThick -- id 7 dMinDoorThick tMainTabPar.MxJL = mCamData[nNumMachFromCam].MaxJambLength -- id 8 dMaxJambLength tMainTabPar.MnJL = mCamData[nNumMachFromCam].MinJambLength -- id 9 dMinJambLength tMainTabPar.MxJW = mCamData[nNumMachFromCam].MaxJambWidth -- id 10 dMaxJambWidth tMainTabPar.MnJW = mCamData[nNumMachFromCam].MinJambWidth -- id 11 dMinJambWidth tMainTabPar.MxJT = mCamData[nNumMachFromCam].MaxJambThick -- id 12 dMaxJambThick tMainTabPar.MnJT = mCamData[nNumMachFromCam].MinJambThick -- id 13 dMinJambThick tMainTabPar.AR = mCamData[nNumMachFromCam].dAltRef -- id 14 dAltRef tMainTabPar.TR = mCamData[nNumMachFromCam].dTallRef -- id 15 dTallRef tMainTabPar.LS = mCamData[nNumMachFromCam].sLocSecure -- id 16 sLocSecure tMainTabPar.MOM = mCamData[nNumMachFromCam].MaxOverMat -- id 17 dMaxOverMat tMainTabPar.SOM = mCamData[nNumMachFromCam].StepOverMat or 10 -- id 18 dStepOverMat tMainTabPar.TDD = mCamData[nNumMachFromCam].TopSideDriveDisp -- id 19 nTopSideDriveDisp tMainTabPar.MDC = mCamData[nNumMachFromCam].MaxDistToChain -- id 20 dMaxDistToChain tMainTabPar.FPB = mCamData[nNumMachFromCam].FramePosBar -- id 21 dPosBarForJamb tMainTabPar.FVR = mCamData[nNumMachFromCam].nFixSameVacOnRaw == 1 -- id 22 bFixSameVac tMainTabPar.ETM = mCamData[nNumMachFromCam].ExtraThruDepthMachining -- id 23 dExtraThruDepth tMainTabPar.OR1 = mCamData[nNumMachFromCam].Ori1 -- id 24 Ori1 tMainTabPar.OR2 = mCamData[nNumMachFromCam].Ori2 -- id 25 Ori2 tMainTabPar.OR1f = mCamData[nNumMachFromCam].Ori1f -- id 26 Ori1f tMainTabPar.OR2f = mCamData[nNumMachFromCam].Ori2f -- id 27 Ori2f tMainTabPar.OR3f = mCamData[nNumMachFromCam].Ori3f -- id 28 Ori3f tMainTabPar.OR4f = mCamData[nNumMachFromCam].Ori4f -- id 29 Ori4f tMainTabPar.OR5f = mCamData[nNumMachFromCam].Ori5f -- id 30 Ori5f tMainTabPar.OR6f = mCamData[nNumMachFromCam].Ori6f -- id 31 Ori6f tMainTabPar.SH1 = mCamData[nNumMachFromCam].Shift1 -- id 32 vShiftAct tMainTabPar.SHL = mCamData[nNumMachFromCam].ShiftLck -- id 33 vShiftLockSide not used tMainTabPar.DVL = mCamData[nNumMachFromCam].dDistanceVacLeft -- id 34 new tMainTabPar.DVR = mCamData[nNumMachFromCam].dDistanceVacRight -- id 35 new tMainTabPar.EZPB = mCamData[nNumMachFromCam].dExtraZedProbeBevels -- id 36 new tMainTabPar.P2P1 = mCamData[nNumMachFromCam].sProperty_1 -- id 37 name property 1 (skinned) tMainTabPar.P2P2 = mCamData[nNumMachFromCam].sProperty_2 -- id 38 name property 2 (extruded) DISPMODE = mCamData[nNumMachFromCam].SideDoorDispose or DISPMODE -- SideDoorDispose -------------------------------------------------------------------------------- local MTable, MTableOrd local sLocMachId local bOk = true local bFirstStep = true local bShiftMchng = false local bSmallShiftedDoor = false local sDispMode local sNotePhase local sTotDispMode = '' local sNumGroup = '' local bGenFirstStep = false local nIndexStartMach = 1 local bWork = true local sIdList = '' -- variabili utilizzate dentro al ciclo local nMchId local sTab local tabOri local Ori local ColA local nRaw local tnRaw = {} local bMoveRaw local bTopOnRight local bFrame -- variabili per disposizione sottopezzi local dMobOffs1 local dMobOffs2 -- local dVacOffs -- ridondante local dDistMinX local dDistMaxX local dVacOn local dInterAx local dMinDistGroup local bUseOnly2Bars local OffsXSovr = 0 local OffsYSovr = 0 -- variabile per tool setup local bSetUp local MSetup local sSetup local tListError local sListTool -- variabili calcolo box local b3SolidPiece = {} local b3SolidPiece2 = {} local b3SolidOnTab local pMin local pMinRecalc local pMax local dOffsX = 0 local dOffsY = 0 -- variabili conteggio lavorazioni profilatura bevel e saltate local nNumMachSkip = 0 local bLocMach local tsMachProf = {} local bNoVertProf = true local bWorkUnder = true -- variabile per conteggio lavorazioni local nNumMach = 0 local nNumSkip local tSecMachTab = {} local tSecMachTabOrd = {} -- variabili per fase local nNumPhase local nNumCycle = 1 -- variabili per gestione ripresa porta local bFlipFirst local bTopOnRightFirst local sProfiles = '' local nNumGeomBottom = 0 local nNumGeomTop = 0 local pDistToMove local dAngleToAlign = 0 -- variabile proprietà speciale local nNumProperties = 0 -- tabella lavorazioni local tLocMach = {} local tLocMachOrd = {} -- Set Current Machine: si setta sulla fase 1 EgtSetCurrMachine( tMainTabPar.MN) -- raccolgo gli id dei pezzi for v = 1, #tPz do sIdList = sIdList .. '_' .. EgtNumToString(tPz[v],0) end local bEnBreak = false -- faccio tutte le fasi while bWork do -- per ogni pezzo passato for v = 1, #tPz do Pz = tPz[v] sAssemb = tsAssemb[v] -- assegnamento variabili bFrame = sAssemb and string.find( sAssemb, 'frame') == 1 Ls = EgtGetFirstNameInGroup( Pz, 'SOLID') Aux = EgtGetFirstNameInGroup( Pz, 'AUX') sCode = EgtGetInfo( Pz, 'Code') dWidthDoor = EgtGetInfo( Pz, 'W', 'd') dLengthDoor = EgtGetInfo( Pz, 'H', 'd') dThickDoor = EgtGetInfo( Pz, 'T', 'd') sSwing = EgtGetInfo( Pz, 'Swing') sSecure = EgtGetInfo( Pz, 'Secure') tsProperties = EgtSplitString( EgtGetInfo( Pz, 'Properties') or '') sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming') sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming') sTopTrim = EgtGetInfo( Pz, 'top_trimming') sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming') bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b') bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b') bTopMach = EgtGetInfo( Pz, 'top_machining', 'b') bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b') bAtRight = ( sSwing:sub(1,1) == 'L') -- flag settato a vero se serratura a destra bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' ) dRadiusPrf = EgtGetInfo( Pz, 'RadHingeProfile', 'd') nProbeMode = EgtGetInfo( Pz, 'ProbeMode', 'i') or 0 dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0 dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0 dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0 dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0 if bFirstStep and not bShiftMchng then -- determino se la porta ha speciali proprietà if MB.FindProperties ( tsProperties, tMainTabPar.P2P1) then nNumProperties = 1 -- per skinned elseif MB.FindProperties ( tsProperties, tMainTabPar.P2P2) then nNumProperties = 2 -- per extruded -- se sono in modalità lavorazione porta ricostruita, -- riassegno la probemode per far elaborare la porta in modalità normale if nProbeMode == 2 then nProbeMode = 0 end end -- ottengo la tabella corrente del primo pezzo MachiningsTable = EgtGetInfo( tPz[1], 'MTable') -- Box pezzo table.insert( tb3Part, v, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) local b3fx = BBox3d() -- inizializzo il box nullo b3fx = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) table.insert( tb3Solid, v, b3fx) -- table.insert( tb3Solid, v, EgtGetBBoxGlob( Ls, GDB_BB.STANDARD)) end -- assegno i box del pezzo b3Part = tb3Part[v] b3Solid = tb3Solid[v] if v == 1 then -- solo il primo pezzo if bFirstStep and not bShiftMchng then -- *** settaggi CAM *** -- Mtable 1 if not MachiningsTable then -- se non c'è il nome della MTable esco DGD.ERR = 26 local sErrMess = string.format(EgtDoorsMsg[597], MachiningsTable) DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl') if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then TAB = require( MachiningsTable) if not TAB then DGD.ERR = 27 local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end else DGD.ERR = 28 local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end MachinesName = TAB.MMachineData if not MachinesName then DGD.ERR = 29 local sErrMess = string.format(EgtDoorsMsg[491], '') DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- Errore! Nome macchina: non presente in MTable if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end -- *** settaggi CAM *** -- Mtable 2 MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0) EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl') if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then TABORD = require( MachiningsTableOrd) if not TABORD then DGD.ERR = 30 local sErrMess = string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore tabella non trovata nel file -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end else DGD.ERR = 31 local sErrMess = string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore, file di tabella non trovato -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end -- se non devo generare il cn esco subito if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then DoorOutLog( string.format(EgtDoorsMsg[492], tMainTabPar.MN), 0) -- warning. Cnc generation disable return true end -- se dimensioni porta incompatibili per collisione con aggregato attrezzato sulla tavola if ( dLengthDoor > (97.5*25.4) and dWidthDoor > (42.9*25.4)) or (dLengthDoor > (118*25.4) and dWidthDoor > (22.5*25.4)) then DGD.ERR = 35 local sErrMess = "Error! Door length and width exceded and there is a risk of collision by 5axis head with table aggregate" DGD.EMC = DGD.EMC .. '\n' .. sErrMess WriteErrFile( sFileDir..sFileName..'.txt') DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) DoorOutLog( sErrMess, 0) -- errore -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then EgtOutBox( sErrMess, EgtDoorsMsg[476], EgtDoorsMsg[477]) end return false end MTable = TAB.MTable MTableOrd = TABORD.MTable end end -- se è un frame if bFrame then -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi local bFailDim = false local sErrMess = '' if dLengthDoor < tMainTabPar.MnJL then -- se lunghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[623], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MnJL)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dLengthDoor > tMainTabPar.MxJL then -- se lunghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[623], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MxJL)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dWidthDoor < tMainTabPar.MnJW then -- se larghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[623], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MnJW)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dWidthDoor > tMainTabPar.MxJW then -- se larghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[623], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MxJW)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dThickDoor < tMainTabPar.MnJT then -- se spessore inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[623], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MnJT)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dThickDoor > tMainTabPar.MxJT then -- se spessore superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[623], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MxJT)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if bFailDim then DGD.ERR = 19 -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..'.txt') -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( DGD.EMC, 0) DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) EgtOutBox( DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation end return false end else -- è una porta -- controllo se le dimensioni porta sono compresi nei valori minimi e massimi local bFailDim = false local sErrMess = '' if dLengthDoor < tMainTabPar.MnDL then -- se lunghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MnDL)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dLengthDoor > tMainTabPar.MxDL then -- se lunghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(tMainTabPar.MxDL)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dWidthDoor < tMainTabPar.MnDW then -- se larghezza inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MnDW)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dWidthDoor > tMainTabPar.MxDW then -- se larghezza superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(tMainTabPar.MxDW)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dThickDoor < tMainTabPar.MnDT then -- se spessore inferiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MnDT)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if dThickDoor > tMainTabPar.MxDT then -- se spessore superiore bFailDim = true sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(tMainTabPar.MxDT)) if #DGD.EMC > 0 then DGD.EMC = DGD.EMC .. '\n'.. sErrMess else DGD.EMC = sErrMess end end if bFailDim then DGD.ERR = 19 -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..'.txt') -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( DGD.EMC, 0) DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) EgtOutBox( DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation end return false end end sDispMode = '' if bFirstStep and not bShiftMchng then if v == 1 then nNumGroup = nNumGroup + 1 end -- Set Machining Group if not sAssemb then -- se pezzo unico nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) else -- creo gruppo lavooro if v == 1 then nMchId = EgtAddMachGroup( 'Ids'.. sIdList ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. tMainTabPar.MN) end end nNumPhase = EgtGetCurrPhase() else if v == 1 then -- se nessuna lavorazione riutilizzo la vecchia fase if nNumMach == 0 then -- elimino i vecchi grezzi for t = 1, #tnRaw do EgtRemoveRawPart( tnRaw[t]) -- elimino il grezzo end -- elimino la disposizione dei sottopezzi local nNumFix = EgtGetFirstFixture() while nNumFix do EgtRemoveFixture( nNumFix) nNumFix = EgtGetFirstFixture() end else nNumPhase = EgtAddPhase() -- creo nuova fase end end -- rendo corrente la fase if nNumPhase then EgtSetCurrPhase(nNumPhase) end end ----------------------------------------------------------------------- -- Calcolo dei sovramateriali e definizione e posizionamento del grezzo ----------------------------------------------------------------------- if bFirstStep and not bShiftMchng then -- se check macchina settato per non gestire grezzo if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then dLeftOffs = 0 dRightOffs = 0 dTopOffs = 0 dBottomOffs = 0 end else -- fase successiva ribaltata o spostata -- i profili con lavorazione disabilitata li posso mettere subito a zero if ( not bLockMach and bAtRight) or ( not bHingeMach and not bAtRight) then -- lavorazione lato destro disabilitata dRightOffs = 0 end if ( not bLockMach and not bAtRight) or ( not bHingeMach and bAtRight) then -- lavorazione lato sinistro disabilitata dLeftOffs = 0 end if not bTopMach then -- lavorazione lato top disabilitata dTopOffs = 0 end if not bBottomMach then -- lavorazione lato top disabilitata dBottomOffs = 0 end -- azzero i sovramateriali dei profili che sono stati lavorati if tsMachProf and string.len( tsMachProf[v]) > 0 then local sListProf = EgtSplitString( tsMachProf[v], ',') for m = 1, #sListProf do if string.lower( sListProf[m]) == 'left' then dLeftOffs = 0 elseif string.lower( sListProf[m]) == 'right' then dRightOffs = 0 elseif string.lower( sListProf[m]) == 'top' then dTopOffs = 0 elseif string.lower( sListProf[m]) == 'bottom' then dBottomOffs = 0 end end end end -- se sono in ribaltamento e in rebuild della porta devo ruotare la porta -- con il lato opposto parallelo a Y (prima della disposizione) if not bFirstStep and nProbeMode == 2 then local nRecId = EgtGetFirstNameInGroup( Pz, 'REC') local nSideToAlign local sSideToAlign local nSideToAlignMid local sSideToAlignMid local nSideToAlignTop local sSideToAlignTop local bInvert if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then sSideToAlign = 'Right' sSideToAlignMid = 'RightMid' sSideToAlignTop = 'RightTop' bInvert = false else sSideToAlign = 'Left' sSideToAlignMid = 'LeftMid' sSideToAlignTop = 'LeftTop' bInvert = true end nSideToAlign = EgtGetFirstNameInGroup( nRecId, sSideToAlign) nSideToAlignMid = EgtGetFirstNameInGroup( nRecId, sSideToAlignMid) nSideToAlignTop = EgtGetFirstNameInGroup( nRecId, sSideToAlignTop) local vVectorToAlign if nSideToAlign then if bInvert then vVectorToAlign = EgtSV( nSideToAlign) dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) - 180 else vVectorToAlign = EgtSV( nSideToAlign) dAngleToAlign = atan(vVectorToAlign:getX(),vVectorToAlign:getY()) end -- allineo il pezzo prendendo il riferimento del lato opposto al lato riferito nella prima fase EgtRotate( Pz , ORIG(), Z_AX(), dAngleToAlign ) -- muovo la porta nelle origini if ( bFlipFirst and bTopOnRightFirst) or ( not bFlipFirst and not bTopOnRightFirst) then -- lato allineato right if bAtRight then -- se serratura a destra if sLockTrim == 'BD' or sLockTrim == 'BU' then -- se profilo bevel if bPush then -- se porta a spingere prendo come riferimento lato bottom pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato top pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) end elseif sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato medio pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) end else if sHingeTrim == 'BD' or sHingeTrim == 'BU' then -- se profilo bevel if bPush then -- se porta a spingere prendo come riferimento lato bottom pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato top pDistToMove = EgtSP(nSideToAlignTop, GDB_ID.ROOT) end elseif sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) pDistToMove = EgtSP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato medio pDistToMove = EgtSP(nSideToAlignMid, GDB_ID.ROOT) end end else -- lato allineato left if bAtRight then -- se serratura a destra if sHingeTrim == 'BD' or sHingeTrim == 'BU' then -- se profilo bevel if bPush then -- se porta a spingere prendo come riferimento lato bottom pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato top pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) end elseif sHingeTrim == 'CV' then -- prendo riferimento da lato bottom (o top) pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato medio pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) end else if sLockTrim == 'BD' or sLockTrim == 'BU' then -- se profilo bevel if bPush then -- se porta a spingere prendo come riferimento lato bottom pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato top pDistToMove = EgtEP(nSideToAlignTop, GDB_ID.ROOT) end elseif sLockTrim == 'CV' then -- prendo riferimento da lato bottom (o top) pDistToMove = EgtEP(nSideToAlign, GDB_ID.ROOT) else -- prendo riferimento da lato medio pDistToMove = EgtEP(nSideToAlignMid, GDB_ID.ROOT) end end end -- muovo il pezzo sull'origine EgtMove( Pz, ORIG() - Point3d( pDistToMove:getX(), pDistToMove:getY(), 0), GDB_RT.GLOB) -- ricalcolo il box del solido b3Solid = MakeBoxFromSolidLayer( Ls, nProbeMode, Aux) -- ricalcolo il box del pezzo b3Part = EgtGetBBoxGlob( Pz, GDB_BB.STANDARD) end -- bEnBreak = true -- bWork = false -- break end if bFirstStep then table.insert( b3SolidPiece, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) else table.insert( b3SolidPiece2, EgtGetBBoxGlob( Pz, GDB_BB.STANDARD)) end if b3SolidPiece[v] and b3SolidPiece2[v] and nProbeMode ~= 2 then dOffsX = b3SolidPiece2[v]:getMin():getX() - b3SolidPiece[v]:getMin():getX() dOffsY = b3SolidPiece2[v]:getMin():getY() - b3SolidPiece[v]:getMin():getY() else dOffsX = 0 dOffsY = 0 end ColA = Color3d( 255, 165, 0, 25) nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs, b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA) table.insert( tnRaw, v, nRaw) EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs + dOffsX, dBottomOffs + dOffsY, 0), nRaw) if not bFirstStep and nProbeMode == 2 then -- contromovimento e controrotazione del pezzo per riportarlo nelle condizioni originarie EgtResetCurrMachGroup() EgtMove( Pz, Point3d( pDistToMove:getX(), pDistToMove:getY(), 0) - ORIG(), GDB_RT.GLOB) EgtRotate( Pz , ORIG(), Z_AX(), -dAngleToAlign ) EgtSetCurrMachGroup() EgtSetCurrPhase(nNumPhase) end -- if nProbeMode == 2 then if bFirstStep and nProbeMode == 2 then local dtempX = EgtIf( abs(b3Solid:getMin():getX()) < abs(b3Solid:getMax():getX()), b3Solid:getMin():getX(), b3Solid:getMax():getX()) local dtempY = EgtIf( abs(b3Solid:getMin():getY()) < abs(b3Solid:getMax():getY()), b3Solid:getMin():getY(), b3Solid:getMax():getY()) pMinRecalc = Point3d( dtempX, dtempY, 0) else pMinRecalc = Point3d( 0, 0, 0) end -- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe, -- decido su quale lato disporre la porta per evitae inutili ribaltamenti -- ricavo minimo e massimo del solido del pezzo b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) pMin = b3SolidOnTab:getMin() pMax = b3SolidOnTab:getMax() if v == 1 then -- solo il primo pezzo if bFirstStep then tLocMach = MTable tLocMachOrd = MTableOrd if not bShiftMchng then nIndexStartMach = 1 end else tLocMach = tSecMachTab tLocMachOrd = MTableOrd if not bShiftMchng then nIndexStartMach = 1 end end end if bFirstStep and not bShiftMchng then tsMachProf[v] = '' end if v == #tPz then -- solo all'ultimo pezzo -- solo il primo giro, prendo nota dei profili tipo bevel -- verifico se cave da sotto o da sopra -- verifico se trovate lavorazioni applicate con 'shift' if bFirstStep and not bShiftMchng then local nUnderGeom local tGeomThruUp = {} local tGeomThruDw = {} local tGeomBlindUp = {} local tGeomBlindDw = {} for i = 1, #tLocMach do if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId -- se non c'è il campo macchina setto di default la 1 if not sLocMachId then sLocMachId = 1 end -- se macchina corrispondente if sLocMachId == nNumMachFromTable then -- prendo i profili bevel direttamente dalla tabella local sUpperProfName = string.upper(tLocMach[i].Name) if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then if not string.find( sProfiles, sUpperProfName) then sProfiles = sProfiles .. sUpperProfName .. ',' end end -- Recupero le entità local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) -- se è una porta if not bFrame then -- se flag non ancora settato e trovata geometria e l'associazione è shiftata .. -- setto il flag di disposizione iniziale Traslata if not bSmallShiftedDoor and #EntList > 0 and tLocMach[i].Shift and tLocMach[i].Shift > 0 then bSmallShiftedDoor = true end end -- Test delle lavorazioni for j = 1, #EntList do local nTypeGeom = 0 -- OPERAZIONI if tLocMach[i].Oper == 'AdjustThrouIsle' then bLocMach, nUnderGeom, nTypeGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) if bLocMach then if nUnderGeom and nUnderGeom == 1 then nNumGeomBottom = nNumGeomBottom + 1 elseif nUnderGeom and nUnderGeom == -1 then nNumGeomTop = nNumGeomTop + 1 end end if nTypeGeom == 1 then -- se passante up table.insert( tGeomThruUp, EntList[j]) elseif nTypeGeom == 2 then -- se passante dw table.insert( tGeomThruDw, EntList[j]) elseif nTypeGeom == 3 then -- se cieca up table.insert( tGeomBlindUp, EntList[j]) elseif nTypeGeom == 4 then -- se cieca dw table.insert( tGeomBlindDw, EntList[j]) end elseif tLocMach[i].Oper == 'AdjustVertHole' then bLocMach, nUnderGeom, nTypeGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder) if bLocMach then if nUnderGeom and nUnderGeom == 1 then nNumGeomBottom = nNumGeomBottom + 1 elseif nUnderGeom and nUnderGeom == -1 then nNumGeomTop = nNumGeomTop + 1 end end if nTypeGeom == 1 then -- se passante up table.insert( tGeomThruUp, EntList[j]) elseif nTypeGeom == 2 then -- se passante dw table.insert( tGeomThruDw, EntList[j]) elseif nTypeGeom == 3 then -- se cieca up table.insert( tGeomBlindUp, EntList[j]) elseif nTypeGeom == 4 then -- se cieca dw table.insert( tGeomBlindDw, EntList[j]) end elseif tLocMach[i].Oper == 'AdjustBevel' then table.insert( tGeomThruUp, EntList[j]) elseif tLocMach[i].Oper == 'AdjustThrouCurve' then table.insert( tGeomThruUp, EntList[j]) elseif tLocMach[i].Oper == 'AdjPrfThrouCurve' then table.insert( tGeomThruUp, EntList[j]) end end end end end -- in base al tipo e al numero geometrie, vedo se invertire une sola geometria if #tGeomThruUp == 1 and #tGeomBlindUp == 0 and #tGeomBlindDw > 1 then -- se condizione per invertire l'unica geometria UP MB.InvertGeom(tGeomThruUp[1]) end if #tGeomThruDw == 1 and #tGeomBlindDw == 0 and #tGeomBlindUp > 1 then -- se condizione per invertire l'unica geometria UP MB.InvertGeom(tGeomThruDw[1]) end elseif not bFirstStep and not bShiftMchng then -- se porta ribaltata for i = 1, #tLocMach do if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId -- se non c'è il campo macchina setto di default la 1 if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithName( tPz, tLocMach[i].Name) -- se è una porta if not bFrame then -- se flag non ancora settato e trovata geometria e l'associazione è shiftata -- setto il flag di disposizione iniziale Traslata if not bSmallShiftedDoor and #EntList > 0 and tLocMach[i].Shift and tLocMach[i].Shift > 0 then bSmallShiftedDoor = true end end end end end end -- se porta da disposrre subito traslata setto i flag if bSmallShiftedDoor then bShiftMchng = true -- porta traslata bGenFirstStep = true -- flag per saltare il primo giro end end ----------------------- -- *** Disposizione *** ----------------------- if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or sSwing == 'LH' or sSwing == 'LHI' or sSwing == 'LHA' then bPush = true else bPush = false end if v == 1 then -- solo il primo pezzo -- Scelta della tavola sTab = 'Tab' EgtSetTable( sTab) -- Origine tavola corrente rispetto a Zero macchina tabOri = EgtGetTableRef( 1) end -- Rotazione porta in base alla macchina bMoveRaw = false local nCodeVacDisp = 0 -- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf -- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello. -- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge -- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf -- se non c'è il parametro considero la porta come se avesse bevel down -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) local sNumPhase if nNumPhase and nNumPhase < 10 then sNumPhase = '0'.. tostring( nNumPhase) elseif nNumPhase then sNumPhase = tostring( nNumPhase) else sNumPhase = '0' end if bFirstStep then local bOkDisp = false if bFrame then bOkDisp = true bFlip = false bTopOnRight = CalcTopPosition( tMainTabPar.TDD, not bAtRight) if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto if bPush then bTopOnRight = not bTopOnRight end elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso if bPush then bTopOnRight = not bTopOnRight end end else -- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura, -- se non ha bevel nemmeno il lato serratura considero il parametro secure if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then -- se profilo cerniera indicato bevel -- verifico se i profili risultanti sono presenti in tabella if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti if ( sHingeTrim == 'BD' and bPush) or ( sHingeTrim == 'BU' and not bPush) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end -- se profilo serratura indicato bevel (e da lavorare) if ( sLockTrim == 'BD' or sLockTrim == 'BU') and not bOkDisp then -- verifico se i profili risultanti sono presenti in tabella if sLockTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true elseif sLockTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sLockTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then bOkDisp = true elseif sLockTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then bOkDisp = true end if bOkDisp then -- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing -- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti if ( sLockTrim == 'BD' and bPush) or ( sLockTrim == 'BU' and not bPush) then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing -- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end end end end -- in caso non ci sia nessun profilo bevel verifico il parametro Secure if not bOkDisp then -- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore if sSecure and string.upper(sSecure) == '0' then -- se parametro da CurrcamInfo non è valido do errore if not tMainTabPar.LS or ( string.upper(tMainTabPar.LS) ~= 'UP' and string.upper(tMainTabPar.LS) ~= 'DN') then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[590] break else sSecure = tMainTabPar.LS end end -- se lato secure va sopra il ribaltamento è obbligato if sSecure and string.upper(sSecure) == 'UP' then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end elseif sSecure and string.upper(sSecure) == 'DN' then bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end -- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) qualla di considerare la porta bevel down -- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata -- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData) else if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing -- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down if bPush then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end -- se porta a tirare non la ribalto perchè si presta già ad essere bevel down else bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end end else -- in base alle geometrie trovate ribalto o meno la porta if nNumGeomBottom > nNumGeomTop then bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end elseif nNumGeomTop >= nNumGeomBottom then bFlip = false if bAtRight then -- se serratura a destra bTopOnRight = false else bTopOnRight = true end else -- altrimenti vecchio metodo bFlip = true if bAtRight then -- se serratura a destra bTopOnRight = true else bTopOnRight = false end end end end end --[[ metodo precedente: lato hinge sempre davanti e lato top decide se sempre destra o sinistra -- setto il lato top dove va a finire bTopOnRight = CalcTopPosition( tMainTabPar.TDD, bAtRight) -- in base alla posizione del top calcolo se ribaltare la porta per avere il lato cerniere sul davanti if (bTopOnRight and bAtRight) or ( not bTopOnRight and not bAtRight) then -- se top a destra bFlip = true else bFlip = false end end ]]-- -- Scelta dell'origine (ora espressa rispetto Zero Tavola) if sAssemb == 'framesx' then if bPush then if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 end else if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 end end elseif sAssemb == 'framedx' then if bPush then if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 end else if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 end end elseif sAssemb == 'frametop' then Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) nCodeVacDisp = 2 elseif sAssemb == 'framebot' then Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) end if v == #tPz then -- solo all'ultimo pezzo -- se porta da traslare setto lo shift da applicare if bShiftMchng then vShift = tMainTabPar.SH1 else vShift = vNullShift end Ori = Ori + vShift end -- faccio le rotazioni della porta if bFlip then EgtRotateRawPart( nRaw, Y_AX(), 180) sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) else sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) end if bTopOnRight then EgtRotateRawPart( nRaw, Z_AX(), -90) sDispMode = sDispMode .. EgtDoorsMsg[481] else EgtRotateRawPart( nRaw, Z_AX(), 90) sDispMode = sDispMode .. EgtDoorsMsg[482] end if bShiftMchng then sDispMode = sDispMode .. EgtDoorsMsg[510] end -- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' local nNumProbeZ -- se c'è probe mode (prod) filtro le geometrie che si trovano sotto if nProbeMode == 1 and nNumProperties == 0 then if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') end -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end -- rinomino i rimenenti if bFlip then DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_secure') else DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint_keyway') end -- mi tengo via il numero di probe in Z nNumProbeZ = #DelList -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtSetName( DelList[j], 'ProbePoint') end else -- se non c'è il probe point o c'è una proprietà, elimino tutti i percorsi di probe (in Z) DelList = MB.FindEntitiesWithPartName( tPz, 'ProbePoint') -- ciclo su tutte le entità trovate for j = 1, #DelList do EgtErase( DelList[j] ) end end ------------------------------------------------------------------ -- calcolo delta Y in base al profilo e al ribaltamento del pezzo ------------------------------------------------------------------ local vExtraYDelta local dExtraY = 0 local dExtraYOppo = 0 local dDeltaProbe = 0 local dDeltaProf = 0 local dDeltaProfOppo = 0 -- variabili per note relative al lato hinges local nHingeMach = 0 -- setto default non lavorato local nLockMach = 0 -- setto default non lavorato local nSideType = -1 -- 0 per profili SQ local nSideOppoType = -1 -- 0 per profili SQ local sProfName local sProfOppoName -- nome profilo lato opposto alla battuta local bHingeOnRef local bCalcProf = false local bCalcProfOppo = false -- per i frame non calcolo distanza profilo su finito if bFrame then bCalcProf = false bCalcProfOppo = false else -- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota if bHingeMach then nHingeMach = 1 end -- se profilo lock da lavorare setto la variabile per la nota if bLockMach then nLockMach = 1 end -- se il profilo hinge è in battuta if ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight) then sProfName = sHingeTrim sProfOppoName = sLockTrim bHingeOnRef = true -- se il profilo hinge non è da lavorare o è una skinned if not bHingeMach or nNumProperties == 1 then bCalcProf = true end -- se il profilo lock non è da lavorare o è una skinned if not bLockMach or nNumProperties == 1 then bCalcProfOppo = true end else -- altrimenti è il profilo lock in battuta sProfName = sLockTrim sProfOppoName = sHingeTrim bHingeOnRef = false -- se il profilo lock non è da lavorare o è una skinned if not bLockMach or nNumProperties == 1 then bCalcProf = true end -- se il profilo hinge non è da lavorare o è una skinned if not bHingeMach or nNumProperties == 1 then bCalcProfOppo = true end end if nProbeMode == 2 then bCalcProf = false bCalcProfOppo = false end end -- se devo calcolare eventuale spostamento dato dal profilo in battuta if bCalcProf then if sProfName == 'SQ' then nSideType = 0 -- se disposizione bevel down uso il riferimento in alto elseif sProfName == 'BD' then nSideType = 1 if dThickDoor > tMainTabPar.AR then dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 end -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se disposizione bevel up uso il riferimento in basso elseif sProfName == 'BU' then nSideType = 2 dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo bull nose verifico in base al raggio elseif sProfName == '1B' or sProfName == '2B' or sProfName == '3B' or sProfName == '4B' then nSideType = 3 -- calcolo punto massimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = 0 -- se punto max è sotto il minimo riferimento if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf -- se punto max è sopra il massimo riferimento elseif dAltProf > tMainTabPar.AR then dAltcalc = dAltProf - tMainTabPar.AR end -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y if dAltcalc > 0 then dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) end -- calcolo errore del probe tastando a metà spessore dDeltaProbe = -dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo convex verifico in base al raggio elseif sProfName == 'CV' then nSideType = 4 -- calcolo punto minimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = (tMainTabPar.TR/2) -- calcolo il delta Y massimo del minimo ingombro profilo local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProf*dAltProf)) -- se riferimento è sul max ingombro porta if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then dAltcalc = 0 -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = tMainTabPar.AR - dAltProf -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR end -- calcolo il delta Y if dAltcalc > 0 then dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf end -- calcolo errore del probe tastando a metà spessore dDeltaProbe = dRadiusPrf - (dExtraY + dMaxInsPrf) -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY end end if bCalcProfOppo then if sProfOppoName == 'SQ' then nSideOppoType = 0 -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto elseif sProfOppoName == 'BD' then nSideOppoType = 1 -- calcolo errore del probe tastando a metà spessore - il parametro z extra p dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) -- se disposizione bevel up uso il riferimento in basso elseif sProfOppoName == 'BU' then nSideOppoType = 2 -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) -- se profilo bull nose verifico in base al raggio elseif sProfOppoName == '1B' or sProfOppoName == '2B' or sProfOppoName == '3B' or sProfOppoName == '4B' then nSideOppoType = 3 -- se profilo convex verifico in base al raggio elseif sProfOppoName == 'CV' then nSideOppoType = 4 -- calcolo punto minimo ingombro profilo local dAltProfOppo = dThickDoor/2 -- calcolo il delta Y massimo del minimo ingombro profilo dExtraYOppo = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) -- calcolo errore del probe tastando a metà spessore dDeltaProfOppo = dRadiusPrf - dExtraYOppo end end -- in base alle proprietà della porta inserisco delle note relative al tipo di personalizzazione richiesta -- se porta con proprietà extruded if nNumProperties == 2 then local dOverMatOnHead = 0 -- in base alla disposizione della porta recupero il sovramateriale del lato di testa contro i riferimenti if ( DISPMODE > 0 and bTopOnRight) or ( DISPMODE < 0 and not bTopOnRight) then -- se porta disposta a sinistra dOverMatOnHead = dBottomOffs else dOverMatOnHead = dTopOffs end -- scrivo le note relative alla proprietà della porta e le altre note EgtSetInfo( Pz, 'PropertiesApplied', tMainTabPar.P2P2) EgtSetInfo( Pz, 'OverMatOnHeadRef', dOverMatOnHead) EgtSetInfo( Pz, 'FinalDoorLength', dLengthDoor) end vExtraYDelta = Vector3d(0,-dExtraY,0) -- scrivo le note EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) EgtSetInfo( Pz, 'SideDisposition', DISPMODE) -- scrivo nota lavorazione lato hinge EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) EgtSetInfo( Pz, 'SideHingeProf', nSideType) -- scrivo profilo lato in battuta EgtSetInfo( Pz, 'SideProfOnRef', nSideType) -- scrivo profilo lato opposto EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) -- scrivo nota lavorazione lato lock EgtSetInfo( Pz, 'SideLockMach', nLockMach) -- scrivo nota con numero geometrie di ProbeZ EgtSetInfo( Pz, 'NumProbeZ', nNumProbeZ) local vExtraXY local dExtraX = 0 dExtraY = 0 local nCorner = MCH_CR.BL if sAssemb == 'framesx' then dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'framedx' then dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'frametop' then dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'framebot' then dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) else -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) if nProbeMode == 2 then local btempX = EgtIf( bTopOnRight, bFlip, not bFlip) bMoveRaw = EgtMoveRawPart( nRaw, Vector3d( EgtIf( bTopOnRight, pMinRecalc:getY(), -pMinRecalc:getY()), EgtIf( btempX, pMinRecalc:getX(), -pMinRecalc:getX()), 0)) end end -- memorizzo i flag per le fasi successive bFlipFirst = bFlip bTopOnRightFirst = bTopOnRight else -- se sono in ribaltamento porta if bFrame then if sAssemb == 'frametop' then -- modifico rotazione per avere sempre lato porta verso l'alto if bPush then bTopOnRight = not bTopOnRight end elseif sAssemb == 'framebot' then -- modifico rotazione per avere sempre lato porta verso il basso if bPush then bTopOnRight = not bTopOnRight end end else -- posizioni opposte bTopOnRight = not bTopOnRightFirst end bFlip = not bFlipFirst -- Scelta dell'origine (ora espressa rispetto Zero Tavola) if sAssemb == 'framesx' then if bPush then if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 end else if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 end end elseif sAssemb == 'framedx' then if bPush then if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 else Ori = EgtIf( DISPMODE > 0,tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 end else if bTopOnRight then -- se top a destra Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR5f, tMainTabPar.OR6f) nCodeVacDisp = 3 end end elseif sAssemb == 'frametop' then Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR3f, tMainTabPar.OR4f) nCodeVacDisp = 2 elseif sAssemb == 'framebot' then Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1f, tMainTabPar.OR2f) nCodeVacDisp = 1 else Ori = EgtIf( DISPMODE > 0, tMainTabPar.OR1, tMainTabPar.OR2) end if v == #tPz then -- solo all'ultimo pezzo -- se porta da traslare setto lo shift da applicare if bShiftMchng then vShift = tMainTabPar.SH1 else vShift = vNullShift end Ori = Ori + vShift end -- faccio le rotazioni della porta if bFlip then EgtRotateRawPart( nRaw, Y_AX(), 180) sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[610], EgtDoorsMsg[479]) else sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtIf( bFrame, EgtDoorsMsg[611], EgtDoorsMsg[480]) end if bTopOnRight then EgtRotateRawPart( nRaw, Z_AX(), -90) sDispMode = sDispMode .. EgtDoorsMsg[481] else EgtRotateRawPart( nRaw, Z_AX(), 90) sDispMode = sDispMode .. EgtDoorsMsg[482] end if bShiftMchng then sDispMode = sDispMode .. EgtDoorsMsg[510] end -- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' ------------------------------------------------------------------ -- calcolo delta Y in base al profilo e al ribaltamento del pezzo ------------------------------------------------------------------ local vExtraYDelta local dExtraY = 0 local dExtraYOppo = 0 local dDeltaProbe = 0 local dDeltaProf = 0 local dDeltaProfOppo = 0 -- variabili per note relative al lato hinges local nHingeMach = 0 -- setto default non lavorato local nLockMach = 0 -- setto default non lavorato local nSideType = -1 -- 0 per profili SQ local nSideOppoType = -1 -- 0 per profili SQ local sProfName -- nome profilo in battuta local sProfOppoName -- nome profilo lato opposto alla battuta local bHingeOnRef local bCalcProf = false local bCalcProfOppo = false -- per i frame non calcolo distanza profilo su finito if bFrame then bCalcProf = false bCalcProfOppo = false else -- se profilo hinge è da lavorare e non è stato lavorato setto il valore della nota if bHingeMach and not DGD.MHS then nHingeMach = 1 end -- se profilo lock é da lavorare e non è stato lavorato setto la variabile per la nota if bLockMach and not DGD.MLS then nLockMach = 1 end -- se il profilo hinge è in battuta if ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight) then sProfName = sHingeTrim sProfOppoName = sLockTrim bHingeOnRef = true -- se il profilo hinge non è da lavorare o è già stato lavorato if not bHingeMach or DGD.MHS then bCalcProf = true end -- se il profilo lock non è da lavorare o è già stato lavorato if not bLockMach or DGD.MLS then bCalcProfOppo = true end else -- altrimenti è il profilo lock in battuta sProfName = sLockTrim sProfOppoName = sHingeTrim bHingeOnRef = false -- se il profilo lock non è da lavorare o è già stato lavorato if not bLockMach or DGD.MLS then bCalcProf = true end -- se il profilo hinge non è da lavorare o è già stato lavorato if not bHingeMach or DGD.MHS then bCalcProfOppo = true end end --[[ -- se il profilo in battuta non è da lavorare o è già stato lavorato if ( not bHingeMach or DGD.MHS) and ( ( not bFlip and bTopOnRight and not bAtRight) or ( not bFlip and not bTopOnRight and bAtRight) or ( bFlip and bTopOnRight and bAtRight) or ( bFlip and not bTopOnRight and not bAtRight)) then sProfName = sHingeTrim sProfOppoName = sLockTrim bHingeOnRef = true bCalcProf = true elseif ( not bLockMach or DGD.MLS) and ( ( not bFlip and bTopOnRight and bAtRight) or ( not bFlip and not bTopOnRight and not bAtRight) or ( bFlip and bTopOnRight and not bAtRight) or ( bFlip and not bTopOnRight and bAtRight)) then sProfName = sLockTrim sProfOppoName = sHingeTrim bHingeOnRef = false bCalcProf = true end ]]-- end -- se devo calcolare eventuale spostamento dato dal profilo in battuta if bCalcProf then if sProfName == 'SQ' then nSideType = 0 -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto elseif sProfName == 'BU' then nSideType = 1 if dThickDoor > tMainTabPar.AR then dExtraY = ( dThickDoor - tMainTabPar.AR) * TAN3 end -- calcolo errore del probe tastando a metà spessore - il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso elseif sProfName == 'BD' then nSideType = 2 dExtraY = ( tMainTabPar.AR - tMainTabPar.TR) * TAN3 -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProf = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) dDeltaProbe = dDeltaProf - dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo bull nose verifico in base al raggio elseif sProfName == '1B' or sProfName == '2B' or sProfName == '3B' or sProfName == '4B' then nSideType = 3 -- calcolo punto massimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = 0 -- se punto max è sotto il minimo riferimento if dAltProf < ( tMainTabPar.AR - tMainTabPar.TR) then dAltcalc = tMainTabPar.AR - tMainTabPar.TR - dAltProf -- se punto max è sopra il massimo riferimento elseif dAltProf > tMainTabPar.AR then dAltcalc = dAltProf - tMainTabPar.AR end -- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y if dAltcalc > 0 then dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) end -- calcolo errore del probe tastando a metà spessore dDeltaProbe = -dExtraY -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY -- se profilo convex verifico in base al raggio elseif sProfName == 'CV' then nSideType = 4 -- calcolo punto minimo ingombro profilo local dAltProf = dThickDoor/2 local dAltcalc = (tMainTabPar.TR/2) -- calcolo il delta Y massimo del minimo ingombro profilo local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProf*dAltProf)) -- se riferimento è sul max ingombro porta if ( dThickDoor < tMainTabPar.AR) and ( dThickDoor > ( tMainTabPar.AR - tMainTabPar.TR)) then dAltcalc = 0 -- se punto minimo ingombro profilo è sotto all'altezza media del riferimento elseif dAltProf < ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = tMainTabPar.AR - dAltProf -- se punto minimo ingombro profilo è sopra all'altezza media del riferimento elseif dAltProf > ( tMainTabPar.AR - (tMainTabPar.TR/2)) then dAltcalc = dAltProf - tMainTabPar.AR + tMainTabPar.TR end -- calcolo il delta Y if dAltcalc > 0 then dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf end -- calcolo errore del probe tastando a metà spessore -- dDeltaProbe = dRadiusPrf - dExtraY -- dDeltaProf = dRadiusPrf - dMaxInsPrf dDeltaProbe = dRadiusPrf - (dExtraY + dMaxInsPrf) -- dato che viene compensato il dDeltaProbe nella tastatura. il dDeltaProf risulta essere uguale a dExtraY dDeltaProf = dExtraY end end if bCalcProfOppo then if sProfOppoName == 'SQ' then nSideOppoType = 0 -- se disposizione bevel down ( il nome è riferito alla prima disposizione) uso il riferimento in alto elseif sProfOppoName == 'BU' then nSideOppoType = 1 -- calcolo errore del probe tastando a metà spessore - il parametro z extra p dDeltaProfOppo = ((( dThickDoor / 2) - tMainTabPar.EZPB) * TAN3) -- se disposizione bevel up ( il nome è riferito alla prima disposizione) uso il riferimento in basso elseif sProfOppoName == 'BD' then nSideOppoType = 2 -- calcolo errore del probe tastando a metà spessore + il parametro z extra probe dDeltaProfOppo = ((( dThickDoor / 2) + tMainTabPar.EZPB) * TAN3) elseif sProfOppoName == '1B' or sProfOppoName == '2B' or sProfOppoName == '3B' or sProfOppoName == '4B' then nSideOppoType = 3 -- se profilo convex verifico in base al raggio elseif sProfOppoName == 'CV' then nSideOppoType = 4 -- calcolo punto minimo ingombro profilo local dAltProfOppo = dThickDoor/2 -- calcolo il delta Y dExtraYOppo = sqrt((dRadiusPrf*dRadiusPrf)-(dAltProfOppo*dAltProfOppo)) -- calcolo errore del probe tastando a metà spessore dDeltaProfOppo = dRadiusPrf - dExtraYOppo end end vExtraYDelta = Vector3d(0,-dExtraY,0) -- scrivo le note -- se sono ancora nella prima fase e non sono state fatte lavorazioni allora setto le note -- ancora per la prima disposizione if nNumPhase and nNumPhase == 1 and nNumMach == 0 then EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY) EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe) EgtSetInfo( Pz, 'DoorProbeExtraPosZ', tMainTabPar.EZPB) EgtSetInfo( Pz, 'DoorProfErrorY', dDeltaProf) EgtSetInfo( Pz, 'DoorProfOppoErrorY', dDeltaProfOppo) EgtSetInfo( Pz, 'SideDisposition', DISPMODE) -- scrivo nota lavorazione lato hinge EgtSetInfo( Pz, 'SideHingeMach', nHingeMach) -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) EgtSetInfo( Pz, 'SideHingeProf', nSideType) -- scrivo profilo lato in battuta EgtSetInfo( Pz, 'SideProfOnRef', nSideType) -- scrivo profilo lato opposto EgtSetInfo( Pz, 'SideProfOnOppo', nSideOppoType) -- scrivo nota lavorazione lato lock EgtSetInfo( Pz, 'SideLockMach', nLockMach) else EgtSetInfo( Pz, 'ExtraCalcMoveY_2', dExtraY) EgtSetInfo( Pz, 'DoorProbeErrorY_2', dDeltaProbe) EgtSetInfo( Pz, 'DoorProbeExtraPosZ_2', tMainTabPar.EZPB) EgtSetInfo( Pz, 'DoorProfErrorY_2', dDeltaProf) EgtSetInfo( Pz, 'DoorProfOppoErrorY_2', dDeltaProfOppo) EgtSetInfo( Pz, 'SideDisposition_2', DISPMODE) -- scrivo nota lavorazione lato hinge EgtSetInfo( Pz, 'SideHingeMach_2', nHingeMach) -- per compatibilità scrivo nota tipo profilo su lato in battuta (inizialmente il lato hinge era sempre in battuta) EgtSetInfo( Pz, 'SideHingeProf_2', nSideType) -- scrivo profilo lato in battuta EgtSetInfo( Pz, 'SideProfOnRef_2', nSideType) -- scrivo profilo lato opposto EgtSetInfo( Pz, 'SideProfOnOppo_2', nSideOppoType) -- scrivo nota lavorazione lato lock EgtSetInfo( Pz, 'SideLockMach_2', nLockMach) end local vExtraXY local dExtraX = 0 dExtraY = 0 local nCorner = MCH_CR.BL if sAssemb == 'framesx' then dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'framedx' then dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'frametop' then dExtraX , dExtraY, nCorner = CalcDispositionRef( true, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) elseif sAssemb == 'framebot' then dExtraX , dExtraY, nCorner = CalcDispositionRef( false, bTopOnRight, bPush, dLeftOffs, dRightOffs, dTopOffs, dBottomOffs, bFlip) vExtraXY = Vector3d( dExtraX, dExtraY, 0) -- Muovo frame nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta + vExtraXY), nCorner) else -- Muovo porta con l'angolo in basso a ( destra o sinistra) nella posizione di origine bMoveRaw = EgtMoveToCornerRawPart( nRaw, ( Ori + vExtraYDelta), EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR)) end end if not bMoveRaw then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[528]..EgtDoorsMsg[474] -- Error positioning raw part on table break end if bFirstStep then if bShiftMchng then sNotePhase = 'SHIFT' else sNotePhase = 'NORMAL' end else if bShiftMchng then sNotePhase = 'FLIPSHIFT' else sNotePhase = 'FLIP' end end -- salvo una nota con le info della disposizione traslata EgtSetInfo( Pz, 'DoorOnTable_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sDispMode) EgtSetInfo( Pz, 'KindPhase_' .. tostring(nNumPhase) .. '_' .. tMainTabPar.MN, sNotePhase) -- salvo note per porta ribaltata rispetto al ddf e per disposizione lato top EgtSetInfo( Pz, 'DispPhase_' .. tostring(nNumPhase) , EgtIf( bFlip, 'F', 'N')) EgtSetInfo( Pz, 'DispTopOn_' .. tostring(nNumPhase) , EgtIf( bTopOnRight, 'R', 'L')) if bFlip then -- se porta capovolta if bTopOnRight then -- se top a destra -- il lato sinistro appoggia sui riferimenti OffsYSovr = dLeftOffs OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) else -- se top a sinistra -- il lato destro appoggia sui riferimenti OffsYSovr = dRightOffs OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) end else -- altrimenti non è capovolta if bTopOnRight then -- se top a destra -- il lato destro appoggia sui riferimenti OffsYSovr = dRightOffs OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs) else -- se top a sinistra -- il lato sinistro appoggia sui riferimenti OffsYSovr = dLeftOffs OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs) end end -- se frame riassegno il valore del sovramateriale perchè viene tenuto a filo della ventosa if bFrame then if nCodeVacDisp == 1 then OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR1f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR2f:getX() - tMainTabPar.OR2:getX())) elseif nCodeVacDisp == 2 then OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR3f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR4f:getX() - tMainTabPar.OR2:getX())) elseif nCodeVacDisp == 3 then OffsXSovr = EgtIf( DISPMODE > 0, abs( tMainTabPar.OR5f:getX() - tMainTabPar.OR1:getX()), abs( tMainTabPar.OR6f:getX() - tMainTabPar.OR2:getX())) end end ---------------------------------------- -- Inserimento riferimenti e ventose ---------------------------------------- if v == 1 then -- Offset ventose da bordo pezzo in Y -- dVacOffs = 65.0 -- utilizzo il valore della nota perchè è ridondante -- Offset barra riferimenti mobile da riferimenti quando posizione 0 dMobOffs2 = 0 dMobOffs1 = dMobOffs2 / 2 -- è in posizione intermedia -- Lunghezza minima per alzare prima ventosa da bordo sinistro -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) -- dDistMinX = 296.8 + 5.5 + 46.7 -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza dDistMinX = tMainTabPar.DVL + 92.075 + DIST_MIN_VAC -- Lunghezza minima per alzare prima ventosa da bordo destro -- ( dall'angolo rettangolo al punto centrale ventose + 5.5 + distanza riferimento-rettangolo) -- dDistMaxX = 185.1 + 5.5 + 46.7 -- dall'angolo appoggio porta (riferimento) al punto centrale ventose + mezza larghezza ventosa (in X) + quota sicurezza dDistMaxX = tMainTabPar.DVR + 92.075 + DIST_MIN_VAC -- Posizione ventose in alto dVacOn = 1 -- Interasse ventose dInterAx = 193.68 -- Interasse minimo gruppi ventose dMinDistGroup = 139.5 -- setto modaità due barre disabilitato bUseOnly2Bars = false -- Ventose nTabId = EgtGetTableId( 'Tab') nMobId1 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE1') nMobId2 = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE2') nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED') nDispId = EgtGetPhaseDisposition( nNumPhase) -- se gruppi richiesti non trovati if not nMobId1 or not nMobId2 or not nFixId then bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar' break end -- Posizionamento barra mobile -- fisso dFixval = EgtGetInfo( nFixId, 'Val', 'd') -- mobile 2 dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') local dNewVal if bFrame then -- se è un frame dNewVal_2 = tMainTabPar.FPB dNewVal = dNewVal_2 nIndexPin = 11 else dNewVal = b3Solid:getDimX() - dFixval + OffsYSovr + vShift:getY() + vShiftVac:getY() - dMobOffs2 -- aggiusto la posizione per i valori fissi del regolatore manuale dNewVal_2, nIndexPin = GetCorrectedIndexedAxis( dNewVal) end -- Se posizione raggiungibile if dNewVal_2 and ( dNewVal_2 - dFixval) >= ( 2 * dMinDistGroup) then -- mobile 2 EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) EgtSetInfo( nMobId2, 'Val', dNewVal_2) EgtSetInfo( nDispId, 'MOB2', dNewVal_2) EgtSetInfo( nDispId, 'PINPOS', nIndexPin) -- mobile 1 dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') dNewVal_1 = ( dNewVal_2 + dFixval) / 2 EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) EgtSetInfo( nMobId1, 'Val', dNewVal_1) EgtSetInfo( nDispId, 'MOB1', dNewVal_1) else -- controllo se con due barre è possibile if ( dNewVal - dFixval) >= dMinDistGroup then -- mobile 1 -- dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') dNewVal_1 = dNewVal -- EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) -- EgtSetInfo( nMobId1, 'Val', dNewVal_1) -- EgtSetInfo( nDispId, 'MOB1', dNewVal_1) -- mobile 2 dOldVal = EgtGetInfo( nMobId2, 'Val', 'd') dNewVal_2 = (dNewVal_1 * 2) - dFixval -- ri-aggiusto la posizione per i valori fissi del regolatore manuale dNewVal_2, nIndexPin = GetCorrectedIndexedAxis( dNewVal_2) if not dNewVal_2 then -- verifico se numero di ventose sufficienti e do errore nel caso contrario bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[633] if not bOk then break end end EgtMove( nMobId2, Vector3d( 0, dNewVal_2 - dOldVal, 0), GDB_RT.GLOB) EgtSetInfo( nMobId2, 'Val', dNewVal_2) EgtSetInfo( nDispId, 'MOB2', dNewVal_2) EgtSetInfo( nDispId, 'PINPOS', nIndexPin) -- ricalcolo la posizione della barra intermedia mobile 1 dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') dNewVal_1 = ( dNewVal_2 + dFixval) / 2 EgtMove( nMobId1, Vector3d( 0, dNewVal_1 - dOldVal, 0), GDB_RT.GLOB) EgtSetInfo( nMobId1, 'Val', dNewVal_1) EgtSetInfo( nDispId, 'MOB1', dNewVal_1) bUseOnly2Bars = true else -- mobile 2 EgtSetInfo( nDispId, 'MOB2', dOldVal) -- mobile 1 dOldVal = EgtGetInfo( nMobId1, 'Val', 'd') EgtSetInfo( nDispId, 'MOB1', dOldVal) EgtSetInfo( nDispId, 'PINPOS', 0) bOk = false DGD.EMC = ' ' .. EgtDoorsMsg[633] if not bOk then break end end end end -- Elevazione ventose con: altezza porta ( uso getDimY perchè presa prima della disposizione porta) + -- sovramateriale a contatto con il riferimento a sx - distanza ventosa dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( DISPMODE > 0, dDistMinX, dDistMaxX) -- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto StartVacVerify( Ls, bFlip, nProbeMode) -- ciclo sulle ventose local nInd = 1 local nNumTotVacRow = 15 -- tabelle per gestione conteggi inserimento ventose, gli indici tabella sono le barre (1 fissa, 2 intermedia, 3 mobile) local tnCountFailed = {} -- tabella conteggio ventose non disposte tnCountFailed[1] = 0 tnCountFailed[2] = 0 tnCountFailed[3] = 0 local tnIniFailed = {} -- tabella conteggio ventose iniziali non disposte tnIniFailed[1] = 0 tnIniFailed[2] = 0 tnIniFailed[3] = 0 local tnMiddleFailed = {} -- tabella conteggio ventose intermedie non disposte tnMiddleFailed[1] = 0 tnMiddleFailed[2] = 0 tnMiddleFailed[3] = 0 local tnEndFailed = {} -- tabella conteggio ventose finali non disposte tnEndFailed[1] = 0 tnEndFailed[2] = 0 tnEndFailed[3] = 0 local tnMaxIniFailed = {} -- tabella contatore totale ventose iniziali non disposte tnMaxIniFailed[1] = 0 tnMaxIniFailed[2] = 0 tnMaxIniFailed[3] = 0 local tnMaxMiddleFailed = {}-- tabella contatore totale ventose intermedie non disposte tnMaxMiddleFailed[1] = 0 tnMaxMiddleFailed[2] = 0 tnMaxMiddleFailed[3] = 0 local tnMaxEndFailed = {} -- tabella contatore totale ventose finali non disposte tnMaxEndFailed[1] = 0 tnMaxEndFailed[2] = 0 tnMaxEndFailed[3] = 0 -- tabelle gestione ventose, gli indici tabella rappresentano le barre (1 fissa, 2 intermedia, 3 mobile) local tsBaseNamePnt = {} -- tabella nomi punti ventosa base tsBaseNamePnt[1] = 'CEN1V' tsBaseNamePnt[2] = 'CEN1V' tsBaseNamePnt[3] = 'CEN1V' local tdBaseRadiusPnt1 = {} -- tabella con valori raggio interferenza da punti controllo ventosa primo tipo tdBaseRadiusPnt1[1] = 41.275 tdBaseRadiusPnt1[2] = 51.275 tdBaseRadiusPnt1[3] = 41.275 local tsBaseNameVac_1 = {} -- tabella nomi ventose primo tipo normale tsBaseNameVac_1[1] = 'VAC2_FIX' tsBaseNameVac_1[2] = 'VAC_MOB1' tsBaseNameVac_1[3] = 'VAC2_MOB2' local tsBaseNameVacSld_1 = {} -- tabella nomi ventose primo tipo con disegno dispositivo alzapezzo tsBaseNameVacSld_1[1] = 'VAC2_FIX_SLD' tsBaseNameVacSld_1[2] = 'VAC_MOB1_SLD' tsBaseNameVacSld_1[3] = 'VAC2_MOB2_SLD' local tsBaseNamePnt2 = {} -- tabella nomi punti ventosa secondo tipo tsBaseNamePnt2[1] = 'CEN2V' tsBaseNamePnt2[2] = 'CEN2V' tsBaseNamePnt2[3] = 'CEN2V' local tdBaseRadiusPnt2 = {} -- tabella con valori raggio interferenza da punti controllo ventosa secondo tipo tdBaseRadiusPnt2[1] = 31.750 tdBaseRadiusPnt2[2] = 51.275 -- non usata attualmente sulla batta centrale tdBaseRadiusPnt2[3] = 31.750 local tsBaseNameVac_2 = {} -- tabella nomi ventose secondo tipo normale tsBaseNameVac_2[1] = 'VAC_FIX_2' tsBaseNameVac_2[2] = 'VAC_MOB1_2' -- non usata attualmente sulla batta centrale tsBaseNameVac_2[3] = 'VAC_MOB2_2' local tsBaseNameVacSld_2 = {} -- tabella nomi ventose secondo tipo con disegno dispositivo alzapezzo tsBaseNameVacSld_2[1] = 'VAC_FIX_SLD_2' tsBaseNameVacSld_2[2] = 'VAC_MOB1_SLD_2' tsBaseNameVacSld_2[3] = 'VAC_MOB2_SLD_2' local tsBaseNameVac = {} -- tabella nomi ventose tipo unificato normale tsBaseNameVac[1] = '' tsBaseNameVac[2] = '' tsBaseNameVac[3] = '' local tsBaseNameVacSld = {} -- tabella nomi ventose unificato con disegno dispositivo alzapezzo tsBaseNameVacSld[1] = '' tsBaseNameVacSld[2] = '' tsBaseNameVacSld[3] = '' --------------------------------------- local tsNoteRow = {} -- tabella per note da assegnare alle geometrie delle barre tsNoteRow[1] = '' tsNoteRow[2] = '' tsNoteRow[3] = '' -- questa tabella deve essere settata in base ai sottopezzi presenti nella cartella della macchina -- e al disegno della macchina: deve avere i punti con i nomi geometria indicati da tsBaseNamePnt, tsBaseNamePnt2, ecc. local tnNumVacInsert = {} -- tabella per numero di tipi di ventosa presenti sulle barre tnNumVacInsert[1] = 1 tnNumVacInsert[2] = 1 tnNumVacInsert[3] = 1 local tnNumKindVac = {} -- tabella che indica il tipo di ventosa corrente tnNumKindVac[1] = 1 tnNumKindVac[2] = 1 tnNumKindVac[3] = 1 --------------------------------------- -- tabella posizionamento ventose local tPosRowSubPieceRow1 = {} local tPosRowSubPieceRow2 = {} local tPosRowSubPieceRow3 = {} local tdYCommpos = {} -- tabella valori Y con sottopezzi identici while dCalcLen > 0 and nInd <= nNumTotVacRow do local nIndVac = EgtIf( DISPMODE > 0, nInd, ( nNumTotVacRow - nInd + 1)) local sInd = tostring( nIndVac) if nCodeVacDisp <= 1 then tPosRowSubPieceRow1[nIndVac] = CalcDispositionSubPieces( 1, nFixId, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) end if nCodeVacDisp == 0 or nCodeVacDisp == 2 then local nIdVac = 2 if bUseOnly2Bars then nIdVac = 3 end tPosRowSubPieceRow2[nIndVac] = CalcDispositionSubPieces( nIdVac, nMobId1, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) end if ( nCodeVacDisp == 0 or nCodeVacDisp == 3) and not bUseOnly2Bars then tPosRowSubPieceRow3[nIndVac] = CalcDispositionSubPieces( 3, nMobId2, tMainTabPar.FVR, tsBaseNameVac, tsBaseNamePnt, sInd, tdBaseRadiusPnt1, tnNumVacInsert, tsBaseNamePnt2, tdBaseRadiusPnt2, tnNumKindVac, tsBaseNameVac_2, tsBaseNameVacSld, tsBaseNameVacSld_2, tdYCommpos, nInd, tnCountFailed, tnMaxIniFailed, tnIniFailed, tnMaxMiddleFailed, tnMiddleFailed, tnMaxEndFailed, tnEndFailed, nNumTotVacRow, ( dCalcLen - dInterAx)) end -- aggiorno la lunghezza di calcolo e l'indice dCalcLen = dCalcLen - dInterAx nInd = nInd + 1 end -- end while -- elimino geometrie per verifica EndVacVerify() for l = 1, nNumTotVacRow do local nIndVac = EgtIf( DISPMODE > 0, l, ( nNumTotVacRow - l + 1)) if nCodeVacDisp <= 1 then -- porta o frame su prima linea vicino a riferimenti DispositionSubPieces( 1, nIndVac, tPosRowSubPieceRow1, tMainTabPar.FVR, tsBaseNameVac, tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, tsBaseNameVacSld_2, nIndVac, tabOri, tsNoteRow, nDispId) end if nCodeVacDisp == 0 or nCodeVacDisp == 2 then -- porta o frame su linea intermedia local nIdVac = 2 if bUseOnly2Bars then nIdVac = 3 end DispositionSubPieces( nIdVac, nIndVac, tPosRowSubPieceRow2, tMainTabPar.FVR, tsBaseNameVac, tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, tsBaseNameVacSld_2, ( nIndVac + 1), tabOri, tsNoteRow, nDispId) end if nCodeVacDisp == 0 or nCodeVacDisp == 3 then -- porta o frame su ultima linea lontana dai riferimenti DispositionSubPieces( 3, nIndVac, tPosRowSubPieceRow3, tMainTabPar.FVR, tsBaseNameVac, tsBaseNameVacSld, tdYCommpos, tsBaseNameVac_1, tsBaseNameVacSld_1, tsBaseNameVac_2, tsBaseNameVacSld_2, nIndVac, tabOri, tsNoteRow, nDispId) end end -- scrivo nota linea di ventose if string.len( tsNoteRow[1]) > 0 then EgtSetInfo( Pz, 'FixVacRow_Phase_'..tostring(nNumPhase), tsNoteRow[1]) end if string.len( tsNoteRow[2]) > 0 then EgtSetInfo( Pz, 'Mob1VacRow_Phase_'..tostring(nNumPhase), tsNoteRow[2]) end if string.len( tsNoteRow[3]) > 0 then EgtSetInfo( Pz, 'Mob2VacRow_Phase_'..tostring(nNumPhase), tsNoteRow[3]) end -- scrivo note con i valori di partenza della prima ventosa in basso a destra EgtSetInfo( Pz, 'FixValX', tMainTabPar.DVR) EgtSetInfo( Pz, 'FixValY', dFixval) -- verifico se numero di ventose sufficienti e do errore nel caso contrario bOk, DGD.EMC = CheckEnoughVacuums( ( nInd - 1), nCodeVacDisp, tnMaxIniFailed, tnMaxMiddleFailed, tnMaxEndFailed, bUseOnly2Bars) if not bOk then break end ---------------------- ---------------------- -- *** Lavorazioni *** ---------------------- ---------------------- local bMakeGhost = EgtIf( bFirstStep, true, false) local tSideMachDoor={} -- ricavo minimo e massimo del solido del pezzo b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.STANDARD) pMin = b3SolidOnTab:getMin() pMax = b3SolidOnTab:getMax() if v == 1 then -- solo il primo pezzo -- print Machining table for i = nIndexStartMach, #tLocMach do DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') .. ' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1) end end -- solo il primo giro aggiusto i profili bevel per essere coerente con la sequenza di tabella if bFirstStep and ( not bShiftMchng or bSmallShiftedDoor) and nProbeMode ~= 1 then for i = 1, #tLocMach do if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name) -- Applico le lavorazioni for j = 1, #EntList do -- OPERAZIONI if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then -- MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf) MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep) end end end end end end -- conteggio lavorazioni saltate nNumMachSkipResult = 0 if v == 1 then -- solo il primo pezzo -- variabile per conteggio lavorazioni nNumMach = 0 nNumSkip = 0 end -- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sottp if bFlip then local nValAppo = nNumGeomBottom nNumGeomBottom = nNumGeomTop nNumGeomTop = nValAppo end -- local bEnBreak = false bEnBreak = false -- Machining adding, only for selected machine -- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni for i = nIndexStartMach, #tLocMach do -- se devo uscire dal ciclo if bEnBreak then break end if tLocMach[i].On ~= 0 then sLocMachId = tLocMach[i].MachId if not sLocMachId then sLocMachId = 1 end if sLocMachId == nNumMachFromTable then -- Recupero le entità local sHide = EgtIf( bFirstStep, '','_HIDE') local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide) -- Applico le lavorazioni for j = 1, #EntList do local nNewIdEnt -- OPERAZIONI if tLocMach[i].Oper then if tLocMach[i].Oper == 'AdjustBevel' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then bLocMach, _, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf, bMakeGhost) -- bLocMach, _, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, nil, bMakeGhost) if bLocMach then local bInsLav = false -- faccio il test per vedere se la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) if not bInsLav then nNumMachSkipResult = nNumMachSkip + 1 EgtSetInfo( nNewIdEnt, 'Mach', 12) end elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) if not bInsLav then nNumMachSkipResult = nNumMachSkip + 1 EgtSetInfo( nNewIdEnt, 'Mach', 11) end elseif nMach == 3 then bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) if not bInsLav then nNumMachSkipResult = nNumMachSkip + 1 EgtSetInfo( nNewIdEnt, 'Mach', 13) end end -- se la lavorazione è applicabile e non scatena lo shift -- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then -- se la lavorazione è applicabile if bInsLav then -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if sEdge then if string.len( tsMachProf[v]) > 0 then tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge else tsMachProf[v] = sEdge end end -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura if string.lower( sEdge) == 'left' then local dOffsLoc = 0 if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) elseif string.lower( sEdge) == 'right' then local dOffsLoc = 0 if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) elseif string.lower( sEdge) == 'top' then tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) elseif string.lower( sEdge) == 'bottom' then tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) end elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) else bOk = false end nNumMachSkip = nNumMachSkipResult end else bOk = false end elseif tLocMach[i].Oper == 'AdjustVertCurve' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost) elseif tLocMach[i].Oper == 'AdjustRoughCurve' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true) elseif tLocMach[i].Oper == 'AdjustThrouCurve' or tLocMach[i].Oper == 'AdjPrfThrouCurve' and ( nProbeMode == 0 or ( nProbeMode == 1 and nNumProperties == 1)) then if tLocMach[i].Oper == 'AdjustThrouCurve' then bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) else -- altrimenti bLocMach, nNewIdEnt = MB.AdjPrfThrouCurve( EntList[j], bMakeGhost, tsProperties, tMainTabPar.P2P1, bNoVertProf, bFirstStep, tLocMach[i].Name) -- bLocMach, nNewIdEnt = MB.AdjPrfThrouCurveOld( EntList[j], bMakeGhost, tsProperties, tMainTabPar.P2P1) end if bLocMach then local bInsLav = false -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) nNumMachSkipResult = nNumMachSkip + 1 end -- se la lavorazione è applicabile e non scatena lo shift -- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then -- se la lavorazione è applicabile if bInsLav then -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if sEdge then if string.len( tsMachProf[v]) > 0 then if not string.find( tsMachProf[v], sEdge) then tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge end else tsMachProf[v] = sEdge end end -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura if string.lower( sEdge) == 'left' then local dOffsLoc = 0 if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) elseif string.lower( sEdge) == 'right' then local dOffsLoc = 0 if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) elseif string.lower( sEdge) == 'top' then tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) elseif string.lower( sEdge) == 'bottom' then tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) end elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) else bOk = false end nNumMachSkip = nNumMachSkipResult end --[[ end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult end ]]-- else bOk = false end elseif tLocMach[i].Oper == 'AdjustThrouCurveInt' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost) if bLocMach then local bInsLav = false -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) nNumMachSkipResult = nNumMachSkip + 1 end if bInsLav then -- ottengo il nome del lato lavorato local sEdge = EgtGetName( EgtGetParent( EntList[j])) if sEdge then if string.len( tsMachProf[v]) > 0 then if not string.find( tsMachProf[v], sEdge) then tsMachProf[v] = tsMachProf[v] .. ',' .. sEdge end else tsMachProf[v] = sEdge end end -- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura if string.lower( sEdge) == 'left' then local dOffsLoc = 0 if bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.left = MB.MakeRoughPaths( dLeftOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.left, dOffsLoc) elseif string.lower( sEdge) == 'right' then local dOffsLoc = 0 if bAtRight and ( sLockTrim == 'BD' or sLockTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 elseif not bAtRight and ( sHingeTrim == 'BD' or sHingeTrim == 'BU') then dOffsLoc = dThickDoor * TAN3 end tSideMachDoor.right = MB.MakeRoughPaths( dRightOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, false, bFlip, tSideMachDoor.right, dOffsLoc) elseif string.lower( sEdge) == 'top' then tSideMachDoor.top = MB.MakeRoughPaths( dTopOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.top) elseif string.lower( sEdge) == 'bottom' then tSideMachDoor.bottom = MB.MakeRoughPaths( dBottomOffs, tMainTabPar.MOM, tMainTabPar.SOM, nNewIdEnt, true, bFlip, tSideMachDoor.bottom) end elseif not bInsLav or (nNumMachSkipResult > nNumMachSkip) then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) else bOk = false end nNumMachSkip = nNumMachSkipResult end else bOk = false end elseif tLocMach[i].Oper == 'AdjustThrouIsle' and nProbeMode ~= 1 then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) if not bLocMach then -- se operazione fallita bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- il metodo AdjustThrouIsle non dovrebbe restituire il 3 bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end -- se la lavorazione non è applicabile if not bInsLav then if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- aumento di 1 il numero di lavorazioni skippate nNumMachSkip = nNumMachSkip + 1 -- ricambio la nota come non lavorabile in questa fase if nMach == 1 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) elseif nMach == 2 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) else EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) end -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end end elseif tLocMach[i].Oper == 'AdjustHorizDrillX' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHorizDrillX( EntList[j], bMakeGhost, true) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorizDrillY' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHorizDrillY( EntList[j], bMakeGhost, true) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorizAS' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustMortise' and nProbeMode ~= 1 then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost, NO_WORK_UPSQUARE) if bLocMach then local bInsLav = false -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- questa macchina non ha aggragati per il bevel DW bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult end else bOk = false end elseif tLocMach[i].Oper == 'AdjustVertHole' and nProbeMode ~= 1 then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, tMainTabPar.ETM) if not bLocMach then bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- il metodo AdjustVertHole non dovrebbe restituire il 3 bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end -- se la lavorazione non è applicabile if not bInsLav then if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- aumento di 1 il numero di lavorazioni skippate nNumMachSkip = nNumMachSkip + 1 -- ricambio la nota come non lavorabile in questa fase if nMach == 1 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) elseif nMach == 2 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) else EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) end -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end end elseif tLocMach[i].Oper == 'AdjustHole' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjPreHoleAndPocket' and nProbeMode ~= 1 then bLocMach, nNewIdEnt = MB.AdjPreHoleAndPocket( EntList[j], bMakeGhost, tsProperties, {tMainTabPar.P2P2, tMainTabPar.P2P1}) if not bLocMach then bOk = false end elseif tLocMach[i].Oper == 'AdjustProbeHole' and nProbeMode == 1 and nNumProperties == 0 then bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustProbeHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, false, bMakeGhost) if not bLocMach then bOk = false end if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end nNumMachSkip = nNumMachSkipResult else -- se non skippata provo a verificare se la lavorazione è applicabile local bInsLav = true -- faccio un test per vedere che la lavorazione è applicabile local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 if nMach == 1 then bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt) elseif nMach == 2 then bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt) elseif nMach == 3 then -- il metodo AdjustProbeHole non dovrebbe restituire il 3 bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt) end -- se la lavorazione è applicabile setto la nota sul pezzo if bInsLav then EgtSetInfo( Pz, 'ExistsProbeZ', true) -- presenza del probe in Z else -- altrimenti la lavorazione non è applicabile if bFirstStep then -- inserisco in tabella solo se non già presente tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i) end -- aumento di 1 il numero di lavorazioni skippate nNumMachSkip = nNumMachSkip + 1 -- ricambio la nota come non lavorabile in questa fase if nMach == 1 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 + 1) elseif nMach == 2 then EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10 - 1) else EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10) end -- incremento il numero di lavorazioni da sotto nNumGeomBottom = nNumGeomBottom + 1 end end end else -- se nessuna operazione if nProbeMode ~= 1 then nNewIdEnt = MB.MakeGhostCopy( EntList[j]) end end -- LAVORAZIONI local nMach if nNewIdEnt then nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1 else nMach = 0 end local bScroll = true if nMach > 30 and nMach < 40 then nMach = nMach - 30 end -- se prima lavorazione, valida, con chiave Shift abilitata, esco dal giro --[[ if ( nMach > 0 and nMach < 10) and not bShiftMchng and tLocMach[i].Shift == 1 then bShiftMchng = true -- flag per traslazione Y nIndexStartMach = i -- ripartenza da questa posizione bScroll = false -- salto l'applicazione delle lavorazioni in seguito bEnBreak = true -- blocco il for della scansione tabella -- se fase di ripresa rimetto la nota mach disabilitata if not bFirstStep then nMach = nMach + 10 EgtSetInfo( EntList[j], 'Mach', nMach) nNumMachSkip = nNumMachSkip + 1 end end --]] if not bScroll then break -- esco dal ciclo for j else if nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno -- carico id entità in una tabella local tListSameMach = {} table.insert( tListSameMach, nNewIdEnt) bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach, tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false, NOT_GEN_MACH) else DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') .. EgtDoorsMsg[596]..tostring( nNumPhase), 0) nNumSkip = nNumSkip + 1 end end end end end end end -- end for local i = 1 while i <= #tLocMachOrd and not bEnBreak do -- carico tutto il gruppo in una tabella local tGroup = {} local nNumGroup = tLocMachOrd[i].Group local sProperty = tLocMachOrd[i].Property tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGroup, sProperty) if sProperty then -- se esiste proprietà del gruppo if sProperty == 'MinDist' or sProperty == 'MinDistByPiece' then -- ottimizzare alla minima distanza -- prendo l'ultima lavorazione inserita ( lavorazione o disposizione) local LastMch = EgtGetLastOperation() local EndLastMach -- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then EgtSetCurrMachining( LastMch) EndLastMach = EgtGetMachiningEndPoint() end local nPz local nTotPz if sProperty == 'MinDistByPiece' then nTotPz = #tPz else nTotPz = 1 end for v = 1, nTotPz do local nPz if sProperty == 'MinDistByPiece' then nPz = tPz[v] else nPz = tPz end local tMachining = {} -- creo lavorazioni del gruppo for k = 1, #tGroup do -- Recupero le entità local EntList = MB.FindEntitiesWithName( nPz, tGroup[k].Name..'_HIDE') local bAdjustHead = false -- Applico le lavorazioni for j = 1, #EntList do -- LAVORAZIONI local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMach = nMach - 30 -- se lavorazione corretta ottengo 1 o 2 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 local sMachining = EgtGetInfo( EntList[j], 'Machining') -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima if nMach > 0 and nMach < 4 then nMach = 1 end -- se è fuori range o non corrispondono le lavorazioni if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) -- se più di 1 entità le ordino if #tListSameMach > 1 then tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGroup, tGroup[k].Mach, tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH, tMachining) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end -- ordino le lavorazioni if #tMachining > 1 then -- Tavole per fresature da ordinare local TabMill = {} local TabMStEnP = {} local TabZMach = {} for k = 1, #tMachining do -- Se appartiene alla fase corrente e fresatura non vuota if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then EgtSetCurrMachining( tMachining[k][1]) local ptStart = EgtGetMachiningStartPoint() local ptEnd = EgtGetMachiningEndPoint() if ptStart and ptEnd then table.insert( TabMill, tMachining[k][1]) table.insert( TabMStEnP, { ptStart, ptEnd}) MB.InsZedByTool( TabZMach, tMachining, k) end end end -- calcolo ordinamento EgtSpInit() for k = 1, #TabMill do EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0, TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0) end if EndLastMach then EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90) else EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90) end local vMillOrd = EgtSpCalculate(SHP_TY.OPEN) EgtSpTerminate() -- applico ordinamento calcolato -- parto da LastMch precedente if vMillOrd then for k = 1, #vMillOrd do EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER) LastMch = TabMill[vMillOrd[k]] end end end end -- end for elseif sProperty == 'Layer' then -- lavorazione layer for v = 1, #tPz do local nPz = tPz[v] -- ottengo tutte le entità del gruppo local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, nPz, '_HIDE') -- Applico le lavorazioni for j = 1, #EntListGrp do local nParendId = EgtGetParent(EntListGrp[j]) -- Recupero la prima entità del layer padre local EntList = MB.FindEntities( nParendId, true) -- LAVORAZIONI local nMach = 1 -- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGroup, nNumMach, bOk, '_HIDE', tMainTabPar.MDC, EndLastMach) end end -- end for elseif sProperty == '' then -- proprietà nulla -- creo lavorazioni del gruppo for k = 1, #tGroup do -- Recupero le entità local EntList = MB.FindEntitiesWithName( tPz, tGroup[k].Name..'_HIDE') local bAdjustHead = false -- Applico le lavorazioni for j = 1, #EntList do -- LAVORAZIONI local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1 nMach = nMach - 30 -- se lavorazione corretta ottengo 1 local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0 local sMachining = EgtGetInfo( EntList[j], 'Machining') -- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima if nMach > 0 and nMach < 4 then nMach = 1 end if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then -- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza) local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, tMainTabPar.MDC) -- se più di 1 entità le ordino if #tListSameMach > 1 then tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach) EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT ) end bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGroup, tGroup[k].Mach, tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead, GEN_MACH) -- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto SetInfoTable( tListSameMach, 'Mach2nd', 1) local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1 if nNewMach > 30 and nNewMach < 40 then SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo elseif nNewMach > 40 and nNewMach < 50 then SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo end end end -- tolgo di mezzo le note secondarie for j = 1, #EntList do EgtRemoveInfo( EntList[j], 'Mach2nd') end end end end i = i + 1 end -- se ci sono state lavorazioni accodo la disposizione delle fase if nNumMach > 0 then sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n' end -- se sono al primissimo giro if not bGenFirstStep then -- la lavorazione di traslazione ha priorità sul ribaltamento -- se trovata traslazione setto il flag per il prossimo giro if bShiftMchng then bGenFirstStep = true if not bFirstStep then -- se sono già in ripresa porta resetto il contatore di lavorazioni saltate nNumMachSkip = 0 -- resetto per il prossimo giro end else -- se nessuna geometria skippata esco if nNumMachSkip and nNumMachSkip == 0 then bWork = false end -- se lavorazioni skippate abilito il ribaltamento porta in altra fase if nNumMachSkip and nNumMachSkip > 0 then -- con lavorazioni skippate ma già con pezzo non i prima face e non shiftato, esco if not bFirstStep then bWork = false else bFirstStep = false end nNumMachSkip = 0 -- resetto per il prossimo giro end end else -- altrimenti ho già fatto un giro e ho trovato la traslazione -- se nessuna geometria skippata esco if nNumMachSkip == 0 then bWork = false end -- se lavorazioni skippate abilito il ribaltamento porta in altra fase if nNumMachSkip and nNumMachSkip > 0 then nNumMachSkip = 0 -- resetto per il prossimo giro if bFirstStep then -- se ho terminato il giro con eventuale traslazione disabilito la traslazione -- disativo la traslazione sul giro successvo bShiftMchng = false -- disattivo il flag che indica di disporre la porta subito traslata bSmallShiftedDoor = false end bFirstStep = false end end -- controllo di sicurezza if nNumCycle > 4 then bWork = false end nNumCycle = nNumCycle + 1 end -- end while -------------------------- -------------------------- -- *** Tools Setup *** -------------------------- -------------------------- -- provo a importare l'attrezzaggio di default, se fallisce passo gli altri bSetUp = EgtImportSetup() sListTool = '' if bSetUp then -- se importato quello di default sSetup = EgtGetDefaultSetupName() -- verifico se l'attrezzaggio è idoneo bSetUp, tListError = EgtVerifyCurrSetup() -- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default if bSetUp then -- assegno nota con il nome del file setup assegnato EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) else -- preparo la lista degli utensili mancanti sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)' sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] for k = 1, #tListError do sListTool = sListTool .. '\n ' .. tListError[k] end end else sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], ' ') .. ' (from Default)' end -- se fallito quello di default o utensili mancanti provo quelli indicati nel CurrCamInfo if not bSetUp then local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default local nContImport = 0 -- ciclo tra quelli disponibili for k = 1, 30 do if not bSetUp then if k == 1 then sSetup = mCamData[nNumMachFromCam].Setup1 elseif k == 2 then sSetup = mCamData[nNumMachFromCam].Setup2 elseif k == 3 then sSetup = mCamData[nNumMachFromCam].Setup3 elseif k == 4 then sSetup = mCamData[nNumMachFromCam].Setup4 elseif k == 5 then sSetup = mCamData[nNumMachFromCam].Setup5 elseif k == 6 then sSetup = mCamData[nNumMachFromCam].Setup6 elseif k == 7 then sSetup = mCamData[nNumMachFromCam].Setup7 elseif k == 8 then sSetup = mCamData[nNumMachFromCam].Setup8 elseif k == 9 then sSetup = mCamData[nNumMachFromCam].Setup9 elseif k == 10 then sSetup = mCamData[nNumMachFromCam].Setup10 elseif k == 11 then sSetup = mCamData[nNumMachFromCam].Setup11 elseif k == 12 then sSetup = mCamData[nNumMachFromCam].Setup12 elseif k == 13 then sSetup = mCamData[nNumMachFromCam].Setup13 elseif k == 14 then sSetup = mCamData[nNumMachFromCam].Setup14 elseif k == 15 then sSetup = mCamData[nNumMachFromCam].Setup15 elseif k == 16 then sSetup = mCamData[nNumMachFromCam].Setup16 elseif k == 17 then sSetup = mCamData[nNumMachFromCam].Setup17 elseif k == 18 then sSetup = mCamData[nNumMachFromCam].Setup18 elseif k == 19 then sSetup = mCamData[nNumMachFromCam].Setup19 elseif k == 20 then sSetup = mCamData[nNumMachFromCam].Setup20 elseif k == 21 then sSetup = mCamData[nNumMachFromCam].Setup21 elseif k == 22 then sSetup = mCamData[nNumMachFromCam].Setup22 elseif k == 23 then sSetup = mCamData[nNumMachFromCam].Setup23 elseif k == 24 then sSetup = mCamData[nNumMachFromCam].Setup24 elseif k == 25 then sSetup = mCamData[nNumMachFromCam].Setup25 elseif k == 26 then sSetup = mCamData[nNumMachFromCam].Setup26 elseif k == 27 then sSetup = mCamData[nNumMachFromCam].Setup27 elseif k == 28 then sSetup = mCamData[nNumMachFromCam].Setup28 elseif k == 29 then sSetup = mCamData[nNumMachFromCam].Setup29 elseif k == 30 then sSetup = mCamData[nNumMachFromCam].Setup30 end -- se nome attrezzaggio non è vuoto if sSetup and #sSetup > 0 then bSetUp = EgtImportSetup(sSetup) end if bSetUp then -- se importato il fle da CurrCamInfo nContImport = nContImport + 1 -- verifico se l'attrezzaggio è idoneo bSetUp, tListError = EgtVerifyCurrSetup() if bSetUp then -- se è andato bene -- assegno nota con il nome del file setup assegnato EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup) break else -- se utensili mancanti prendo la lista e passo al successivo sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553] for k = 1, #tListError do sListTool = sListTool .. '\n ' .. tListError[k] end end else -- se non importato carico il messaggio di errore e passo al successivo sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k) end end end -- se nessuno è andato bene verifico se il primo era stato importato if not bSetUp then -- se ho importato almeno un attrezzaggio do errore if ( sDefSetUp and #sDefSetUp > 0) or nContImport > 0 then DGD.EMC = ' ' .. EgtDoorsMsg[551] bOk = false if #sListTool > 0 then DGD.EMC = DGD.EMC .. sListTool end else -- setup default non definito -- assegno ugualmente un attrezzaggio vuoto EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555]) end end end if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end -- Eventuale messaggio di errore if not bOk then DoorOutLog( string.format(EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina DGD.ERR = 20 DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) -- stampo gli errori del machiningBase if DGD.EMC and #DGD.EMC > 0 then DoorOutLog( DGD.EMC, 0) end DoorOutLog( string.format( EgtDoorsMsg[475], tMainTabPar.MN), 0) -- Error on machining calculation -- cancello il file cn e il txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc') EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con l'errore WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], tMainTabPar.MN)) if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD if DGD.EMC and #DGD.EMC > 0 then EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation else EgtOutBox( string.format( EgtDoorsMsg[475], tMainTabPar.MN), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation end end -- Salvo progetto EgtSaveFile() return false, nNumGroup end -- Forzo aggiornamento calcolo assi macchina e movimenti tra lavorazioni e finale EgtUpdateAllMachinings() -- Salvo progetto EgtSaveFile() -- NC code generation bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..EgtIf( nProbeMode ~= 1,'.cnc','.prb'), 'EgtCam5 - '..sFilePath) if bOk then if not DGD.ERR then DGD.ERR = 0 end DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], tMainTabPar.MN), 0) -- inizio lavorazione su macchina DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1) if not DGD.NCGEN then if DGD.ERM and #DGD.ERM > 0 then DoorOutLog( DGD.ERM, 0) -- stampo la disposizione nel log end end DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode) else -- altrimenti errore cn DGD.ERR = 20 DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup) -- cancello e ricreo il file txt EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt') --ricreo il file txt con la disposizione WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt') -- scrivo messaggio nei file log DoorOutLog( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), 0) -- Error on Nc part program generation -- se lanciato da DMach stampo anche un messaggio a video if not DGD or not DGD.NCGEN then DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0) EgtOutBox( string.format(EgtDoorsMsg[478], tMainTabPar.MN, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation end return false end -- reset librerie locali package.loaded[MachiningsTable] = nil package.loaded[MachiningsTableOrd] = nil return true, nNumGroup end return MachiningLoc