Files
datadoors/Machining_2.lua
Dario Sassi cc55202ec5 DataDoors 2.7c1 :
- primo commit con versione corrente.
2025-03-18 17:02:20 +01:00

2967 lines
137 KiB
Lua

--
-- EEEEEEEEEE GGGGGG wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwww wwww
-- EEEE GGGG GGGG wwww wwww wwww
-- EEEE GGGG wwww wwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEEEEE GGGG GGGGGGG wwww wwwwww wwww
-- EEEE GGGG GGGG wwww wwwwwwww wwww
-- EEEE GGGG GGGG wwww wwww wwww wwww
-- EEEEEEEEEE GGGGGGGGGG wwwwwwww wwwwwwww
-- EEEEEEEEEE GGGGGG wwwwwww wwwwwww
--
-- Machining_2.lua by EgalWare s.r.l. 2016/23/05
-- Autore: Dario Sassi
-- Machining generation for Doors program machine Multiax N1216
-- 2017.06.01 V1.011 FM Manage machining optimization
-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece
-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining
-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole
-- 2017.12.08 V1.015 FM Manage two new probe pointposition , before and after the hinge/pivot to probe always on left of hinge
-- (according to MDC door dispostion on table)
-- 2017.12.28 V1.016 FM Set note about hinge side machining
-- 2017.12.28 V1.016 FM Set note about hinge side profile
-- 2017.12.28 V1.016 FM Set note about door shift on Y with hinge not machined profile on reference
-- 2017.12.28 V1.016 FM Set note about door probe error on hinge not machined profile on reference
-- 2017.12.28 V1.016 FM Set note about lock side machining
-- 2018.02.22 V1.017 FM Fix rename offsetted probe geometry to leave enabled always the left probe geometry
-- (according to MDC door dispostion on table)
-- 2018.02.26 V1.0b1 FM Manage door dimension checking
-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces
-- 2018.10.18 V1.0b3 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles
-- 2018.10.19 V1.0b4 FM Make sure that use only enabled shuttle ( give nForceUseShuttle into AdjustHead)
-- 2018.10.23 V1.0b5 FM Manage rough machining
-- 2018.11.05 V1.0b6 FM Change the percentage of shuttle assignement to variable dPercentDoorLength (by Mark requests)
-- 2019.01.14 V1.0b7 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set
-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name)
-- 2019.01.23 V1.0b8 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files.
-- 2019.01.24 V1.0b9 FM Extend cases to machine with AdjustHeadChisel operation,
-- use new settings to use with this extended operation: NO_WORK_UPSQUARE, CHISEL_ONLY_HORIZONTAL
-- 2019.03.27 V1.0c1 FM Manage check door/jamb dimension by function CheckPieceDimension
-- 2019.03.27 V1.0c2 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values
-- 2019.03.27 V1.0c2 FM Modify error messages format into CheckPieceDimension
-- 2019.03.27 V1.0c3 FM Manage estimate time
-- 2019.03.29 V1.0c4 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles
-- 2019.04.08 V1.0c5 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines
-- Now it uses 1 line for antisplint blade and 1 line for normal blade
-- 2019.04.08 V1.0c5 FM Manage Blade groove function AdjustBladeVertCurve
-- 2019.04.30 v1.0c6 FM Manage function AdjustASplintWithBlade to manage anti-splint paths when machine groove by blade
-- 2019.04.30 v1.0c6 FM Manage function AdjustHeadOnASplint to manage hinge anti-splint paths when machine groove by blade
-- 2019.05.28 v1.0c7 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings
-- 2019.07.22 V1.0c8 FM Manage better the updoor/underdoor machinings counter that generate flags values
-- 2019.08.27 V1.0c9 FM Manage underneath machining checking (by machining note 'UD_CHECK') to disable vacuums
-- (use new underneath distance by variable dDistInterferUnder)
-- 2020.03.19 V1.0d0 FM Fix error on check door dimension into CheckPieceDimension (when door is shifted by Bullnose profile on hinge side)
-- 2021.05.06 V1.0d1 FM Change the percentage of shuttle assignement to variable dPercentDoorLength if door length is more than 2700mm (long door limit)
-- 2021.05.28 V1.0d2 FM Add managing new one special code p6
-- 2021.06.01 v1.0d3 FM Fix error on calculate piece box
-- 2021.10.28 V1.0d4 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter
-- 2022.07.27 V1.0d5 FM Modification to use compiled code
-- 2023.03.29 V1.0d6 FM Fix error on calculate rough paths on Convex profile
-- 2023.03.31 V1.0d7 FM Manage offsetted path ( by path note) to extra path of Convex profile
-- 2023.12.01 V1.0d8 FM Manage small planes on Convex profile
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
local MachiningLoc = {}
-- Librerie particolari
local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
require( 'EgtDoorsBase')
require( 'EgtDoorsData')
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local MB = require( 'MachiningBase')
-- Impostazioni Cam per consentire forature con utensile più piccolo
EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50)
EgtMdbSave()
-- Definizione disposizione porta ( a sinistra : 1, a destra : -1)
local DISPMODE = -1
-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra)
local NO_WORK_UNDERSQUARE = false
-- Definizione possibilità di lavorare soprasquadra nei profili bevel ( true: non lavora soprasquadra, false: possibile lavorare soprasquadra)
local NO_WORK_UPSQUARE = false
-- Definizione possibilità di lavorare testa chisel rimanendo solo orizzontale o seguendo il bevel ( per teste non shuttle)
local CHISEL_ONLY_HORIZONTAL = false
-- variabili generazione lavorazioni
local GEN_MACH = false
local NOT_GEN_MACH = true
-- Variabile distanza minima tra pezzo finito e ventosa (in X)
local DIST_MIN_VAC_L = 5
local DIST_MIN_VAC_R = 7.5
-- variabile per applicare sempre la lavorazione degli anti-scheggia fatti con gli shuttle ( >= 4 inserisce solo quelle necessarie, < 4 inserisce tutte)
-- in caso il groove sia fatto con lama
local MAXMACH = 4
-- variabile che indica se sono state inserite lavorazioni da sotto
local bMachUnder
-- variabile dimensione porta considerata lunga che segna il diverso parcheggio dello shuttle 1 come è settata nella macro P5INIT
local Big_Dorr_Height
-----------------------------------------------------------------
-- *** Error write file ***
-----------------------------------------------------------------
local function WriteErrFile( sFileErr, sDispMsg)
local nIdFile = io.open( sFileErr, 'w')
if nIdFile then
if DGD.ERR == 0 then
if DGD.ERM and #DGD.ERM > 0 then
nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM)
else
nIdFile:write( 'Err=' .. tostring( DGD.ERR))
end
else
if DGD.EMC and #DGD.EMC > 0 then
nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.EMC)
else
nIdFile:write( 'Err=' .. tostring( DGD.ERR))
end
end
if sDispMsg and #sDispMsg > 0 then
nIdFile:write('\n' .. sDispMsg)
end
nIdFile:close()
end
end
-----------------------------------------------------------------
-- *** Add machining combine in table for second part ***
-----------------------------------------------------------------
local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab)
if tSecMcng then
if #tSecMcng > 0 then
local bFound = false
MTMachLine.Row = nIndexTab
for k = 1, #tSecMcng do
if MTMachLine == tSecMcng[k] then
bFound = true
end
end
-- se non trovato lo inserisco
if not bFound then
table.insert( tSecMcng,MTMachLine)
end
else
MTMachLine.Row = nIndexTab
table.insert( tSecMcng,MTMachLine)
end
end
return tSecMcng
end
local function SetInfoTable( tListEnt, sNameInfo, nValInfo)
for j = 1, #tListEnt do
if tListEnt[j] then
EgtSetInfo( tListEnt[j], sNameInfo, nValInfo)
end
end
end
-----------------------------------------------------------------
-- *** Apply Machining by Mach number ***
-----------------------------------------------------------------
local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach,
sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote,
bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed )
local dOverL = EgtGetInfo( tEndId[1], 'OL')
local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd')
local nOffsetDel = EgtIf( bNotGenMachining, 20, 0)
local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0)
if nMach == 1 then
local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel)
end
if bNotGenMachining then
nNumMach = nNumMach + 1
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel)
SetInfoTable( tEndId, 'Machining', sMach)
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
-- cerco se nelle note ho quella per l'aggregato da sotto
if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota
local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true)
if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto
SetInfoTable( tEndId, 'UnderneathMach', true)
bMachUnder = true
end
end
end
end
elseif nMach == 2 then
local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel)
end
if bNotGenMachining then
nNumMach = nNumMach + 1
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel)
SetInfoTable( tEndId, 'Machining', sMachUp)
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
-- cerco se nelle note ho quella per l'aggregato da sotto
if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota
local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true)
if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto
SetInfoTable( tEndId, 'UnderneathMach', true)
bMachUnder = true
end
end
end
end
elseif nMach == 3 then
local nRes, nMachId, sToolName, sNotesMach = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel)
end
if bNotGenMachining then
nNumMach = nNumMach + 1
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel)
SetInfoTable( tEndId, 'Machining', sMachDw)
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
-- cerco se nelle note ho quella per l'aggregato da sotto
if sNotesMach and #sNotesMach > 0 then -- se la nota non è vuota
local nPosFind, _ = sNotesMach:find( 'UD_CHECK', 1, true)
if nPosFind then -- se trovata nota aggiungo nota alle geometrie per indicare che è lavorata da sotto
SetInfoTable( tEndId, 'UnderneathMach', true)
bMachUnder = true
end
end
end
end
end
return bOk, nNumMach, tMachining
end
-----------------------------------------------------------------
-- *** Calc Machining for same group ***
-----------------------------------------------------------------
local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach,
nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed )
local nParendId = EgtGetParent(nEndId)
local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo
local sLocMachId
local bNotGenMachining = true
-- ordinare lavorazioni navette come scritto su foglio nella documentazione
for i = 1, #tLocTable do
if tLocTable[i].On ~= 0 then
sLocMachId = tLocTable[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name)
-- Applico le lavorazioni
for j = 1, #EntList do
local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1
if ( tLocTable[i].Oper == 'AdjustHead' or tLocTable[i].Oper == 'AdjustHeadOnASplint') and nMachCk > 0 and nMachCk < 10 then
-- assegno la stessa nota nMach dell'entità del gruppo
EgtSetInfo( EntList[j], 'Mach', nMach)
-- duplico entià
local nNewEntId = MB.MakeGhostCopy( EntList[j])
-- carico id entità in una tabella
local tListSameMach = {}
table.insert( tListSameMach, nNewEntId)
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach,
tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
end
end
end
return bOk, nNumMach
end
-----------------------------------------------------------------
-- *** Add Machining for same group ***
-----------------------------------------------------------------
local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup,
nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach,
dBladePerpLeadIn, dPercRedFeed)
local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo
-- ordinare lavorazioni navette come scritto su foglio nella documentazione
for i = 1, #tLocTable do
-- Recupero le entità
local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName)
-- Applico le lavorazioni
for j = 1, #EntList do
local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end
if nMachCk > 0 and nMachCk < 10 then
local nNewEntId = EntList[j]
local sMachining = EgtGetInfo( nNewEntId, 'Machining')
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach,
tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true,
GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
end
-- tolgo di mezzo le note secondarie
for j = 1, #EntList do
EgtRemoveInfo( EntList[j], 'Mach2nd')
end
end
return bOk, nNumMach
end
-----------------------------------------------------------------
-- *** Movimento ventose ***
-----------------------------------------------------------------
local ThroughId, BlindId
-----------------------------------------------------------------
local function StartVacVerify( nIdSolid, bFlipped)
-- regioni passante e cieca non definite
EgtErase( ThroughId or GDB_ID.NULL)
ThroughId = nil
EgtErase( BlindId or GDB_ID.NULL)
BlindId = nil
-- recupero le regioni sopra e sotto della porta messa in macchina
local UpId, DwId
-- se porta ribaltata
if bFlipped then
-- superficie a contatto con le ventose
DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true)
-- superficie sopra
UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true)
else
-- superficie a contatto con le ventose
DwId = MB.FindGeomWithName( nIdSolid, 'FLAT_DW', true)
-- superficie sopra
UpId = MB.FindGeomWithName( nIdSolid, 'FLAT_UP', true)
end
-- creo le regioni complementari
local b3Up = EgtGetBBoxGlob( UpId, GDB_BB.EXACT)
local CompUpId = EgtSurfFrRectangle( nIdSolid, b3Up:getMin(), b3Up:getMax(), GDB_RT.GLOB)
local vtNUp = EgtSurfFrNormVersor( UpId, GDB_ID.ROOT)
local vtNCompUp = EgtSurfFrNormVersor( CompUpId, GDB_ID.ROOT)
if not AreSameVectorApprox( vtNUp, vtNCompUp) then EgtInvertSurf( CompUpId) end
EgtSurfFrSubtract( CompUpId, UpId)
if not EgtExistsObj( CompUpId) then CompUpId = nil end
local b3Dw = EgtGetBBoxGlob( DwId, GDB_BB.EXACT)
local CompDwId = EgtSurfFrRectangle( nIdSolid, b3Dw:getMin(), b3Dw:getMax(), GDB_RT.GLOB)
local vtNDw = EgtSurfFrNormVersor( DwId, GDB_ID.ROOT)
local vtNCompDw = EgtSurfFrNormVersor( CompDwId, GDB_ID.ROOT)
if not AreSameVectorApprox( vtNDw, vtNCompDw) then EgtInvertSurf( CompDwId) end
EgtSurfFrSubtract( CompDwId, DwId)
if not EgtExistsObj( CompDwId) then CompDwId = nil end
if CompDwId then EgtInvertSurf( CompDwId) end
-- calcolo le regioni passante e cieca
local ThroughRegId = nil
local BlindRegId = nil
-- se ci sono entrambe le regioni
if CompUpId and CompDwId then
-- per ottenere la regione passante faccio intersezione tra sopra e sotto
EgtSurfFrIntersect( CompUpId, CompDwId)
if EgtExistsObj( CompUpId) then
ThroughRegId = CompUpId
end
-- per ottenere la regione cieca faccio differenza tra sotto e passante
if ThroughRegId then
EgtSurfFrSubtract( CompDwId, ThroughRegId)
if EgtExistsObj( CompDwId) then
BlindRegId = CompDwId
end
else
BlindRegId = CompDwId
end
-- se c'è solo la regione sotto è già quella delle lavorazioni cieche
elseif CompDwId then
BlindRegId = CompDwId
-- se c'è solo la sopra, non interessa e la cancello
elseif CompUpId then
EgtErase( CompUpId)
end
-- sistemazioni finali
if ThroughRegId then
ThroughId = EgtGroup( GDB_ID.ROOT)
EgtSetName( ThroughId, 'THROUGH')
EgtSetColor( ThroughId, RED())
EgtSetLevel( ThroughId, GDB_LV.TEMP)
local nChunk = 0
while EgtExtractSurfFrChunkLoops( ThroughRegId, nChunk, ThroughId) do
nChunk = nChunk + 1
end
EgtErase( ThroughRegId)
--EgtSetName( ThroughRegId, 'THROUGH')
--EgtSetColor( ThroughRegId, RED())
--EgtSetLevel( ThroughRegId, GDB_LV.TEMP)
end
if BlindRegId then
BlindId = EgtGroup( GDB_ID.ROOT)
EgtSetName( BlindId, 'BLIND')
EgtSetColor( BlindId, BLUE())
EgtSetLevel( BlindId, GDB_LV.TEMP)
local nChunk = 0
while EgtExtractSurfFrChunkLoops( BlindRegId, nChunk, BlindId) do
nChunk = nChunk + 1
end
EgtErase( BlindRegId)
--EgtSetName( BlindRegId, 'BLIND')
--EgtSetColor( BlindRegId, BLUE())
--EgtSetLevel( BlindRegId, GDB_LV.TEMP)
end
end
-----------------------------------------------------------------
local function ExecVacVerify( ptVac, Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder)
-- verifica con le regioni passanti
local nId = EgtGetFirstInGroup( ThroughId or GDB_ID.NULL)
while nId do
local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT)
if ptNear then
local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) +
( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2]))
-- se distanza inferiore al limite ...
if dDist < dDistInterferThru then
return false
end
end
nId = EgtGetNext( nId)
end
-- verifica con le regioni cieche
nId = EgtGetFirstInGroup( BlindId or GDB_ID.NULL)
while nId do
local ptNear = EgtNP( nId, ptVac, GDB_ID.ROOT)
if ptNear then
local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) +
( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2]))
-- se distanza inferiore al limite ...
if dDist < dDistInterferBlind then
return false
end
end
nId = EgtGetNext( nId)
end
-- se ho delle lavorazioni da sotto
if bMachUnder then
local tUnderList = {}
tUnderList = MB.FindGeomWithNote( Pz, 'UnderneathMach', 'b', true, tUnderList)
for i = 1, #tUnderList do
local ptNear = EgtNP( tUnderList[i], ptVac, GDB_ID.ROOT)
if ptNear then
local dDist = sqrt( ( ptNear[1] - ptVac[1]) * ( ptNear[1] - ptVac[1]) +
( ptNear[2] - ptVac[2]) * ( ptNear[2] - ptVac[2]))
-- se distanza inferiore al limite ...
if dDist < dDistInterferUnder then
return false
end
end
end
end
-- nessuna interferenza
return true
end
-----------------------------------------------------------------
local function EndVacVerify()
-- cancello regioni passante e cieca
EgtErase( ThroughId or GDB_ID.NULL)
ThroughId = nil
EgtErase( BlindId or GDB_ID.NULL)
BlindId = nil
end
-----------------------------------------------------------------
local function MoveVac( nGroupId, sName, dVal)
local nId = EgtGetFirstNameInGroup( nGroupId or GDB_ID.NULL, sName)
local dOldVal = EgtGetInfo( nId, 'Val', 'd')
EgtMove( nId, Vector3d( 0, 0, dVal - dOldVal), GDB_RT.GLOB)
EgtSetInfo( nId, 'Val', dVal)
end
-----------------------------------------------------------------
local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer)
-- Box solido: lo ottengo dalla somma delle varie superfici della porta
local tListFaces = {}
if nProbeMode == 2 then
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2'))
else
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW'))
end
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE'))
-- aggiungo anche il layer AUX escludendo il testo
if nAuxLayer then
local nIdGeom = EgtGetFirstInGroup(nAuxLayer)
local nTypeEnt
while nIdGeom do
-- se elemento passato è un testo lo escludo
nTypeEnt = EgtGetType( nIdGeom)
if nTypeEnt ~= GDB_TY.EXT_TEXT then
table.insert( tListFaces, nIdGeom)
end
nIdGeom = EgtGetNext(nIdGeom)
end
end
local b3fx = BBox3d() -- inizializzo il box nullo
for i = 1, #tListFaces do
if tListFaces[i] then
local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT)
b3fx:Add(b3f1)
end
end
return b3fx
end
-----------------------------------------------------------------
local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr,
ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth,
dMaxDoorWidth, dMinDoorThick, dMaxDoorThick)
local bFailDim = false
local sErrMess = ''
local dLimitToCheck
dLimitToCheck = dMinDoorLength - abs(ShiftXOri)
if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr),
EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMaxDoorLength - abs(ShiftXOri)
if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr),
EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
-- dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri)
dLimitToCheck = dMinDoorWidth + abs(ShiftYOri)
if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)),
EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
-- dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri)
dLimitToCheck = dMaxDoorWidth + abs(ShiftYOri)
if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)),
EgtToUiUnits(abs(ShiftYOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMinDoorThick
if dThickDoor < dLimitToCheck then -- se spessore inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMaxDoorThick
if dThickDoor > dLimitToCheck then -- se spessore superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
return bFailDim
end
-----------------------------------------------------------------
-- *** Funzione di generazione lavorazioni ***
-----------------------------------------------------------------
function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup)
--macchina e tabella di default
local MachName = 'Multiax-'
-- Machinings Tables
local MachiningsTable = 'MachStdTable'
local MachiningsTableOrd = 'MachStdTable_Ord'
-- References on table (respect Zero machine)
-- Y Table
local Ori1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH
local Ori2 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH
-- shift value
local vShift = Vector3d(0,0,0)
local vShiftVac = Vector3d(0,0,0)
local vShiftAct = Vector3d(0,0,0)
local vNullShift = Vector3d(0,0,0)
local vShiftLockSide = Vector3d(0,0,0)
-- variabile per posizione media della porta per il cambio navette
local dPosShuttleChange = 40 * GEO.ONE_INCH
-- tabella raggi profili su ogni lato
local tsRadiusProf = {}
local tsPlaneProf = {}
-- utilizzo la tabella dati cam
local sPathCurrMachtabOri = 'CurrCamInfo'
local mCamData = require( sPathCurrMachtabOri)
-- variabili pezzo singolo
local nPz
local sAssemb
-- variabile check dimensioni porta
local bFailDim = false
-- resetto la macchinata (riporto il pezzo in area disegno)
EgtResetCurrMachGroup()
-- elimino percorsi eventualmente creati dal Mach
-- cancello tutti i percorsi ghost
local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE')
-- ciclo su tutte le entità trovate
for j = 1, #DelList do
EgtErase( DelList[j] )
end
DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_')
-- ciclo su tutte le entità trovate
for j = 1, #DelList do
EgtErase( DelList[j] )
end
-- se la variabile è una tabella, estrapolo solo la porta
local PzIsTab = type(tPz) == 'table'
if PzIsTab then
for v = 1, #tPz do
Pz = tPz[v]
sAssemb = tsAssemb[v]
-- se non ha nota o nota della prima porta esco
if not sAssemb or ( sAssemb and sAssemb == 'first') then
break
end
end
else
Pz = tPz
sAssemb = tsAssemb
end
--------------------------------------------------------------------------------
-- Dati della porta
local sDoorCode = EgtGetInfo( Pz, 'Code')
local dWidthDoor = EgtGetInfo( Pz, 'W', 'd')
local dLengthDoor = EgtGetInfo( Pz, 'H', 'd')
local dThickDoor = EgtGetInfo( Pz, 'T', 'd')
local sSwing = EgtGetInfo( Pz, 'Swing')
MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente
local sSecure = EgtGetInfo( Pz, 'Secure')
local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming')
local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming')
local sTopTrim = EgtGetInfo( Pz, 'top_trimming')
local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming')
local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b')
local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b')
local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b')
local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b')
local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra
local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' )
local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' )
tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd')
tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd')
tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd')
tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd')
tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd')
tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd')
tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd')
tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd')
local dRadiusPrf = tsRadiusProf[1]
local dPlanePrf = tsPlaneProf[1]
local dNumHingesPivots = EgtGetInfo( Pz, 'NumHingesPivots', 'd') or 0
local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0
local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0
local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0
local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0
-- Box pezzo
local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID')
local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT)
local b3fx = BBox3d() -- inizializzo il box nullo
b3fx = MakeBoxFromSolidLayer( Ls, 0, Aux)
local b3Solid = b3fx
-- local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
-- Project path, name, extension
local sFilePath = EgtGetCurrFilePath()
local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath)
------------------------------------------------------
-- se codice porta contiene comandi speciali
-- che non producono la generazione del part program della porta ma dei part program speciali
if sDoorCode then
local sCode = string.lower(sDoorCode)
if sCode == 'p1' or sCode == 'p2' or sCode == 'p3' or sCode == 'p4' or sCode == 'p5' or sCode == 'p6' then
EgtSetInfo( Pz, 'SpecialCmd', sCode)
end
end
------------------------------------------------------
--------------------------------------------------------------------------------
-- *** settaggi CAM *** -- Mtable 1
if not MachiningsTable then -- se non c'è il nome della MTable esco
DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato
return false
end
EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl')
local TAB
if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then
TAB = require( MachiningsTable)
if not TAB then
DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file
return false
end
else
DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato
return false
end
local MachinesName = TAB.MMachineData
if not MachinesName then
DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable
return false
end
-- *** settaggi CAM *** -- Mtable 2
MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0)
EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl')
local TABORD
if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then
TABORD = require( MachiningsTableOrd)
if not TABORD then
DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file
return false
end
else
DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file
return false
end
local dMaxDoorLength
local dMinDoorLength
local dMaxDoorWidth
local dMinDoorWidth
local dMaxDoorThick
local dMinDoorThick
local nForceUseShuttle
local nForceDisableHood
local dAltRef
local dTallRef
local sLocSecure
local dMaxOverMat
local dStepOverMat
local dMaxDistToChain
local dExtraThruDepth
local nGenCncAsDdfName
local dBladePerpLeadIn
local dPercRedFeed
-- imposto i dati macchina secondo le informazioni del file cam
MachName = mCamData[nNumMachFromCam].MachName
Ori1 = mCamData[nNumMachFromCam].Ori1
Ori2 = mCamData[nNumMachFromCam].Ori2
vShiftAct = mCamData[nNumMachFromCam].Shift1
vShiftLockSide = mCamData[nNumMachFromCam].ShiftLck
dMaxDoorLength = mCamData[nNumMachFromCam].MaxDoorLength
dMinDoorLength = mCamData[nNumMachFromCam].MinDoorLength
dMaxDoorWidth = mCamData[nNumMachFromCam].MaxDoorWidth
dMinDoorWidth = mCamData[nNumMachFromCam].MinDoorWidth
dMaxDoorThick = mCamData[nNumMachFromCam].MaxDoorThick
dMinDoorThick = mCamData[nNumMachFromCam].MinDoorThick
nForceUseShuttle = mCamData[nNumMachFromCam].ForceShuttleUse
nForceDisableHood = mCamData[nNumMachFromCam].ForceDisableHood
dAltRef = mCamData[nNumMachFromCam].dAltRef
dTallRef = mCamData[nNumMachFromCam].dTallRef
sLocSecure = mCamData[nNumMachFromCam].sLocSecure
dMaxOverMat = mCamData[nNumMachFromCam].MaxOverMat
dStepOverMat = mCamData[nNumMachFromCam].StepOverMat or 10
dMaxDistToChain = mCamData[nNumMachFromCam].MaxDistToChain
dExtraThruDepth = mCamData[nNumMachFromCam].ExtraThruDepthMachining
nGenCncAsDdfName = mCamData[nNumMachFromCam].nGenCncAsDdfName or 0
dBladePerpLeadIn = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4)
dPercRedFeed = mCamData[nNumMachFromCam].PercRedFeed or 0.3
Big_Dorr_Height = mCamData[nNumMachFromCam].BigDoorHeight or 2700.0
-- se non devo generare il cn esco subito
if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then
DoorOutLog( string.format(EgtDoorsMsg[492], MachName), 0) -- warning. Cnc generation disable
return true
end
-- setto come generare il nome del file cnc (di default è uguale al nome del parametro interno ad ddf)
if nGenCncAsDdfName == 0 then
-- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi
sFileName = sDoorCode
end
local MTable = TAB.MTable
local MTableOrd = TABORD.MTable
-- variabile principale per definizione disposizione porta a destra o sinistra
local sLocMachId
local bOk = true
local bFirstStep = true
local bShiftedDoor = false
local sDispMode
local sTotDispMode = ''
local sNumGroup = ''
local bWork = true
-- variabili utilizzate dentro al ciclo
local nMchId
local sTab
local tabOri
local Ori
local ColA
local nRaw
local bMoveRaw
local bPush
local bFlip
local bTopOnRight
-- variabili per disposizione sottopezzi
local dMobOffs
local dVacOffs
local dDistMinX
local dDistMaxX
local dVacOn
local dInterAx
local OffsXSovr = 0
local OffsYSovr = 0
local dDistInterferThru
local dDistInterferBlind
local dDistInterferUnder
-- variabile per tool setup
local MSetup
local sSetup
-- variabili calcolo box
local b3SolidOnTab
local pMin
local pMax
-- variabili conteggio lavorazioni profilatura bevel e saltate
local nNumMachSkip = 0
local bLocMach
local sMachProf
local bNoVertProf = true
local bWorkUnder = true
-- variabile per conteggio lavorazioni
local nNumMach
local nNumSkip
local tSecMachTab = {}
-- variabili per fase
local nNumPhase
local nNumCycle = 1
-- variabili per gestione ripresa porta
local bFlipFirst
local bTopOnRightFirst
local sProfiles = ''
local nNumGeomBottom = 0
local nNumGeomTop = 0
local nNumGeomBottomHole = 0
local nNumGeomTopHole = 0
-- variabili per geometrie lato Hinge
local nNumTopGeom = 0
local nNumBottomGeom = 0
-- variabile piazzamento porta
local sLight
-- variabile direzione riordino gruppi
local nDirReorderGroups
-- tabella lavorazioni
local tLocMach = {}
local tLocMachOrd = {}
-- Set Current Machine: si setta sulla fase 1
EgtSetCurrMachine( MachName)
-------------------------------------------------------------------------------------------------------
-- per questa macchina è importante differenziare il nome del profilo lato lock rispetto al lato hinge
-- in modo che venga lavorato prima il lato hinge e poi il lock
-------------------------------------------------------------------------------------------------------
-- Recupero le entità
local nLockProf
-- se serratura è a destra cerco il nome dl profilo corrispondente a quel lato
if bAtRight then
nLockProf = EgtGetFirstNameInGroup( Pz, 'Right')
else
nLockProf = EgtGetFirstNameInGroup( Pz, 'Left')
end
local EntListHg = MB.FindEntities( nLockProf)
sLockTrim = sLockTrim..'_LK'
-- rinomino tutte le entità del gruppo
for j = 1, #EntListHg do
local sNameEnt = EgtGetName( EntListHg[j])
if not string.find( sNameEnt, '_LK') then
sNameEnt = sNameEnt .. '_LK'
end
EgtSetName( EntListHg[j], sNameEnt)
end
-- faccio tutte le fasi ( probabilmente solo una perché non sono previsti ribaltamenti)
while bWork do
sDispMode = ''
bMachUnder = nil
nNumGroup = nNumGroup + 1
-- Set Machining Group
if not sAssemb then -- se pezzo unico
nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName)
else
nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName)
end
nNumPhase = EgtGetCurrPhase()
-----------------------------------------------------------------------
-- Calcolo dei sovramateriali e definizione e posizionamento del grezzo
-----------------------------------------------------------------------
-- se check macchina settato per non gestire grezzo
if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then
dLeftOffs = 0
dRightOffs = 0
dTopOffs = 0
dBottomOffs = 0
end
ColA = Color3d( 255, 165, 0, 15)
nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs,
b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA)
EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs, dBottomOffs, 0), nRaw)
-- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe,
-- decido su quale lato disporre la porta per evitare inutili ribaltamenti
-- ricavo minimo e massimo del solido del pezzo
b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
pMin = b3SolidOnTab:getMin()
pMax = b3SolidOnTab:getMax()
tLocMach = MTable
tLocMachOrd = MTableOrd
sMachProf = ''
-- prendo nota dei profili tipo bevel e bull nose
-- verifico se cave da sotto o da sopra
-- verifico se trovate lavorazioni applicate con 'shift'
local nUnderGeom
for i = 1, #tLocMach do
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
-- se non c'è il campo macchina setto di default la 1
if not sLocMachId then sLocMachId = 1 end
-- se macchina corrispondente
if sLocMachId == nNumMachFromTable then
local sUpperProfName = string.upper(tLocMach[i].Name)
-- prendo i profili bevel direttamente dalla tabella
if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then
if not string.find( sProfiles, sUpperProfName) then
sProfiles = sProfiles .. sUpperProfName .. ','
end
end
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- Test delle lavorazioni
for j = 1, #EntList do
-- OPERAZIONI
if tLocMach[i].Oper == 'AdjustThrouIsle' then
bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder)
if bLocMach then
if nUnderGeom and nUnderGeom == 1 then
nNumGeomBottom = nNumGeomBottom + 1
elseif nUnderGeom and nUnderGeom == -1 then
nNumGeomTop = nNumGeomTop + 1
end
end
elseif tLocMach[i].Oper == 'AdjustVertHole' then
bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder)
if bLocMach then
if nUnderGeom and nUnderGeom == 1 then
nNumGeomBottom = nNumGeomBottom + 1
nNumGeomBottomHole = nNumGeomBottomHole + 1
elseif nUnderGeom and nUnderGeom == -1 then
nNumGeomTop = nNumGeomTop + 1
nNumGeomTopHole = nNumGeomTopHole + 1
end
end
end
end
end
end
end
-----------------------
-- *** Disposizione ***
-----------------------
-- controllo se ho profili bullnose sul lato hinge (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE)
if ( sHingeTrim == '1B' or sHingeTrim == '2B') then -- se profilo cerniere è bullnose
bShiftedDoor = true
end
-- controllo se ho profili bullnose sul lato serratura (INDIPENDENTEMENTE CHE SIANO O MENO DA LAVORARE)
if ( sLockTrim == '1B_LK' or sLockTrim == '2B_LK' or sLockTrim == '3B_LK' or sLockTrim == '4B_LK') then -- se profilo serratura indicato è bullnose
vShiftVac = vShiftLockSide
else
vShiftVac = vNullShift
end
-- Scelta della tavola
sTab = 'Tab'
EgtSetTable( sTab)
-- Origine tavola corrente rispetto a Zero macchina
tabOri = EgtGetTableRef( 1)
-- Scelta dell'origine (ora espressa rispetto Zero Tavola)
Ori = EgtIf( DISPMODE > 0, Ori1, Ori2)
-- se porta da traslare setto lo shift da applicare
if bShiftedDoor then
vShift = vShiftAct
else
vShift = vNullShift
end
Ori = Ori + vShift
-- Rotazione porta in base alla macchina
bMoveRaw = false
-- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf
-- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello.
-- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge
-- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf
-- se non c'è il parametro considero la porta come se avesse bevel down
-- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData)
if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or
sSwing == 'LH' or sSwing == 'LHA' or sSwing == 'LHI' then
bPush = true
else
bPush = false
end
local sNumPhase
if nNumPhase and nNumPhase < 10 then
sNumPhase = '0'.. tostring( nNumPhase)
elseif nNumPhase then
sNumPhase = tostring( nNumPhase)
else
sNumPhase = '0'
end
local bOkDisp = false
-- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura,
-- se non ha bevel nemmeno il lato serratura considero il parametro secure
-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel e da lavorare
if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel
-- verifico se i profili risultanti sono presenti in tabella
if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or
( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
else
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
end
end
end
-- se profilo serratura indicato bevel (e da lavorare)
-- if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK') and bLockMach and not bOkDisp then
if ( sLockTrim == 'BD_LK' or sLockTrim == 'BU_LK' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB_LK') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sLockTrim == 'BD_LK' and bPush and string.find( sProfiles, 'BU_LK,') then
bOkDisp = true
elseif sLockTrim == 'BDEB_LK' and bPush and string.find( sProfiles, 'BU_LK,') then
bOkDisp = true
elseif sLockTrim == 'BD_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then
bOkDisp = true
elseif sLockTrim == 'BDEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then
bOkDisp = true
elseif sLockTrim == 'BU_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then
bOkDisp = true
elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then
bOkDisp = true
elseif sLockTrim == 'BU_LK' and bPush and string.find( sProfiles, 'BU_LK,') then
bOkDisp = true
elseif sLockTrim == 'BUEB_LK' and not bPush and string.find( sProfiles, 'BD_LK,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- a meno che ho il profilo opposto, in questo caso non ribalto la porta, altrimenti devo ribaltare la porta
-- e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sLockTrim == 'BD_LK' or sLockTrim == 'BDEB_LK') and bPush) or
( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and not bPush and not bOppoBevelProf) or
( ( sLockTrim == 'BU_LK' or sLockTrim == 'BUEB_LK') and bPush and bOppoBevelProf) then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
else
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
end
end
end
-- se profilo top indicato bevel (e da lavorare)
if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or
( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
else
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
end
end
end
-- se profilo top indicato bevel (e da lavorare)
if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or
( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
else
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
end
end
end
-- in caso non ci sia nessun profilo bevel verifico il parametro Secure
if not bOkDisp then
-- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore
if sSecure and string.upper(sSecure) == '0' then
-- se parametro da CurrcamInfo non è valido do errore
if not sLocSecure or ( string.upper(sLocSecure) ~= 'UP' and string.upper(sLocSecure) ~= 'DN') then
bOk = false
DGD.EMC = ' ' .. EgtDoorsMsg[590]
break
else
sSecure = sLocSecure
end
end
-- se lato secure va sopra il ribaltamento è obbligato
if sSecure and string.upper(sSecure) == 'UP' then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
elseif sSecure and string.upper(sSecure) == 'DN' then
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
-- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) quella di considerare la porta bevel down
-- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata
-- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData)
else
if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing
-- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down
if bPush then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
-- se porta a tirare non la ribalto perché si presta già ad essere bevel down
else
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
end
else -- in base alle geometrie trovate ribalto o meno la porta
if nNumGeomBottom > nNumGeomTop then
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
elseif nNumGeomTop >= nNumGeomBottom then
bFlip = false
if bAtRight then -- se serratura a destra
bTopOnRight = false
else
bTopOnRight = true
end
else -- altrimenti vecchio metodo
bFlip = true
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
end
end
end
end
-- faccio le rotazioni della porta
if bFlip then
EgtRotateRawPart( nRaw, Y_AX(), 180)
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479]
else
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480]
end
if bTopOnRight then
EgtRotateRawPart( nRaw, Z_AX(), -90)
sDispMode = sDispMode .. EgtDoorsMsg[481]
else
EgtRotateRawPart( nRaw, Z_AX(), 90)
sDispMode = sDispMode .. EgtDoorsMsg[482]
end
if bShiftedDoor then
sDispMode = sDispMode .. EgtDoorsMsg[510]
end
sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n'
------------------------------------------------------------------
-- calcolo delta Y in base al profilo e al ribaltamento del pezzo
------------------------------------------------------------------
local vExtraYDelta
local dExtraY = 0
local dDeltaProbe = 0
-- variabili per note relative al lato hinges
local nHingeMach = 0 -- setto default non lavorato
local nLockMach = 0 -- setto default non lavorato
local nSideType = -1 -- 0 per profili SQ
if sHingeTrim == 'SQ' or sHingeTrim == 'EB' then
nSideType = 0
-- se disposizione bevel down uso il riferimento in alto
elseif sHingeTrim == 'BD' or sHingeTrim == 'BDEB' then
nSideType = 1
if dThickDoor > dAltRef then
dExtraY = ( dThickDoor - dAltRef) * TAN3
end
-- calcolo errore del probe tastando a metà spessore
dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY
-- se disposizione bevel up uso il riferimento in basso
elseif sHingeTrim == 'BU' or sHingeTrim == 'BUEB' then
nSideType = 2
dExtraY = ( dAltRef - dTallRef) * TAN3
-- calcolo errore del probe tastando a metà spessore
dDeltaProbe = (( dThickDoor / 2) * TAN3) - dExtraY
-- se profilo bull nose verifico in base al raggio
elseif sHingeTrim == '1B' or sHingeTrim == '2B' or
sHingeTrim == '3B' or sHingeTrim == '4B' then
nSideType = 3
-- calcolo punto massimo ingombro profilo
local dAltProf = dThickDoor/2
local dAltcalc = 0
-- se punto max è sotto il minimo riferimento
if dAltProf < ( dAltRef - dTallRef) then
dAltcalc = dAltRef - dTallRef - dAltProf
-- se punto max è sopra il massimo riferimento
elseif dAltProf > dAltRef then
dAltcalc = dAltProf - dAltRef
end
-- se punto massimo profilo non è compreso nel riferimento calcolo il delta Y
if dAltcalc > 0 then
dExtraY = dRadiusPrf - sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc))
end
-- calcolo errore del probe tastando a metà spessore
dDeltaProbe = -dExtraY
-- se profilo convex verifico in base al raggio
elseif sHingeTrim == 'CV' then
nSideType = 4
-- calcolo punto minimo ingombro profilo
local dAltProf = dThickDoor/2
local dAltcalc = (dTallRef/2)
-- calcolo il delta Y massimo del minimo ingombro profilo
local dMaxInsPrf = sqrt((dRadiusPrf*dRadiusPrf)-((dAltProf-dPlanePrf)*(dAltProf-dPlanePrf)))
-- se riferimento è sul max ingombro porta
if ( dThickDoor < dAltRef) and ( dThickDoor > ( dAltRef - dTallRef)) then
dAltcalc = 0
-- se punto minimo ingombro profilo è sotto all'altezza media del riferimento
elseif dAltProf < ( dAltRef - (dTallRef/2)) then
dAltcalc = dAltRef - dAltProf
-- se punto minimo ingombro profilo è sopra all'altezza media del riferimento
elseif dAltProf > ( dAltRef - (dTallRef/2)) then
dAltcalc = dAltProf - dAltRef + dTallRef
end
-- calcolo il delta Y
if dAltcalc > 0 then
dExtraY = sqrt((dRadiusPrf*dRadiusPrf)-(dAltcalc*dAltcalc)) - dMaxInsPrf
end
-- calcolo errore del probe tastando a metà spessore
dDeltaProbe = dRadiusPrf - dExtraY
end
-- se profilo hinge è da lavorare annullo il delta Y e setto il valore della nota
if bHingeMach then
dExtraY = 0
nHingeMach = 1
dDeltaProbe = 0
end
-- se profilo lock da lavorare setto la variabile per la nota
if bLockMach then
nLockMach = 1
end
vExtraYDelta = Vector3d(0,-dExtraY,0)
-- scrivo le note
EgtSetInfo( Pz, 'ExtraCalcMoveY', dExtraY)
EgtSetInfo( Pz, 'DoorProbeErrorY', dDeltaProbe)
EgtSetInfo( Pz, 'SideDisposition', DISPMODE)
-- scrivo nota disabilitazione cuffia
EgtSetInfo( Pz, 'ForceDisableHood', nForceDisableHood)
-- scrivo nota lavorazione lato hinge
EgtSetInfo( Pz, 'SideHingeMach', nHingeMach)
-- scrivo nota tipo profilo lato hinge
EgtSetInfo( Pz, 'SideHingeProf', nSideType)
-- scrivo nota lavorazione lato lock
EgtSetInfo( Pz, 'SideLockMach', nLockMach)
-- sommo il delta spostamento
Ori = Ori + vExtraYDelta
-- Muovo porta con l'angolo indicato dal tipo di disposizione nella posizione di origine
bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, EgtIf( DISPMODE > 0, MCH_CR.BL, MCH_CR.BR))
-- memorizzo i flag per le fasi successive
bFlipFirst = bFlip
bTopOnRightFirst = bTopOnRight
if not bMoveRaw then
bOk = false
DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[474] -- Error positioning raw part on table
break
end
if bShiftedDoor then
-- salvo una nota con le info della disposizione traslata
EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode)
EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, 'SHIFT')
else
-- salvo una nota con le info della disposizione normale
EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode)
EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, 'NORMAL')
end
if bFlip then -- se porta capovolta
if bTopOnRight then -- se top a destra
-- il lato sinistro è quello delle hinges
OffsYSovr = dLeftOffs
OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs)
else -- se top a sinistra
-- il lato destro è quello delle hinges
OffsYSovr = dRightOffs
OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs)
end
else -- altrimenti non è capovolta
if bTopOnRight then -- se top a destra
-- il lato destro è quello delle hinges
OffsYSovr = dRightOffs
OffsXSovr = EgtIf( DISPMODE > 0, dBottomOffs, dTopOffs)
else -- se top a sinistra
-- il lato sinistro è quello delle hinges
OffsYSovr = dLeftOffs
OffsXSovr = EgtIf( DISPMODE > 0, dTopOffs, dBottomOffs)
end
end
-- Controllo dimensioni pezzo
-- controllo se le dimensioni porta sono compresi nei valori minimi e massimi
bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr,
vShift:getX(), vShift:getY(), dMinDoorLength, dMaxDoorLength, dMinDoorWidth,
dMaxDoorWidth, dMinDoorThick, dMaxDoorThick)
if bFailDim then
DGD.ERR = 19
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..'.txt')
-- se lanciato da DMach stampo anche un messaggio a video
if not DGD or not DGD.NCGEN then
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0)
DoorOutLog( DGD.EMC, 0)
EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation
end
return false
end
-------------------------------------------------------------------------------------------------------------
-- abilito/disabilito geometrie probe in base alla lavorazione del lato hinge e alla disposizione sulla tavola
-------------------------------------------------------------------------------------------------------------
if bHingeMach then -- se profilo hinge è da lavorare rinomino nome entita
-- Recupero le entità probe
local ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Hinge_Probe' )
end
ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_POS')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Hinge_Probe' )
end
ProbeList = MB.FindEntitiesWithName( Pz, 'Hinge_Probe_NEG')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Hinge_Probe' )
end
-- Recupero le entità pivot
ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Pivot_Probe' )
end
ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_POS')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Pivot_Probe' )
end
ProbeList = MB.FindEntitiesWithName( Pz, 'Pivot_Probe_NEG')
-- ciclo su tutte le entità trovate
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], 'NO_Pivot_Probe' )
end
else -- profilo hinge non lavorato
-- il probe deve essere sempre quello a sinistra rispetto al piazzamento
-- considerando lo swing perché le cerniere a seconda di questo vengono tuotate e il probe _POS e _NED risultano
-- scambiati rispetto al top della porta
local sProbeHingeToFind = ''
local sProbeHingeDis = ''
local sProbePivotToFind = ''
local sProbePivotDis = ''
if DISPMODE > 0 then -- se disposizione a sinistra
if ( bPush and bAtRight) or ( not bPush and not bAtRight) then
if not bTopOnRight then -- se top a sinistra
sProbeHingeToFind = 'Hinge_Probe_NEG'
sProbeHingeDis = 'NO_Hinge_Probe_NEG'
else -- top a destra
sProbeHingeToFind = 'Hinge_Probe_POS'
sProbeHingeDis = 'NO_Hinge_Probe_POS'
end
else
if not bTopOnRight then -- se top a sinistra
sProbeHingeToFind = 'Hinge_Probe_POS'
sProbeHingeDis = 'NO_Hinge_Probe_POS'
else -- top a destra
sProbeHingeToFind = 'Hinge_Probe_NEG'
sProbeHingeDis = 'NO_Hinge_Probe_NEG'
end
end
if not bTopOnRight then -- se top a sinistra
sProbePivotToFind = 'Pivot_Probe_NEG'
sProbePivotDis = 'NO_Pivot_Probe_NEG'
else -- se top è a destra
sProbePivotToFind = 'Pivot_Probe_POS'
sProbePivotDis = 'NO_Pivot_Probe_POS'
end
else -- disposizione a destra
if ( bPush and bAtRight) or ( not bPush and not bAtRight) then
if bTopOnRight then -- se top a destra
sProbeHingeToFind = 'Hinge_Probe_POS'
sProbeHingeDis = 'NO_Hinge_Probe_POS'
else -- top a sinistra
sProbeHingeToFind = 'Hinge_Probe_NEG'
sProbeHingeDis = 'NO_Hinge_Probe_NEG'
end
else
if bTopOnRight then -- se top a destra
sProbeHingeToFind = 'Hinge_Probe_NEG'
sProbeHingeDis = 'NO_Hinge_Probe_NEG'
else -- top a sinistra
sProbeHingeToFind = 'Hinge_Probe_POS'
sProbeHingeDis = 'NO_Hinge_Probe_POS'
end
end
if bTopOnRight then -- se top a destra
sProbePivotToFind = 'Pivot_Probe_POS'
sProbePivotDis = 'NO_Pivot_Probe_POS'
else -- se top a sinistra
sProbePivotToFind = 'Pivot_Probe_NEG'
sProbePivotDis = 'NO_Pivot_Probe_NEG'
end
end
local ProbeList = MB.FindEntitiesWithName( Pz, sProbeHingeToFind)
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], sProbeHingeDis)
end
ProbeList = MB.FindEntitiesWithName( Pz, sProbePivotToFind)
for j = 1, #ProbeList do
EgtSetName( ProbeList[j], sProbePivotDis)
end
end
-- *** Lavorazioni ***
-- setto variabili in funzione della disposizione porta
local bMakeGhost = true
nDirReorderGroups = DISPMODE
local dPercentDoorLength
---------------------------------------------------------------------------------------------------------------------------
-- 06/05/2021 in base al seguente avvenimento: porta lunga 3025 con 4 cerniere, 2 per ogni shuttle, e con una groove che
-- sborda sul lato cerniere. Alla chiamata della DANGER_L (nel Processo4) lo shuttle 1 a sinistra chiede di parcheggiare
-- nella posizione calcolata (L88) nel P5INIT che è a pacco con lo shuttle 2 nella parte destra della porta. L'arbitro non
-- da il consenso al parcheggio perchè la posizione è ancora occupata dallo shuttle 2 che sta lavorando e quindi manda
-- in parcheggio lo shuttle 1 fuori (tutto a sinistra) ma che, data la lunghezza elevata della porta, quando il gruppo 4
-- andando a lavorare la groove vicino al lato hinge, rischia di collidere con lo shuttle 1.
-- Quindi per ovviare al problema è stato stabilito, in accordo con Carlo Viviani, di controllare per prima
-- la dimensione della porta, e se la lunghezza porta è maggiore del valore stabilito nella macro P5INIT nella variabile
-- L116 (ad oggi al valore 2700mm) allora la percentuale di distribuzione cerniere passa a 52% da sinistra in ogni caso
---------------------------------------------------------------------------------------------------------------------------
if dLengthDoor >= Big_Dorr_Height then
dPercentDoorLength = EgtIf( DISPMODE > 0, 0.52, 0.48)
else
-------------------------------------------------------------------------------------------
-- in base alla richiesta di Mark Offman 18/10/2018
-------------------------------------------------------------------------------------------
-- assegno una percentuale di 0.5 allo shuttle di sinistra (Mark 18/10/2018)
-- ma con 3 cerniere o 3 pivot, cambio la percentuale, cioè 0.4 da sinistra
dPercentDoorLength = EgtIf( DISPMODE > 0, EgtIf( dNumHingesPivots == 3 ,0.5, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.5))
-------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------
-- Vecchia disposizione di Viviani
-------------------------------------------------------------------------------------------
-- assegno una percentuale di 0.6 sempre verso lo shuttle di sinistra (Viviani 30/01/2017)
-- se disposta a sinistra assegno 0.6 da sinistra, se disposta a destra assegno 0.4 da destra, il risultato è quindi
-- sempre 0.6 da sinistra
-- ma con 3 cerniere o 3 pivot, inverto la percentuale, cioè sempre 0.4 da sinistra
-- dPercentDoorLength = EgtIf( DISPMODE > 0, EgtIf( dNumHingesPivots == 3 ,0.4, 0.6), EgtIf( dNumHingesPivots == 3, 0.6,0.4))
-------------------------------------------------------------------------------------------
end
-- Se uso shuttle forzato su uno dei due shuttle cambio la percentuale
if nForceUseShuttle then
if nForceUseShuttle == 1 then
dPercentDoorLength = 0
elseif nForceUseShuttle == 2 then
dPercentDoorLength = 1
else
nForceUseShuttle = 0
end
else
nForceUseShuttle = 0
end
-- scrivo la nota
EgtSetInfo( Pz, 'ForceShuttle', nForceUseShuttle)
-- quanto segue nella sottostante spiegazione è stato cambiato
---- determino la posizione del cambio shuttle utilizzando un coefficiente di 0.4 verso destra se il posizionamento è a destra
---- e un coefficiente di 0.6 verso destra se il posizionamento è a sinistra, in modo
---- da favorire lo shuttle che è dalla parte del riferimento ( a destra con assegnazione nMach a 2 e a sinistra con assegnazione nMach a 3)
dPosShuttleChange = EgtIf( DISPMODE > 0, Ori1:getX(), Ori2:getX()) + ( dLengthDoor * dPercentDoorLength * nDirReorderGroups) + ( OffsXSovr * nDirReorderGroups) + tabOri:getX()
-- ricavo minimo e massimo del solido del pezzo
b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
pMin = b3SolidOnTab:getMin()
pMax = b3SolidOnTab:getMax()
local tOrderGrp = {}
-- print Machining table
-- solo il primo giro: aggiusto i profili bevel per essere coerente con la sequenza di tabella
-- riordino i gruppi geometrici che hanno l'operazione AdjustHead o AdjustHeadOnASplint in ordine di X decrescente
for i = 1, #tLocMach do
-- print Machining table
DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') ..
' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1)
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- Applico le lavorazioni
for j = 1, #EntList do
-- OPERAZIONI
if tLocMach[i].Oper then
if tLocMach[i].Oper == 'AdjustBevel' then
local sNewName
_, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf)
elseif tLocMach[i].Oper == 'AdjustHead' or tLocMach[i].Oper == 'AdjustHeadOnASplint' then
-- nDirReorderGroups = -1 = ordine decrescente ( da dx a sx <--); nDirReorderGroups = 1 ordine crescente ( da sx a dx -->)
MB.ReorderGroup( EntList[j], tOrderGrp, nDirReorderGroups)
end
end
end
end
end
end
-- conteggio lavorazioni saltate
nNumMachSkipResult = 0
-- variabile per conteggio lavorazioni
nNumMach = 0
nNumSkip = 0
-- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sotto
if bFlip then
local nValAppo = nNumGeomBottom
nNumGeomBottom = nNumGeomTop
nNumGeomTop = nValAppo
nValAppo = nNumGeomBottomHole
nNumGeomBottomHole = nNumGeomTopHole
nNumGeomTopHole = nValAppo
end
-- Machining adding, only for selected machine
-- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni
for i = 1, #tLocMach do
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- Applico le lavorazioni
for j = 1, #EntList do
local bAdjustHead = false
local nNewIdEnt
-- OPERAZIONI
if tLocMach[i].Oper then
if tLocMach[i].Oper == 'AdjustBevel' then
local sNewName
bLocMach, sNewName, nNewIdEnt = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, bNoVertProf, bMakeGhost)
if bLocMach then
local bInsLav = false
-- faccio il test per vedere se la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
if nMach == 1 then
bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
-- se la lavorazione è applicabile
if bInsLav then
-- ottengo il nome del lato lavorato
local sEdge = EgtGetName( EgtGetParent( EntList[j]))
if sEdge then
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
-- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura
if string.lower( sEdge) == 'left' then
local dOffsLoc = 0
if bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'right' then
local dOffsLoc = 0
if bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'top' then
local dOffsLoc = 0
if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sTopTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[3]
local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[3] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'bottom' then
local dOffsLoc = 0
if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
end
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
end
end
end
else
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustVertCurve' then
bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost)
elseif tLocMach[i].Oper == 'AdjustRoughCurve' then
bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true)
elseif tLocMach[i].Oper == 'AdjustThrouCurve' then
bLocMach, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost)
if bLocMach then
local bInsLav = false
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
if nMach == 1 then
bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
if bInsLav then
-- ottengo il nome del lato lavorato
local sEdge = EgtGetName( EgtGetParent( EntList[j]))
if sEdge then
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
end
-- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura
if string.lower( sEdge) == 'left' then
local dOffsLoc = 0
if bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'right' then
local dOffsLoc = 0
if bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' or sLockTrim == 'CV_LK' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'top' then
local dOffsLoc = 0
if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sTopTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[3]
local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[3] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'bottom' then
local dOffsLoc = 0
if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
end
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
end
end
else
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustThrouIsle' then
bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth)
if not bLocMach then -- se operazione fallita
bOk = false
end
if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
nNumMachSkip = nNumMachSkipResult
else -- se non skippata provo a verificare se la lavorazione è applicabile
local bInsLav = true
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
local sResMach
if nMach == 1 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
if not bInsLav then
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
-- se nome lavorazione non nullo, incremento i contatori
if sResMach and #sResMach > 0 then
-- aumento di 1 il numero di lavorazioni skippate
nNumMachSkip = nNumMachSkip + 1
-- ricambio la nota come non lavorabile in questa fase
EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10)
-- incremento il numero di lavorazioni da sotto
nNumGeomBottom = nNumGeomBottom + 1
end
else -- se è andata a buon punto vedo di sottrarle ai contatori degli skip
if nMach == 1 then
if nNumGeomTop > 0 then
nNumGeomTop = nNumGeomTop - 1
end
elseif nMach == 2 then
if nNumGeomBottom > 0 then
nNumGeomBottom = nNumGeomBottom - 1
end
end
end
end
elseif tLocMach[i].Oper == 'AdjustHorizAS' then
bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then
bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustMortise' then
bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], nNumMachSkip, NO_WORK_UNDERSQUARE, bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustHeadChisel' then
bLocMach, nNewIdEnt, nNumMachSkipResult = MB.AdjustHeadChisel( EntList[j], bMakeGhost, CHISEL_ONLY_HORIZONTAL, nNumMachSkip, NO_WORK_UPSQUARE, NO_WORK_UNDERSQUARE)
if not bLocMach then
bOk = false
end
if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
nNumMachSkip = nNumMachSkipResult
end
elseif tLocMach[i].Oper == 'AdjustVertHole' then
bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth)
if not bLocMach then
bOk = false
end
if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
nNumMachSkip = nNumMachSkipResult
else -- se non skippata provo a verificare se la lavorazione è applicabile
local bInsLav = true
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
local sResMach
if nMach == 1 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
if not bInsLav then
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
-- se nome lavorazione non nullo, incremento i contatori
if sResMach and #sResMach > 0 then
-- aumento di 1 il numero di lavorazioni skippate
nNumMachSkip = nNumMachSkip + 1
-- ricambio la nota come non lavorabile in questa fase
EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10)
-- incremento il numero di lavorazioni da sotto
nNumGeomBottom = nNumGeomBottom + 1
end
else -- se è andato a buon fine, verifico di sottrarlo alle variabili skip
if nMach == 1 then
if nNumGeomTopHole > 0 then
nNumGeomTopHole = nNumGeomTopHole - 1
nNumGeomTop = nNumGeomTop - 1
end
elseif nMach == 2 then
if nNumGeomBottomHole > 0 then
nNumGeomBottomHole = nNumGeomBottomHole - 1
nNumGeomBottom = nNumGeomBottom - 1
end
end
end
end
elseif tLocMach[i].Oper == 'AdjustHole' then
bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustHead' then
bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHead( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nForceUseShuttle)
bAdjustHead = true
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustHeadOnASplint' then
bLocMach, nNumTopGeom, nNumBottomGeom, nNewIdEnt = MB.AdjustHeadOnASplint( EntList[j], nNumTopGeom, nNumBottomGeom, dPosShuttleChange, nil,
DISPMODE, bFlip, MAXMACH)
bAdjustHead = true
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then
bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost)
elseif tLocMach[i].Oper == 'AdjustASplintWithBlade' then
bOk, nNewIdEnt = MB.AdjustASplintWithBlade( EntList[j], bMakeGhost, DISPMODE, bFlip)
end
else -- se nessuna operazione
nNewIdEnt = MB.MakeGhostCopy( EntList[j])
end
-- LAVORAZIONI
local nMach
if nNewIdEnt then
nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
else
nMach = 0
end
if nMach > 30 and nMach < 40 then nMach = nMach - 30 end
if bAdjustHead and nMach > 0 and nMach < 4 then -- se navette
-- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme
bOk, nNumMach = FindAndCalcGroupMachining( EntList[j], nNewIdEnt, tLocMach, nNumMachFromTable, nMach,
nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed)
elseif nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno
-- carico id entità in una tabella
local tListSameMach = {}
table.insert( tListSameMach, nNewIdEnt)
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach,
tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false,
NOT_GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed)
else
if not bAdjustHead then
DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( tLocMach[i].Mach, tLocMach[i].Mach, '') ..
EgtDoorsMsg[596]..tostring( nNumPhase), 0)
nNumSkip = nNumSkip + 1
end
end
end
end
end
end
local i = 1
while i <= #tLocMachOrd do
-- carico tutto il gruppo in una tabella
local tGroup = {}
local nNumGrp = tLocMachOrd[i].Group
local sProperty = tLocMachOrd[i].Property
tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty)
if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0
if sProperty == 'MinDist' then -- ottimizzare alla minima distanza
-- prendo l'ultima lavorazione inserita ( lavorazione o disposizione)
local LastMch = EgtGetLastOperation()
local EndLastMach
-- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale
if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then
EgtSetCurrMachining( LastMch)
EndLastMach = EgtGetMachiningEndPoint()
end
local tMachining = {}
-- creo lavorazioni del gruppo
for k = 1, #tGroup do
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE')
local bAdjustHead = false
-- Applico le lavorazioni
for j = 1, #EntList do
-- LAVORAZIONI
local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMach = nMach - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
local sMachining = EgtGetInfo( EntList[j], 'Machining')
-- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima
if nMach > 0 and nMach < 4 then nMach = 1 end
-- se lavorazione esiste e corrisponde e numero lavorazione è = 1
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach,
tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead,
GEN_MACH, tMachining, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
-- tolgo di mezzo le note secondarie
for j = 1, #EntList do
EgtRemoveInfo( EntList[j], 'Mach2nd')
end
end
-- ordino le lavorazioni
if #tMachining > 1 then
-- Tavole per fresature da ordinare
local TabMill = {}
local TabMStEnP = {}
local TabZMach = {}
for k = 1, #tMachining do
-- Se appartiene alla fase corrente e fresatura non vuota
if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then
EgtSetCurrMachining( tMachining[k][1])
local ptStart = EgtGetMachiningStartPoint()
local ptEnd = EgtGetMachiningEndPoint()
if ptStart and ptEnd then
table.insert( TabMill, tMachining[k][1])
table.insert( TabMStEnP, { ptStart, ptEnd})
MB.InsZedByTool( TabZMach, tMachining, k)
end
end
end
-- calcolo ordinamento
EgtSpInit()
for k = 1, #TabMill do
EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0,
TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0)
end
if EndLastMach then
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90)
else
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90)
end
local vMillOrd = EgtSpCalculate(SHP_TY.OPEN)
EgtSpTerminate()
-- applico ordinamento calcolato
-- parto da LastMch precedente
if vMillOrd then
for k = 1, #vMillOrd do
EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER)
LastMch = TabMill[vMillOrd[k]]
end
end
end
elseif sProperty == 'Shuttle' then -- lavorazione con shuttle
-- per ogni layer padre nella lista fatta con il reordergroup
for k = 1, #tOrderGrp do
-- Recupero la prima entità del layer padre
local EntList = MB.FindEntities( tOrderGrp[k][1], true)
-- LAVORAZIONI
local nMach = 1
-- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme
bOk, nNumMach = MakeGroupMachining( EntList, tOrderGrp[k][1], tGroup, nMach, nNumGrp,
nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach,
dBladePerpLeadIn, dPercRedFeed)
end
elseif sProperty == 'Layer' then -- lavorazione layer
-- ottengo tutte le entità del gruppo
local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE')
-- Applico le lavorazioni
for j = 1, #EntListGrp do
local nParendId = EgtGetParent(EntListGrp[j])
-- Recupero la prima entità del layer padre
local EntList = MB.FindEntities( nParendId, true)
-- LAVORAZIONI
local nMach = 1
-- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme
bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp,
nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach,
dBladePerpLeadIn, dPercRedFeed)
end
elseif sProperty == '' then -- proprietà nulla
-- creo lavorazioni del gruppo
for k = 1, #tGroup do
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE')
local bAdjustHead = false
-- Applico le lavorazioni
for j = 1, #EntList do
-- LAVORAZIONI
local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMach = nMach - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
local sMachining = EgtGetInfo( EntList[j], 'Machining')
-- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima
if nMach > 0 and nMach < 4 then nMach = 1 end
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach,
tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead,
GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
-- tolgo di mezzo le note secondarie
for j = 1, #EntList do
EgtRemoveInfo( EntList[j], 'Mach2nd')
end
end
end
elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore
DGD.ERR = -15
if DGD.EMC and #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
else
DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
end
if DGD.ERM and #DGD.ERM > 0 then
DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
else
DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
end
end
i = i + 1
end
----------------------------------------
-- Inserimento riferimenti e ventose
----------------------------------------
-- Offset ventose da bordo pezzo in Y
dVacOffs = 52
-- Offset barra riferimenti mobile da riferimenti quando posizione 0
dMobOffs = 160 + 65
-- Lunghezza minima per alzare prima ventosa da bordo sinistro
dDistMinX = 120.61 + 40 + DIST_MIN_VAC_L -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza)
-- Lunghezza minima per alzare prima ventosa da bordo destro
dDistMaxX = 168.2 + 40 + DIST_MIN_VAC_R -- distanza misurata tra appoggio riferimento e centro ventose + quota sicurezza ( R ventosa + sicurezza)
-- Posizione ventose in alto
dVacOn = 110
-- Interasse ventose
dInterAx = 232
-- distanza interferenza con cave passanti
dDistInterferThru = 42 + 8 -- modificato da 8 a 12 il 21/12/2017 su richiesta di Mark
dDistInterferBlind = 42 + 45
dDistInterferUnder = 42 + 55
-- Ventose
local nTabId = EgtGetTableId( 'Tab')
local nMobId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'MOBILE')
local nFixId = EgtGetFirstNameInGroup( nTabId or GDB_ID.NULL, 'FIXED')
local nDispId = EgtGetPhaseDisposition( nNumPhase)
-- se gruppi richiesti non trovati
if not nMobId or not nFixId then
bOk = false
DGD.EMC = ' ' .. EgtDoorsMsg[529]..EgtDoorsMsg[530] -- Error on MOBILE or FIXED table bar'
break
end
-- Posizionamento barra mobile
local dOldVal = EgtGetInfo( nMobId, 'Val', 'd')
-- calcolo nuova posizione con: larghezza finita porta ( uso getDimX perché presa prima della disposizione porta) +
-- sovramateriale a contatto con il riferimento in basso - distanza ventose - offset barra
local dNewVal = b3Solid:getDimX() + OffsYSovr + vShift:getY() + vShiftVac:getY() - dVacOffs - dMobOffs
EgtMove( nMobId, Vector3d( 0, dNewVal - dOldVal, 0), GDB_RT.GLOB)
EgtSetInfo( nMobId, 'Val', dNewVal)
EgtSetInfo( nDispId, 'MOB', dNewVal)
-- Elevazione ventose con: altezza porta ( uso getDimY perché presa prima della disposizione porta) +
-- sovramateriale a contatto con il riferimento a sx - distanza ventosa
local dCalcLen = b3Solid:getDimY() + OffsXSovr - EgtIf( DISPMODE > 0, dDistMinX, dDistMaxX)
-- predispongo regioni per verifica interferenza con lavorazioni passanti o da sotto
StartVacVerify( Ls, bFlip)
-- ciclo sulle ventose
local nInd = 1
local nIndVac
local nNumTotVacRow = 13
local nCountFailed = 0
local nIniFailed = 0
local nMiddleFailed = 0
local nEndFailed = 0
local nMaxIniFailed = 0
local nMaxMiddleFailed = 0
local nMaxEndFailed = 0
while dCalcLen > 0 and nInd <= nNumTotVacRow do
nIndVac = EgtIf( DISPMODE > 0, nInd, ( nNumTotVacRow - nInd + 1))
local sInd = tostring( nIndVac)
-- eseguo verifica
local nCenFixId = EgtGetFirstNameInGroup( nFixId, 'CEN'..sInd)
local bCanUpFix = ExecVacVerify( EgtSP( nCenFixId, GDB_ID.ROOT), Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder)
local nCenMobId = EgtGetFirstNameInGroup( nMobId, 'CEN'..sInd)
local bCanUpMob = ExecVacVerify( EgtSP( nCenMobId, GDB_ID.ROOT), Pz, dDistInterferThru, dDistInterferBlind, dDistInterferUnder)
-- eventuale movimento
if bCanUpFix and bCanUpMob then
-- alzo le due ventose
MoveVac( nFixId, 'VAC'..sInd, dVacOn)
MoveVac( nFixId, 'ROD'..sInd, dVacOn)
MoveVac( nMobId, 'VAC'..sInd, dVacOn)
MoveVac( nMobId, 'ROD'..sInd, dVacOn)
-- salvo lo stato
EgtSetInfo( nDispId, 'VAC'..sInd, dVacOn)
-- interrompo le serie negative
if nInd > 1 then
nCountFailed = 0
if nMaxIniFailed < nIniFailed then
nMaxIniFailed = nIniFailed
end
if nMaxMiddleFailed < nMiddleFailed then
nMaxMiddleFailed = nMiddleFailed
end
if nMaxEndFailed < nEndFailed then
nMaxEndFailed = nEndFailed
end
nIniFailed = 0
nMiddleFailed = 0
nEndFailed = 0
end
else
EgtRemoveInfo( nDispId, 'VAC'..sInd)
nCountFailed = nCountFailed + 1
if nInd == 1 then -- setto solo il fallimento iniziale
nIniFailed = nCountFailed
elseif nInd == nNumTotVacRow or ( dCalcLen - dInterAx) <= 0 then -- setto solo quello finale e annullo il medio
nEndFailed = nCountFailed
if nMaxEndFailed < nEndFailed then
nMaxEndFailed = nEndFailed
end
nMiddleFailed = 0
else -- se fallisce riga intermedia aggiorno solo i contatori già iniziati
if nIniFailed > 0 then
nIniFailed = nCountFailed
elseif nEndFailed > 0 then
nEndFailed = nCountFailed - 1
else
nMiddleFailed = nCountFailed
end
end
end
-- aggiorno la lunghezza di calcolo e l'indice
dCalcLen = dCalcLen - dInterAx
nInd = nInd + 1
end
-- elimino geometrie per verifica
EndVacVerify()
-- riassegno la quantità di file che effettivamente potrebbero essere alzate
nInd = nInd - 1
-- casi di scarse ventose
if nInd > 0 and ( nMaxIniFailed == nInd or nMaxMiddleFailed == nInd or nMaxEndFailed == nInd) then -- tutte le ventose basse
DGD.EMC = ' ' .. EgtDoorsMsg[531]
bOk = false
break
elseif nInd > 0 and nMaxIniFailed / nInd > 0.25 then -- ventose iniziali ( parte destra)
local nNumMsg = EgtIf( DISPMODE > 0, 532, 534)
DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg]
bOk = false
break
elseif nInd > 0 and nMaxMiddleFailed / nInd > 0.45 then -- ventose intermedie
DGD.EMC = ' ' .. EgtDoorsMsg[533]
bOk = false
break
elseif nInd > 0 and nMaxEndFailed / nInd > 0.25 then -- ventose finale ( parte sinistra)
local nNumMsg = EgtIf( DISPMODE > 0, 534, 532)
DGD.EMC = ' ' .. EgtDoorsMsg[nNumMsg]
bOk = false
break
elseif ( nMaxIniFailed + nMaxMiddleFailed + nMaxEndFailed) >= nInd/2 then -- somma di vari intervalli
DGD.EMC = ' ' .. EgtDoorsMsg[531]
bOk = false
break
end
-------------------------------------------------
-- gestione messaggi LIGHT: red, yellow, green
-------------------------------------------------
-- se ho geometrie da entrambe le parti la luce è red
if nNumGeomBottom > 0 and nNumGeomTop > 0 then
sLight = 'RED'
-- se non ho geometrie la luce è green
elseif nNumGeomBottom == 0 and nNumGeomTop == 0 then
sLight = 'GREEN'
-- se una delle due ha delle geometrie
else
-- in caso di geometrie tutte sotto luce yellow
if nNumGeomBottom > 0 then
sLight = 'YELLOW'
-- in caso di geometrie tutte sopra luce green
elseif nNumGeomTop > 0 then
sLight = 'GREEN'
end
end
-- *** Tools Setup ***
-- provo a importare l'attrezzaggio di default, se fallisce passo gli altri
local bSetUp = EgtImportSetup()
local tListError
local sListTool = ''
if bSetUp then -- se importato quello di default
sSetup = EgtGetDefaultSetupName()
-- verifico se l'attrezzaggio è idoneo
bSetUp, tListError = EgtVerifyCurrSetup()
-- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default
if bSetUp then
-- assegno nota con il nome del file setup assegnato
EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup)
else -- preparo la lista degli utensili mancanti
sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)'
sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553]
for k = 1, #tListError do
sListTool = sListTool .. '\n ' .. tListError[k]
end
end
end
-- se fallito quello di default o utensili mancanti provo quello indicato nel CurrCamInfo
if not bSetUp then
local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default
sSetup = mCamData[nNumMachFromCam].Setup1
-- se nome attrezzaggio non è vuoto
if sSetup and #sSetup > 0 then
bSetUp = EgtImportSetup(sSetup)
end
-- se nessuno è andato bene verifico se il primo era stato importato
if not bSetUp then
if sDefSetUp and #sDefSetUp > 0 then
if DGD.EMC and #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551]
else
DGD.EMC = ' ' .. EgtDoorsMsg[551]
end
bOk = false
if #sListTool > 0 then
DGD.EMC = DGD.EMC .. sListTool
end
break
else
-- assegno ugualmente un attrezzaggio vuoto
EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555])
end
else -- ha importato il fle da CurrCamInfo
-- verifico se l'attrezzaggio è idoneo
bSetUp, tListError = EgtVerifyCurrSetup()
if bSetUp then -- se è andato bene
-- assegno nota con il nome del file setup assegnato
EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup)
else -- se utensili mancanti
sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', 1)
sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553]
for k = 1, #tListError do
sListTool = sListTool .. '\n ' .. tListError[k]
end
DGD.EMC = DGD.EMC .. sListTool
bOk = false
break
end
end
end
-- se nessuna geometria skippata esco
if nNumMachSkip and nNumMachSkip == 0 then bWork = false end
-- se lavorazioni skippate abilito il ribaltamento porta in altra fase
if nNumMachSkip and nNumMachSkip > 0 then
nNumMachSkip = 0 -- resetto per il prossimo giro
-- per interrompere il giro forzatamente ( perché nessun ribaltamento) setto bWork
bWork = false
end
nNumCycle = nNumCycle + 1
end -- end while
--bOk = false -- per forzare l'errore
if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end
-- Eventuale messaggio di errore
if not bOk then
DoorOutLog( string.format(EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina
DGD.ERR = 20
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1)
-- stampo gli errori del machiningBase
if DGD.EMC and #DGD.EMC > 0 then
DoorOutLog( DGD.EMC, 0)
end
DoorOutLog( string.format( EgtDoorsMsg[475], MachName), 0) -- Error on machining calculation
-- cancello il file cn e il txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc')
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con l'errore
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], MachName))
if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD
if DGD.EMC and #DGD.EMC > 0 then
EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation
else
EgtOutBox( string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation
end
end
-- Salvo progetto
EgtSaveFile()
return false, nNumGroup
end
-- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale)
EgtApplyAllMachinings( false, false)
-- Salvo progetto
EgtSaveFile()
-- Estimation
bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath)
-- NC code generation
bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath)
if bOk then
if not DGD.ERR then DGD.ERR = 0 end
-- luce di caricamento porta
if sLight then
DGD.ERM = ' LIGHT='..sLight..'\n'..DGD.ERM
end
DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1)
if not DGD.NCGEN then
if DGD.ERM and #DGD.ERM > 0 then
DoorOutLog( DGD.ERM, 0) -- stampo eventuali errori
end
end
DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode)
else
DGD.ERR = 20
DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], MachName, sSetup)
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt')
-- scrivo messaggio nei file log
DoorOutLog( string.format(EgtDoorsMsg[478], MachName, sSetup), 0) -- Error on Nc part program generation
-- se lanciato da DMach stampo anche un messaggio a video
if not DGD or not DGD.NCGEN then
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0)
EgtOutBox( string.format(EgtDoorsMsg[478], MachName, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation
end
return false, nNumGroup
end
-- reset librerie locali
package.loaded[MachiningsTable] = nil
package.loaded[MachiningsTableOrd] = nil
return true, nNumGroup
end
return MachiningLoc