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

2902 lines
135 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_1.lua by EgalWare s.r.l. 2016/23/05 20:00:00
-- Autore: Dario Sassi
-- Machining generation for Doors program machine CMS
-- 2016.11.16 V1.011 FM Manage door limit for shifted disposition
-- 2017.05 V1.012 FM Mmanage machining optimization
-- 2017.06.13 V1.013 FM Manage top door disposition by Currcaminfo
-- 2017.06.13 V1.012 FM Fix bug on calculate box and row piece
-- 2017.06.30 V1.013 FM Manage optimization and assignement of more paths to one machining
-- 2017.11.17 V1.014 FM Add manage parameter dExtraThruDepth from CurrCamInfo for functions AdjustThrouIsle and AdjustVertHole
-- 2018.02.26 V1.0b1 FM Manage door dimension checking
-- 2018.05.17 V1.0b2 FM Calculate the solid box without extra surfaces
-- 2018.10.16 V1.0b3 FM Extend setup to 50 items
-- 2018.10.18 V1.0b4 FM Manage better setting the disposition parameter on Inactive door with opposite bevel profiles
-- 2018.10.23 V1.0b5 FM Manage rough machining
-- 2018.10.25 V1.0b6 FM Fix problem on AdjustBevel: missing parameter into call function
-- 2019.01.14 V1.0b7 FM Manage new CurrCamInfo parameter (nGenCncAsDdfName) to set
-- which name generate the cnc file (by default as parameter sDoorCode or as ddf file name)
-- 2019.01.23 V1.0b8 FM Not generate machining on Group 0 (of MTable ordered table) and print warning message into repot files.
-- 2019.02.12 V1.0b9 FM Remove empty phase (after the first one)
-- 2019.03.11 V1.0c1 FM Fix error on delete paths with HIDE and ROUGH suffix
-- 2019.03.27 V1.0c2 FM Manage check door/jamb dimension by function CheckPieceDimension
-- 2019.03.27 V1.0c3 FM Fix error on calculation bar disposition and menage better into CheckPieceDimension by shift door values
-- 2019.03.27 V1.0c3 FM Modify error messages format into CheckPieceDimension
-- 2019.03.27 V1.0c3 FM Manage estimate time
-- 2019.03.29 V1.0c4 FM Manage Edge break (EB) and Bevel Edge break (BVEB) profiles
-- 2019.04.08 V1.0c5 FM Manage Blade groove machinings with lead-in lead-out to reduce MTABLE lines
-- Now it uses 1 line for antisplint blade and 1 line for normal blade
-- 2019.04.08 V1.0c5 FM Manage Blade groove function AdjustBladeVertCurve
-- 2019.05.28 v1.0c6 FM Fix problem on update all machining after reorder, now use EgtApplyAllMachinings instead of EgtUpdateAllMachinings
-- 2021.06.01 v1.0c7 FM Fix error on calculate piece box
-- 2021.10.28 V1.0c8 FM Fix internal error when calculate Box with STANDARD parameter, now it uses EXACT parameter
-- 2022.06.10 V1.0c9 FM Manage large width door disposition
-- 2022.06.20 V1.0d1 FM Manage Part parameter from ddf
-- 2022.07.27 V1.0d2 FM Modification to use compiled code
-- 2023.03.29 V1.0d3 FM Fix error on calculate rough paths on Convex profile
-- 2023.07.06 V1.0d4 FM Fix error on not check new variables dDimPendularDoor and AskCustomTable
-- 2023.12.01 V1.0d5 FM Manage small planes on Convex profile
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
local MachiningLoc = {}
-- Librerie particolari
local sBaseDir = DGD.BASEDIR -- EgtGetSourceDir()
EgtAddToPackagePath( sBaseDir .. 'LuaLibs\\?.lua')
require( 'EgtDoorsBase')
require( 'EgtDoorsData')
local EgtDoorsMsg = require( 'EgtDoorsMsg')
local MB = require( 'MachiningBase')
-- Impostazioni Cam per consentire forature con utensile più piccolo
EgtMdbSetGeneralParam( MCH_GP.HOLEDIAMTOLER, -50)
EgtMdbSave()
-- Definizione possibilità di lavorare sottosquadra nei profili bevel ( true: non lavora sottosquadra, false: possibile lavorare sottosquadra)
local NO_WORK_UNDERSQUARE = false
-- variabili genarazione lavorazioni
local GEN_MACH = false
local NOT_GEN_MACH = true
-----------------------------------------------------------------
-- *** Error write file ***
-----------------------------------------------------------------
local function WriteErrFile( sFileErr, sDispMsg)
local nIdFile = io.open( sFileErr, 'w')
if nIdFile then
if DGD.ERR == 0 then
if DGD.ERM and #DGD.ERM > 0 then
nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. '\n' .. DGD.ERM)
else
nIdFile:write( 'Err=' .. tostring( DGD.ERR))
end
else
if DGD.EMC and #DGD.EMC > 0 then
nIdFile:write( 'Err=' .. tostring( DGD.ERR) .. DGD.EMC)
else
nIdFile:write( 'Err=' .. tostring( DGD.ERR))
end
end
if sDispMsg and #sDispMsg > 0 then
nIdFile:write('\n' .. sDispMsg)
end
nIdFile:close()
end
end
-----------------------------------------------------------------
-- *** calculate door disposition by parameters ***
-----------------------------------------------------------------
local function CalcTopPosition( nTopSideDriveDisp, bAtRight)
local bTopOnRight
if nTopSideDriveDisp and nTopSideDriveDisp == 1 then
bTopOnRight = true
elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then
bTopOnRight = false
else
if bAtRight then -- se serratura a destra
bTopOnRight = true
else
bTopOnRight = false
end
end
return bTopOnRight
end
-----------------------------------------------------------------
-- *** Add Machining in table for second part ***
-----------------------------------------------------------------
local function AddMachIntable( MTMachLine, tSecMcng, nIndexTab)
if tSecMcng then
if #tSecMcng > 0 then
local bFound = false
MTMachLine.Row = nIndexTab
for k = 1, #tSecMcng do
if MTMachLine == tSecMcng[k] then
bFound = true
end
end
-- se non trovato lo inserisco
if not bFound then
table.insert( tSecMcng,MTMachLine)
end
else
MTMachLine.Row = nIndexTab
table.insert( tSecMcng,MTMachLine)
end
end
return tSecMcng
end
local function SetInfoTable( tListEnt, sNameInfo, nValInfo)
for j = 1, #tListEnt do
if tListEnt[j] then
EgtSetInfo( tListEnt[j], sNameInfo, nValInfo)
end
end
end
-----------------------------------------------------------------
-- *** Apply Machining by Mach number ***
-----------------------------------------------------------------
local function InsertMachiningByMachNum ( tEndId, nMach, sLocName, nNumGroup, sMach,
sMachUp, sMachDw, bOk, nNumMach, bModifyMacNote,
bNotGenMachining, tMachining, dBladePerpLeadIn, dPercRedFeed, bCalMach)
local dOverL = EgtGetInfo( tEndId[1], 'OL')
local dOverR = EgtGetInfo( tEndId[1], 'OFFSTOPATH', 'd')
local nOffsetDel = EgtIf( bNotGenMachining, 20, 0)
local nOffsetDelFail = EgtIf( bNotGenMachining, 30, 0)
if nMach == 1 then
local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMach, tEndId, dOverL, sLocName,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 11+ nOffsetDel)
if bCalMach then
SetInfoTable( tEndId, 'Machining', sMach)
nNumMach = nNumMach + 1
end
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
end
end
elseif nMach == 2 then
local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachUp, tEndId, dOverL, sLocName,
bNotGenMachining, nil, nil, nil, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 12+ nOffsetDel)
if bCalMach then
SetInfoTable( tEndId, 'Machining', sMachUp)
nNumMach = nNumMach + 1
end
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
end
end
elseif nMach == 3 then
local nRes, nMachId, sToolName = MB.AddAndDelMachining( sLocName .. '_G' .. EgtNumToString(nNumGroup,0), sMachDw, tEndId, dOverL, sLocName,
bNotGenMachining, nil, nil, nil, nil,
nil, nil, dOverR)
if nRes < 0 then -- se la lavorazione ha fallito
bOk = false
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
elseif nRes == 0 then -- se lavorazione mancante
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo nemmeno nella generazione reale
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDelFail)
end
else -- lavorazione ok
if bModifyMacNote then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel)
end
if bNotGenMachining then
-- setto nota per non lavorarla di nuovo
SetInfoTable( tEndId, 'Mach', 13+ nOffsetDel)
if bCalMach then
SetInfoTable( tEndId, 'Machining', sMachDw)
nNumMach = nNumMach + 1
end
else
if tMachining then
table.insert( tMachining,{nMachId,sToolName})
end
end
end
end
return bOk, nNumMach, tMachining
end
-----------------------------------------------------------------
-- *** Calc Machining for same group ***
-----------------------------------------------------------------
local function FindAndCalcGroupMachining( nEndId, nEndIdGhost, tLocTable, nNumMachFromTable, nMach,
nNumGroup, nNumMach, bOk, dBladePerpLeadIn, dPercRedFeed)
local nParendId = EgtGetParent(nEndId)
local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo
local sLocMachId
local bNotGenMachining = true
-- ordinare lavorazioni navette come scritto su foglio nella documentazione
for i = 1, #tLocTable do
if tLocTable[i].On ~= 0 then
sLocMachId = tLocTable[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name)
-- Applico le lavorazioni
for j = 1, #EntList do
local nMachCk = EgtGetInfo( EntList[j], 'MachCk', 'i') or 1
if tLocTable[i].Oper == 'AdjustHead' and nMachCk > 0 and nMachCk < 10 then
-- assegno la stessa nota nMach dell'entità del gruppo
EgtSetInfo( EntList[j], 'Mach', nMach)
-- duplico entià
local nNewEntId = MB.MakeGhostCopy( EntList[j])
-- carico id entità in una tabella
local tListSameMach = {}
table.insert( tListSameMach, nNewEntId)
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach,
tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true,
bNotGenMachining, nil, dBladePerpLeadIn, dPercRedFeed)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
EgtSetInfo( EntList[j], 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
EgtSetInfo( EntList[j], 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
end
end
end
return bOk, nNumMach
end
-----------------------------------------------------------------
-- *** Add Machining for same group ***
-----------------------------------------------------------------
local function MakeGroupMachining( nEndId, nParendId, tLocTable, nMach, nNumGroup,
nNumMach, bOk, sGhostName, dMaxDistToChain, EndLastMach,
dBladePerpLeadIn, dPercRedFeed)
local EntListMain = MB.FindEntities( nParendId) -- ricavo tutte le entità che sono nello stesso gruppo
-- ordinare lavorazioni navette come scritto su foglio nella documentazione
for i = 1, #tLocTable do
-- Recupero le entità
local EntList = MB.FindEntitiesWithNameFromTab( EntListMain, tLocTable[i].Name..sGhostName)
-- Applico le lavorazioni
for j = 1, #EntList do
local nMachCk = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMachCk = nMachCk - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
if nMachCk > 0 and nMachCk < 10 then nMachCk = 1 end
if nMachCk > 0 and nMachCk < 10 then
local nNewEntId = EntList[j]
local sMachining = EgtGetInfo( nNewEntId, 'Machining')
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tLocTable[i].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( nNewEntId, EntList, sMachining, tLocTable[i].Join, dMaxDistToChain, true)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocTable[i].Name, nNumGroup, tLocTable[i].Mach,
tLocTable[i].MachUp, tLocTable[i].MachDw, bOk, nNumMach, true,
GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
end
-- tolgo di mezzo le note secondarie
for j = 1, #EntList do
EgtRemoveInfo( EntList[j], 'Mach2nd')
end
end
return bOk, nNumMach
end
-----------------------------------------------------------------
local function MakeBoxFromSolidLayer( nSolidLayer, nProbeMode, nAuxLayer)
-- Box solido: lo ottengo dalla somma delle varie superfici della porta
local tListFaces = {}
if nProbeMode == 2 then
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP_2'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW_2'))
else
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_UP'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'FLAT_DW'))
end
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_LF'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_RH'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_BT'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE_TP'))
table.insert( tListFaces, EgtGetFirstNameInGroup( nSolidLayer, 'SIDE'))
-- aggiungo anche il layer AUX escludendo il testo
if nAuxLayer then
local nIdGeom = EgtGetFirstInGroup(nAuxLayer)
local nTypeEnt
while nIdGeom do
-- se elemento passato è un testo lo escludo
nTypeEnt = EgtGetType( nIdGeom)
if nTypeEnt ~= GDB_TY.EXT_TEXT then
table.insert( tListFaces, nIdGeom)
end
nIdGeom = EgtGetNext(nIdGeom)
end
end
local b3fx = BBox3d() -- inizializzo il box nullo
for i = 1, #tListFaces do
if tListFaces[i] then
local b3f1 = EgtGetBBoxGlob( tListFaces[i], GDB_BB.EXACT)
b3fx:Add(b3f1)
end
end
return b3fx
end
-----------------------------------------------------------------
local function CheckPieceDimension ( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr,
ShiftXOri, ShiftYOri, dMinDoorLength, dMaxDoorLength, dMinDoorWidth,
dMaxDoorWidth, dMinDoorThick, dMaxDoorThick)
local bFailDim = false
local sErrMess = ''
local dLimitToCheck
dLimitToCheck = dMinDoorLength - abs(ShiftXOri)
if ( dLengthDoor + OffsXSovr) < dLimitToCheck then -- se lunghezza inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[617], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr),
EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMaxDoorLength - abs(ShiftXOri)
if ( dLengthDoor + OffsXSovr) > dLimitToCheck then -- se lunghezza superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[616], EgtDoorsMsg[622], EgtToUiUnits(dLengthDoor), EgtToUiUnits(OffsXSovr), EgtToUiUnits(dLengthDoor+OffsXSovr),
EgtToUiUnits(abs(ShiftXOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMinDoorWidth - abs(2*ShiftYOri)
if ( dWidthDoor + (2*OffsYSovr)) < dLimitToCheck then -- se larghezza inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[619], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)),
EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMaxDoorWidth - abs(2*ShiftYOri)
if ( dWidthDoor + (2*OffsYSovr)) > dLimitToCheck then -- se larghezza superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[618], EgtDoorsMsg[622], EgtToUiUnits(dWidthDoor), EgtToUiUnits(2*OffsYSovr), EgtToUiUnits(dWidthDoor+(2*OffsYSovr)),
EgtToUiUnits(abs(2*ShiftYOri)), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMinDoorThick
if dThickDoor < dLimitToCheck then -- se spessore inferiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[621], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
dLimitToCheck = dMaxDoorThick
if dThickDoor > dLimitToCheck then -- se spessore superiore
bFailDim = true
sErrMess = string.format(EgtDoorsMsg[620], EgtDoorsMsg[622], EgtToUiUnits(dThickDoor), EgtToUiUnits(dLimitToCheck))
if #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n'.. sErrMess
else
DGD.EMC = '\n'.. sErrMess
end
end
return bFailDim
end
-----------------------------------------------------------------
-- *** Funzione di generazione lavorazioni ***
-----------------------------------------------------------------
function MachiningLoc.Calc( tPz, tsAssemb, nNumMachFromTable, nNumMachFromCam, nNumGroup)
-- macchina e tabella di default
local MachName = 'Cms-PF122R8RR'
-- Machinings Table
local MachiningsTable = 'MachStdTable'
local MachiningsTableOrd = 'MachStdTable_Ord'
-- References on table (respect Zero machine)
-- Y Table
local Ori1 = Point3d( -21.991, -57.090, -11.511) * GEO.ONE_INCH
-- V Table
local Ori3 = Point3d( -120.420, -57.130, -11.511) * GEO.ONE_INCH
-- Y Table for wide door
local Ori9 = Point3d( -21.991, -11.1703, -11.511) * GEO.ONE_INCH
-- V Table for wide door
local Ori10 = Point3d( -120.420, -11.1703, -11.511) * GEO.ONE_INCH
-- shift value
local vShift = Vector3d(0,0,0)
local vShiftAct = Vector3d(0,0,0)
local vNullShift = Vector3d(0,0,0)
-- tabella raccordi
local tsRadiusProf = {}
local tsPlaneProf = {}
-- utilizzo la tabella dati cam
local sPathCurrMachtabOri = 'CurrCamInfo'
local mCamData = require( sPathCurrMachtabOri)
-- variabili pezzo singolo
local nPz
local sAssemb
-- variabile check dimensioni porta
local bFailDim = false
-- resetto la macchinata (riporto il pezzo in area disegno)
EgtResetCurrMachGroup()
-- elimino percorsi eventualmente creati dal Mach
-- cancello i percorsi ghost e tutti i percorsi di sgrossatura
local DelList = MB.FindEntitiesWithPartName( tPz, '_HIDE')
-- ciclo su tutte le entità trovate
for j = 1, #DelList do
EgtErase( DelList[j] )
end
DelList = MB.FindEntitiesWithPartName( tPz, 'ROUGH_')
-- ciclo su tutte le entità trovate
for j = 1, #DelList do
EgtErase( DelList[j] )
end
-- se la variabile è una tabella, estrapolo solo la porta
local PzIsTab = type(tPz) == 'table'
if PzIsTab then
for v = 1, #tPz do
Pz = tPz[v]
sAssemb = tsAssemb[v]
-- se non ha nota o nota della prima porta esco
if not sAssemb or ( sAssemb and sAssemb == 'first') then
break
end
end
else
Pz = tPz
sAssemb = tsAssemb
end
--------------------------------------------------------------------------------
-- Dati della porta
local sCode = EgtGetInfo( Pz, 'Code')
local dWidthDoor = EgtGetInfo( Pz, 'W', 'd')
local dLengthDoor = EgtGetInfo( Pz, 'H', 'd')
local dThickDoor = EgtGetInfo( Pz, 'T', 'd')
local sSwing = EgtGetInfo( Pz, 'Swing')
MachiningsTable = EgtGetInfo( Pz, 'MTable') -- ottengo la tabella corrente
local sSecure = EgtGetInfo( Pz, 'Secure')
-- local nPart = EgtGetInfo( Pz, 'Part', 'i')
local sHingeTrim = EgtGetInfo( Pz, 'hingeedge_trimming')
local sLockTrim = EgtGetInfo( Pz, 'lockedge_trimming')
local sTopTrim = EgtGetInfo( Pz, 'top_trimming')
local sBottomTrim = EgtGetInfo( Pz, 'bottom_trimming')
local bHingeMach = EgtGetInfo( Pz, 'hingeedge_machining', 'b')
local bLockMach = EgtGetInfo( Pz, 'lockedge_machining', 'b')
local bTopMach = EgtGetInfo( Pz, 'top_machining', 'b')
local bBottomMach = EgtGetInfo( Pz, 'bottom_machining', 'b')
local bAtRight = ( sSwing:sub(1,1) == 'L') -- flag che viene settato a vero se serratura a destra
local bSwingDriveDisp = EgtGetInfo( Pz, 'SwingDriveDisp', 'b' )
local bOppoBevelProf = EgtGetInfo( Pz, 'OppoBevelProf', 'b' )
tsRadiusProf[1] = EgtGetInfo( Pz, 'RadHingeProfile', 'd')
tsRadiusProf[2] = EgtGetInfo( Pz, 'RadLockProfile', 'd')
tsRadiusProf[3] = EgtGetInfo( Pz, 'RadTopProfile', 'd')
tsRadiusProf[4] = EgtGetInfo( Pz, 'RadBottomProfile', 'd')
tsPlaneProf[1] = EgtGetInfo( Pz, 'PlnHingeProfile', 'd')
tsPlaneProf[2] = EgtGetInfo( Pz, 'PlnLockProfile', 'd')
tsPlaneProf[3] = EgtGetInfo( Pz, 'PlnTopProfile', 'd')
tsPlaneProf[4] = EgtGetInfo( Pz, 'PlnBottomProfile', 'd')
local dRadiusPrf = tsRadiusProf[1]
local dPlanePrf = tsPlaneProf[1]
local dLeftOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Left') or GDB_ID.NULL, 'Offs', 'd') or 0
local dRightOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Right') or GDB_ID.NULL, 'Offs', 'd') or 0
local dTopOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Top') or GDB_ID.NULL, 'Offs', 'd') or 0
local dBottomOffs = EgtGetInfo( EgtGetFirstNameInGroup( Pz, 'Bottom') or GDB_ID.NULL, 'Offs', 'd') or 0
-- Box pezzo
local Ls = EgtGetFirstNameInGroup( Pz, 'SOLID')
local b3Part = EgtGetBBoxGlob( Pz, GDB_BB.EXACT)
-- Box solido: lo ottengo dalla somma delle varie superfici della porta
local b3fx = BBox3d() -- inizializzo il box nullo
b3fx = MakeBoxFromSolidLayer( Ls, 0, Aux)
local b3Solid = b3fx
-- local b3Solid = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
-- Project path, name, extension
local sFilePath = EgtGetCurrFilePath()
local sFileDir, sFileName, sFileExt = EgtSplitPath( sFilePath)
--------------------------------------------------------------------------------
-- *** settaggi CAM *** -- Mtable 1
if not MachiningsTable then -- se non c'è il nome della MTable esco
DoorOutLog( string.format(EgtDoorsMsg[597], MachiningsTable), 0) -- errore, file di tabella non trovato
return false
end
EgtAddToPackagePath( sBaseDir .. 'MTables\\?.mtl')
local TAB
if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl') then
TAB = require( MachiningsTable)
if not TAB then
DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore tabella non trovata nel file
return false
end
else
DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTable .. '.mtl'), 0) -- errore, file di tabella non trovato
return false
end
local MachinesName = TAB.MMachineData
if not MachinesName then
DoorOutLog( string.format(EgtDoorsMsg[491], ''), 0) -- Errore! Nome macchina: non presente in MTable
return false
end
-- *** settaggi CAM *** -- Mtable 2
MachiningsTableOrd = MachiningsTable..'_'..EgtNumToString(nNumMachFromTable,0)
EgtAddToPackagePath( sBaseDir .. 'MTables\\?.otl')
local TABORD
if EgtExistsFile( sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl') then
TABORD = require( MachiningsTableOrd)
if not TABORD then
DoorOutLog( string.format(EgtDoorsMsg[490], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file
return false
end
else
DoorOutLog( string.format(EgtDoorsMsg[597], sBaseDir .. 'MTables\\' .. MachiningsTableOrd .. '.otl'), 0) -- errore tabella non trovata nel file
return false
end
local dUseOneTab
local AskCustomTable
local dDimPendularDoor
local dMaxDoorLength
local dMinDoorLength
local dMaxDoorWidth
local dMinDoorWidth
local dMaxDoorThick
local dMinDoorThick
local dWideDoorWidth
local sLocSecure
local dMaxOverMat
local dStepOverMat
local nTopSideDriveDisp
local dMaxDistToChain
local dExtraThruDepth
local nGenCncAsDdfName
local dBladePerpLeadIn
local dPercRedFeed
-- imposto i dati macchina secondo le informazioni del file cam
MachName = mCamData[nNumMachFromCam].MachName
Ori1 = mCamData[nNumMachFromCam].Ori1
Ori3 = mCamData[nNumMachFromCam].Ori3
Ori9 = mCamData[nNumMachFromCam].Ori9
Ori10 = mCamData[nNumMachFromCam].Ori10
vShiftAct = mCamData[nNumMachFromCam].Shift1
dUseOneTab = mCamData[nNumMachFromCam].LimitTable
AskCustomTable = mCamData[nNumMachFromCam].AskCustomTable
dDimPendularDoor = mCamData[nNumMachFromCam].DimPendularDoor
dMaxDoorLength = mCamData[nNumMachFromCam].MaxDoorLength
dMinDoorLength = mCamData[nNumMachFromCam].MinDoorLength
dMaxDoorWidth = mCamData[nNumMachFromCam].MaxDoorWidth
dMinDoorWidth = mCamData[nNumMachFromCam].MinDoorWidth
dMaxDoorThick = mCamData[nNumMachFromCam].MaxDoorThick
dMinDoorThick = mCamData[nNumMachFromCam].MinDoorThick
dWideDoorWidth = mCamData[nNumMachFromCam].WideDoorWidth
sLocSecure = mCamData[nNumMachFromCam].sLocSecure
dMaxOverMat = mCamData[nNumMachFromCam].MaxOverMat
dStepOverMat = mCamData[nNumMachFromCam].StepOverMat or 10
nTopSideDriveDisp = mCamData[nNumMachFromCam].TopSideDriveDisp
dMaxDistToChain = mCamData[nNumMachFromCam].MaxDistToChain
dExtraThruDepth = mCamData[nNumMachFromCam].ExtraThruDepthMachining
nGenCncAsDdfName = mCamData[nNumMachFromCam].nGenCncAsDdfName or 0
dBladePerpLeadIn = mCamData[nNumMachFromCam].BladePerpLeadIn or (3*25.4)
dPercRedFeed = mCamData[nNumMachFromCam].PercRedFeed or 0.3
-- se non devo generare il cn esco subito
if MachinesName[nNumMachFromTable].NcGenerate ~= nil and not MachinesName[nNumMachFromTable].NcGenerate then
DoorOutLog( string.format(EgtDoorsMsg[492], MachName), 0) -- warning. Cnc generation disable
return true
end
-- setto come generare il nome del file cnc (di default è uguale al nome del parametro sCode interno ad ddf)
if nGenCncAsDdfName == 0 then
-- assegno al nome file il nome del campo code, come faccio nel main quando creo più pezzi
sFileName = sCode
end
local MTable = TAB.MTable
local MTableOrd = TABORD.MTable
local sLocMachId
local bOk = true
local bFirstStep = true
local bShiftMchng = false
local bSmallShiftedDoor = false
local bWiderDoor = false
local sDispMode
local sNotePhase
local sTotDispMode = ''
local sNumGroup = ''
local bGenFirstStep = false
local nIndexStartMach = 1
local bWork = true
-- variabili utilizzate dentro al ciclo
local nMchId
local sTab
local tabOri
local Ori
local OriDw
local ColA
local nRaw
local bMoveRaw
local bPush
local bFlip
-- local bSpin = false
local bTopOnRight
-- variabili per disposizione sottopezzi
local OffsRef
local OffsVac
local X1r
local X2r
local X3r
local X1
local X2
local Y1r
local Y2r
local Y3r
local Y1
local Y2
local nRef1
local nRef2
local nRef3
local nFix1
local nFix2
local nFix3
local nFix4
local nFix5
local nFix6
local nFix7
local nFix8
local OffsXSovr = 0
local OffsYSovr = 0
-- variabile per tool setup
local bSetUp
local MSetup
local sSetup
local tListError
local sListTool
-- variabili calcolo box
local b3SolidPiece
local b3SolidPiece2
local b3SolidOnTab
local pMin
local pMax
local dOffsX = 0
local dOffsY = 0
-- variabili conteggio lavorazioni profilatura bevel e saltate
local nNumMachSkip = 0
local bLocMach
local sMachProf
local bWorkUnder = false
-- variabile per conteggio lavorazioni
local nNumMach
local nNumSkip
local tSecMachTab = {}
local tSecMachTabOrd = {}
-- variabili per fase
local nNumPhase
local nNumCycle = 1
-- variabili per gestione ripresa porta
local bFlipFirst
local bTopOnRightFirst
local sProfiles = ''
local nNumGeomBottom = 0
local nNumGeomTop = 0
-- Set Current Machine: si setta sulla fase 1
EgtSetCurrMachine( MachName)
-- faccio tutte le fasi
while bWork do
sDispMode = ''
if bFirstStep and not bShiftMchng then
nNumGroup = nNumGroup + 1
-- Set Machining Group
if not sAssemb then -- se pezzo unico
nMchId = EgtAddMachGroup( 'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName)
else
nMchId = EgtAddMachGroup( 'Id_'.. EgtNumToString(Pz,0) ..'_'..'Mach_' .. EgtNumToString(nNumGroup,0) .. '_' .. MachName)
end
nNumPhase = EgtGetCurrPhase()
else
-- se nessuna lavorazione riutilizzo la vecchia fase
if nNumMach == 0 then
EgtRemoveRawPart( nRaw) -- elimino il grezzo
-- elimino la disposizione dei sottopezzi
local nNumFix = EgtGetFirstFixture()
while nNumFix do
EgtRemoveFixture( nNumFix)
nNumFix = EgtGetFirstFixture()
end
else
nNumPhase = EgtAddPhase() -- creo nuova fase
end
-- rendo corrente la fase
if nNumPhase then
EgtSetCurrPhase(nNumPhase)
end
-- se porta large wide cambio la nota a tutte le entità con la nota SkipByLowerPos
if bWiderDoor then
local tSkipByPosList = {}
tSkipByPosList = MB.FindGeomWithNote( Pz, 'SkipByLowerPos', 'i', 1, tSkipByPosList)
for i = 1, #tSkipByPosList do
local nMach = EgtGetInfo( tSkipByPosList[i], 'Mach', 'i') or 1
if nMach > 10 and nMach < 20 then
nMach = nMach - 10
EgtSetInfo( tSkipByPosList[i], 'Mach', nMach)
EgtRemoveInfo( tSkipByPosList[i], 'SkipByLowerPos')
EgtSetInfo( tSkipByPosList[i], 'AlreadyReduceMach', 1)
end
end
end
end
-----------------------------------------------------------------------
-- Calcolo dei sovramateriali e definizione e posizionamento del grezzo
-----------------------------------------------------------------------
if bFirstStep and not bShiftMchng then
-- se check macchina settato per non gestire grezzo
if MachinesName[nNumMachFromTable].MakeRaw ~= nil and not MachinesName[nNumMachFromTable].MakeRaw then
dLeftOffs = 0
dRightOffs = 0
dTopOffs = 0
dBottomOffs = 0
end
else -- fase successiva ribaltata o spostata
-- i profili con lavorazione disabilitata li posso mettere subito a zero
if ( not bLockMach and bAtRight) or ( not bHingeMach and not bAtRight) then -- lavorazione lato serratura disabilitata
dRightOffs = 0
end
if ( not bLockMach and not bAtRight) or ( not bHingeMach and bAtRight) then -- lavorazione lato serratura disabilitata
dLeftOffs = 0
end
if not bTopMach then -- lavorazione lato top disabilitata
dTopOffs = 0
end
if not bBottomMach then -- lavorazione lato top disabilitata
dBottomOffs = 0
end
-- azzero i sovramateriali dei profili che sono stati lavorati
if sMachProf and #sMachProf > 0 then
local sListProf = EgtSplitString( sMachProf, ',')
for m = 1, #sListProf do
if string.lower( sListProf[m]) == 'left' then
dLeftOffs = 0
elseif string.lower( sListProf[m]) == 'right' then
dRightOffs = 0
elseif string.lower( sListProf[m]) == 'top' then
dTopOffs = 0
elseif string.lower( sListProf[m]) == 'bottom' then
dBottomOffs = 0
end
end
end
end
if bFirstStep then
b3SolidPiece = EgtGetBBoxGlob( Pz, GDB_BB.EXACT)
else
b3SolidPiece2 = EgtGetBBoxGlob( Pz, GDB_BB.EXACT)
end
if b3SolidPiece and b3SolidPiece2 then
dOffsX = b3SolidPiece2:getMin():getX() - b3SolidPiece:getMin():getX()
dOffsY = b3SolidPiece2:getMin():getY() - b3SolidPiece:getMin():getY()
end
ColA = Color3d( 255, 165, 0, 15)
nRaw = EgtAddRawPart( Point3d(0,0,0),b3Solid:getDimX() + dLeftOffs + dRightOffs,
b3Solid:getDimY() + dTopOffs + dBottomOffs, b3Solid:getDimZ(), ColA)
EgtAddPartToRawPart( Pz, b3Part:getMin() - b3Solid:getMin() + Vector3d( dLeftOffs + dOffsX, dBottomOffs + dOffsY, 0), nRaw)
-- fase premach, in base al profilo cerniere e/o serratura, e se ci sono lavorazioni sopra o sotto o entrambe,
-- decido su quale lato disporre la porta per evitae inutili ribaltamenti
-- ricavo minimo e massimo del solido del pezzo
b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
pMin = b3SolidOnTab:getMin()
pMax = b3SolidOnTab:getMax()
local tLocMach = {}
local tLocMachOrd = {}
if bFirstStep then
tLocMach = MTable
tLocMachOrd = MTableOrd
if not bShiftMchng then
sMachProf = ''
nIndexStartMach = 1
end
else
tLocMach = tSecMachTab
tLocMachOrd = MTableOrd
if not bShiftMchng then
nIndexStartMach = 1
end
end
-- solo il primo giro, prendo nota dei profili tipo bevel
-- verifico se cave da sotto o da sopra
-- verifico se trovate lavorazioni applicate con 'shift'
if bFirstStep and not bShiftMchng then
local nUnderGeom
for i = 1, #tLocMach do
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
-- se non c'è il campo macchina setto di default la 1
if not sLocMachId then sLocMachId = 1 end
-- se macchina corrispondente
if sLocMachId == nNumMachFromTable then
local sUpperProfName = string.upper(tLocMach[i].Name)
-- prendo i profili bevel direttamente dalla tabella
if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then
if not string.find( sProfiles, sUpperProfName) then
sProfiles = sProfiles .. sUpperProfName .. ','
end
end
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- se flag non ancora settato e trovata geometria e l'associazione è shiftata o la porta è al di sotto del limite..
-- setto il flag di disposizione iniziale Traslata
if not bSmallShiftedDoor and #EntList > 0 and
( ( tLocMach[i].Shift and tLocMach[i].Shift > 0) or dWidthDoor <= DGC.Wl) then
bSmallShiftedDoor = true
end
-- Test delle lavorazioni
for j = 1, #EntList do
-- OPERAZIONI
if tLocMach[i].Oper == 'AdjustThrouIsle' then
bLocMach, nUnderGeom = MB.TestThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder)
if bLocMach then
if nUnderGeom and nUnderGeom == 1 then
nNumGeomBottom = nNumGeomBottom + 1
elseif nUnderGeom and nUnderGeom == -1 then
nNumGeomTop = nNumGeomTop + 1
end
end
elseif tLocMach[i].Oper == 'AdjustVertHole' then
bLocMach, nUnderGeom = MB.TestVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, bWorkUnder)
if bLocMach then
if nUnderGeom and nUnderGeom == 1 then
nNumGeomBottom = nNumGeomBottom + 1
elseif nUnderGeom and nUnderGeom == -1 then
nNumGeomTop = nNumGeomTop + 1
end
end
end
end
end
end
end
elseif not bFirstStep and not bShiftMchng then -- se porta ribaltata
for i = 1, #tLocMach do
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
-- se non c'è il campo macchina setto di default la 1
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- se flag non ancora settato e trovata geometria e l'associazione è shiftata e la porta è al di sotto del limite
-- setto il flag di disposizione iniziale Traslata
if not bSmallShiftedDoor and #EntList > 0 and
( ( tLocMach[i].Shift and tLocMach[i].Shift > 0) or dWidthDoor <= DGC.Wl) then
bSmallShiftedDoor = true
end
end
end
end
end
-- se porta da disporre subito traslata setto i flag
if bSmallShiftedDoor then
bShiftMchng = true -- porta traslata
bGenFirstStep = true -- flag per saltare il primo giro
end
-- se porta è più larga della dimensione limite
if bFirstStep and dWideDoorWidth and dWidthDoor > dWideDoorWidth then
bWiderDoor = true
if AskCustomTable and AskCustomTable == 1 then
local nNumTab = 9
repeat
local sNumTab = '9'
local tPos = EgtDialogBox( 'Origin on table for wide door', {'Origin 1/3 - 9/10', sNumTab})
if tPos and #tPos == 1 then
nNumTab = tonumber( tPos[1])
if nNumTab == 1 then
bWiderDoor = false
elseif nNumTab == 9 then
bWiderDoor = true
end
else
nNumTab = 0
end
until ( nNumTab == 1 or nNumTab == 9)
end
if bWiderDoor then
bSmallShiftedDoor = false
bShiftMchng = false
end
end
-----------------------
-- *** Disposizione ***
-----------------------
-- Scelta della tavola
if bFirstStep then
sTab = 'YTab'
if b3Solid:getDimY() > dUseOneTab then
sTab = 'YVTab'
-- altrimenti se lunghezza è idonea attivare il pendolare ed è selezionabile
elseif dDimPendularDoor and AskCustomTable and b3Solid:getDimY() <= dDimPendularDoor and AskCustomTable == 1 then
local nNumTab = 1
repeat
local sNumTab = '1'
local tPos = EgtDialogBox( 'Choose pendular table(1 for Y table, 2 For V table)', {'Table 2 - 1', sNumTab})
if tPos and #tPos == 1 then
nNumTab = tonumber( tPos[1])
if nNumTab == 1 then
sTab = 'YTab'
elseif nNumTab == 2 then
sTab = 'VTab'
end
else
nNumTab = 0
end
until ( nNumTab == 1 or nNumTab == 2)
end
end
EgtSetTable( sTab)
-- Origine tavola corrente rispetto a Zero macchina
tabOri = EgtGetTableRef( 1)
if bWiderDoor then
-- Scelta dell'origine (ora espressa rispetto Zero Tavola)
if sTab == 'VTab' then
Ori = Ori10 - tabOri
OriDw = Ori1 - tabOri
-- per Y tab o YV tab
else
Ori = Ori9 - tabOri
OriDw = Ori1 - tabOri
end
else
-- Scelta dell'origine (ora espressa rispetto Zero Tavola)
if sTab == 'VTab' then
Ori = Ori3 - tabOri
else
Ori = Ori1 - tabOri
end
end
-- se porta da traslare setto lo shift da applicare
if bShiftMchng then
vShift = vShiftAct
else
vShift = vNullShift
end
Ori = Ori + Vector3d( 0, 0, 80)
Ori = Ori + vShift
if OriDw then
OriDw = OriDw + Vector3d( 0, 0, 80)
OriDw = OriDw + vShift
end
-- Rotazione porta in base alla macchina
bMoveRaw = false
-- definito col cliente: prima comanda il lato hinge, se ha il bevel lo si dispone secondo quello che c'è nel ddf
-- se il lato hinge non ha profilo bevel si guarda il profilo lock, se ha un bevel allora guardo quello.
-- in caso di inactive doors con bevel paralleli comanda ovviamente il lato hinge
-- se non c'è il parametro considero la porta come se avesse bevel down
-- in caso nessuno dei due lati ha un profilo bevel, utilizzo il parametro Secure passato nel ddf
-- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData)
if sSwing == 'RH' or sSwing == 'RHA' or sSwing == 'RHI' or
sSwing == 'LH' or sSwing == 'LHI' or sSwing == 'LHA' then
bPush = true
else
bPush = false
end
local sNumPhase
if nNumPhase and nNumPhase < 10 then
sNumPhase = '0'.. tostring( nNumPhase)
elseif nNumPhase then
sNumPhase = tostring( nNumPhase)
else
sNumPhase = '0'
end
if bFirstStep then
local bOkDisp = false
-- prima controllo che il lato cerniere abbia un bevel (da lavorare), se no passo al lato serratura,
-- se non ha bevel nemmeno il lato serratura considero il parametro secure
-- if ( sHingeTrim == 'BD' or sHingeTrim == 'BU') and bHingeMach then -- se profilo cerniera indicato bevel ed è da lavorare
if ( sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB') then -- se profilo cerniera indicato bevel
-- verifico se i profili risultanti sono presenti in tabella
if sHingeTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BDEB'and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sHingeTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sHingeTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
if ( ( sHingeTrim == 'BD' or sHingeTrim == 'BDEB') and bPush) or
( ( sHingeTrim == 'BU' or sHingeTrim == 'BUEB') and not bPush) then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
else
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
end
end
end
-- se profilo serratura indicato bevel (e da lavorare)
-- if ( sLockTrim == 'BD' or sLockTrim == 'BU') and bLockMach and not bOkDisp then
if ( sLockTrim == 'BD' or sLockTrim == 'BU' or sLockTrim == 'BDEB' or sLockTrim == 'BUEB') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sLockTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sLockTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sLockTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sLockTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sLockTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sLockTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sLockTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sLockTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
if ( ( sLockTrim == 'BD' or sLockTrim == 'BDEB') and bPush) or
( ( sLockTrim == 'BU' or sLockTrim == 'BUEB') and not bPush and not bOppoBevelProf) or
( ( sLockTrim == 'BU' or sLockTrim == 'BUEB') and bPush and bOppoBevelProf) then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
else
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
end
end
end
-- se profilo top indicato bevel (e da lavorare)
if ( sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sTopTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sTopTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sTopTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sTopTrim == 'BD' or sTopTrim == 'BDEB') and bPush) or
( ( sTopTrim == 'BU' or sTopTrim == 'BUEB') and not bPush) then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
else
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
end
end
end
-- se profilo top indicato bevel (e da lavorare)
if ( sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB') and not bOkDisp then
-- verifico se i profili risultanti sono presenti in tabella
if sBottomTrim == 'BD' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BDEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BD' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BDEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BU' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BUEB' and not bPush and string.find( sProfiles, 'BD,') then
bOkDisp = true
elseif sBottomTrim == 'BU' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
elseif sBottomTrim == 'BUEB' and bPush and string.find( sProfiles, 'BU,') then
bOkDisp = true
end
if bOkDisp then
-- casi in cui il bevel indicato nel ddf non corrisponde al bevel generato dallo swing
-- devo ribaltare la porta e la parte top va posizionata in modo che il lato cerniere sia davanti
if ( ( sBottomTrim == 'BD' or sBottomTrim == 'BDEB') and bPush) or
( ( sBottomTrim == 'BU' or sBottomTrim == 'BUEB') and not bPush) then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
-- gli altri casi in cui il bevel indicato corrisponde al bevel generato dallo swing
-- non devo ribaltare la porta e la parte top va posizionata in base al parametro presente nel curcaminfo
else
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
end
end
end
-- in caso non ci sia nessun profilo bevel verifico il parametro Secure
if not bOkDisp then
-- se il parametro secure è passato con valore '0' prendo quello del CurCamInfo atrimenti do errore
if sSecure and string.upper(sSecure) == '0' then
-- se parametro da CurrcamInfo non è valido do errore
if not sLocSecure or ( string.upper(sLocSecure) ~= 'UP' and string.upper(sLocSecure) ~= 'DN') then
bOk = false
DGD.EMC = ' ' .. EgtDoorsMsg[590]
break
else
sSecure = sLocSecure
end
end
-- se lato secure va sopra il ribaltamento è obbligato
if sSecure and string.upper(sSecure) == 'UP' then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
elseif sSecure and string.upper(sSecure) == 'DN' then
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
-- altrimenti la preferenza sembrerebbe essere ( non è ancora confermata) qualla di considerare la porta bevel down
-- quindi se è una reverse non deve essere ribaltata, mentre se è normale deve essere ribaltata
-- ed effettuo il ribaltamento e rotazioni in base allo swing ( con DGD.SwDD = 1 nel file EgtDoorsData)
else
if bSwingDriveDisp then -- se metodo di posizionamento guidato dallo swing
-- se porta a spingere ( dovrebbe avere bevel up) la ribalto per essere bevel down
if bPush then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
-- se porta a tirare non la ribalto perchè si presta già ad essere bevel down
else
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
end
-- in attesa delle considerazioni del cliente, in base alle geometrie trovate ribalto o meno la porta
else
if nNumGeomBottom > nNumGeomTop then
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
elseif nNumGeomTop >= nNumGeomBottom then
bFlip = false
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, not bAtRight)
else -- altrimenti vecchio metodo
bFlip = true
bTopOnRight = CalcTopPosition( nTopSideDriveDisp, bAtRight)
end
end
end
end
if bWiderDoor then
sDispMode = sDispMode .. EgtDoorsMsg[697]
end
if bFlip then
EgtRotateRawPart( nRaw, Y_AX(), 180)
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479]
else
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480]
end
if bTopOnRight then
EgtRotateRawPart( nRaw, Z_AX(), -90)
sDispMode = sDispMode .. EgtDoorsMsg[481]
else
EgtRotateRawPart( nRaw, Z_AX(), 90)
sDispMode = sDispMode .. EgtDoorsMsg[482]
end
if bShiftMchng then
sDispMode = sDispMode .. EgtDoorsMsg[510]
end
-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n'
-- se porta è più larga dela parametro limite
if bWiderDoor then
-- Muovo porta con l'angolo in alto a destra nella posizione di origine
bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.TR)
else
-- Muovo porta con l'angolo in basso a destra nella posizione di origine
bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.BR)
end
-- memorizzo i flag per le fasi successive
bFlipFirst = bFlip
bTopOnRightFirst = bTopOnRight
else -- se sono in ribaltamento porta
-- posizioni opposte
bFlip = not bFlipFirst
if nTopSideDriveDisp and nTopSideDriveDisp == 1 then
bTopOnRight = true
elseif nTopSideDriveDisp and nTopSideDriveDisp == 2 then
bTopOnRight = false
else
bTopOnRight = not bTopOnRightFirst
end
-- faccio le rotazioni della porta e setto per non ribaltarla
if bWiderDoor then
EgtRotateRawPart( nRaw, Z_AX(), 180)
sDispMode = sDispMode .. EgtDoorsMsg[696]
bFlip = bFlipFirst
bTopOnRight = bTopOnRightFirst
end
if bFlip then
EgtRotateRawPart( nRaw, Y_AX(), 180)
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[479]
else
sDispMode = sDispMode .. EgtDoorsMsg[511] .. sNumPhase .. ' ' .. EgtDoorsMsg[480]
end
if bTopOnRight then
EgtRotateRawPart( nRaw, Z_AX(), -90)
sDispMode = sDispMode .. EgtDoorsMsg[EgtIf( bWiderDoor, 482, 481)]
else
EgtRotateRawPart( nRaw, Z_AX(), 90)
sDispMode = sDispMode .. EgtDoorsMsg[EgtIf( bWiderDoor, 481, 482)]
end
if bShiftMchng then
sDispMode = sDispMode .. EgtDoorsMsg[510]
end
-- sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n'
-- se porta larga
if bWiderDoor then
-- Muovo porta con l'angolo in alto a destra nella posizione di origine
local dXShift
if bTopOnRight then
dXShift = dBottomOffs
else
dXShift = dTopOffs
end
bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori+Vector3d( dXShift,0,0), MCH_CR.TR)
else
-- Muovo porta con l'angolo in basso a destra nella posizione di origine
bMoveRaw = EgtMoveToCornerRawPart( nRaw, Ori, MCH_CR.BR)
end
end
if not bMoveRaw then
bOk = false
DGD.EMC = ' ' .. EgtDoorsMsg[528]..EgtDoorsMsg[474] -- Error positioning raw part on table
break
end
if bFirstStep then
if bShiftMchng then
sNotePhase = 'SHIFT'
else
sNotePhase = 'NORMAL'
end
else
if bShiftMchng then
sNotePhase = 'FLIPSHIFT'
else
if bWiderDoor then
sNotePhase = 'NORMAL'
else
sNotePhase = 'FLIP'
end
end
end
-- salvo una nota con le info della disposizione traslata
EgtSetInfo( Pz, 'DoorOnTable' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sDispMode)
EgtSetInfo( Pz, 'KindPhase' .. '_' .. tostring(nNumPhase) .. '_' .. MachName, sNotePhase)
EgtSetInfo( Pz, 'WideDoor', bWiderDoor)
if bFlip then -- se porta capovolta
if bWiderDoor then
if bFirstStep then
if bTopOnRight then -- se top a destra (effettivo)
-- il lato destro riferito in alto è quello delle lock (effettivo)
OffsYSovr = dRightOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
else -- se top a sinistra (effettivo)
-- il lato sinistro riferito in alto è quello delle lock (effettivo)
OffsYSovr = dLeftOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
end
else
if bTopOnRight then -- se top a destra (nominale)
-- il lato sinistro in alto è quello delle hinges (effettivo)
OffsYSovr = dLeftOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
else -- se top a sinistra (nominale)
-- il lato destro riferito in alto è quello delle hinges (effettivo)
OffsYSovr = dRightOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
end
end
else
if bTopOnRight then -- se top a destra (effettivo)
-- il lato sinistro riferito in basso è quello delle hinges (effettivo)
OffsYSovr = dLeftOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
else -- se top a sinistra (effettivo)
-- il lato destro riferito in basso è quello delle hinges (effettivo)
OffsYSovr = dRightOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
end
end
else -- altrimenti non è capovolta
-- se porta larga
if bWiderDoor then
if bFirstStep then
if bTopOnRight then -- se top a destra (effettivo)
-- il lato sinistro riferito in alto è quello delle lock (effettivo)
OffsYSovr = dLeftOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
else -- se top a sinistra (effettivo)
-- il lato destro riferito in alto è quello delle lock (effettivo)
OffsYSovr = dRightOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
end
else
if bTopOnRight then -- se top a destra (nominale)
-- il lato destro riferito in alto è quello delle hinges (effettivo)
OffsYSovr = dRightOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
else -- se top a sinistra (nominale)
-- il lato sinistro in alto è quello delle hinges (effettivo)
OffsYSovr = dLeftOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
end
end
else
if bTopOnRight then -- se top a destra (effettivo)
-- il lato destro riferito in basso è quello delle hinges (effettivo)
OffsYSovr = dRightOffs
-- il lato top si trova a destra (effettivo)
OffsXSovr = dTopOffs
else -- se top a sinistra
-- il lato sinistro riferito in basso è quello delle hinges (effettivo)
OffsYSovr = dLeftOffs
-- il lato bottom si trova a destra (effettivo)
OffsXSovr = dBottomOffs
end
end
end
-- Controllo dimensioni pezzo
-- controllo se le dimensioni porta sono compresi nei valori minimi e massimi
bFailDim = CheckPieceDimension( dLengthDoor, dWidthDoor, dThickDoor, OffsXSovr, OffsYSovr,
vShift:getX(), vShift:getY(), dMinDoorLength, dMaxDoorLength, dMinDoorWidth,
dMaxDoorWidth, dMinDoorThick, dMaxDoorThick)
if bFailDim then
DGD.ERR = 19
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..'.txt')
-- se lanciato da DMach stampo anche un messaggio a video
if not DGD or not DGD.NCGEN then
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 0)
DoorOutLog( DGD.EMC, 0)
EgtOutBox( ' Err=' .. tostring( DGD.ERR) .. DGD.EMC, EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation
end
return false
end
-- Inserimento riferimenti e ventose
local dPosxRef = b3Solid:getDimY()
if dPosxRef <= dUseOneTab and dPosxRef > 2305.05 then
dPosxRef = 2305.05
end
OffsRef = 70
OffsVac = 40
X1r = Ori:getX() + OffsRef
X2r = Ori:getX() - 150
X3r = Ori:getX() - dPosxRef + 150
X1 = Ori:getX() - dPosxRef + 25 + OffsVac - OffsXSovr
X2 = Ori:getX() - 25 - OffsVac - OffsXSovr
local dAngRef
if bWiderDoor then
Y1r = Ori:getY() - ( Ori9:getY() - Ori1:getY()) + 100
Y2r = Ori:getY() + OffsRef + abs( vShift:getY())
Y3r = Ori:getY() + OffsRef + abs( vShift:getY())
Y1 = Ori:getY() - b3Solid:getDimX() + 25 + OffsVac - OffsYSovr
if Y1 < (OriDw:getY() + 25 + OffsVac) then
Y1 = OriDw:getY() + 25 + OffsVac
end
Y2 = Ori:getY() - 25 - OffsVac - OffsYSovr
dAngRef = 180
else
Y1r = Ori:getY() + 100
Y2r = Ori:getY() - OffsRef - abs( vShift:getY())
Y3r = Ori:getY() - OffsRef - abs( vShift:getY())
Y1 = Ori:getY() + 25 + OffsVac + OffsYSovr
Y2 = Ori:getY() + b3Solid:getDimX() - 25 - OffsVac + OffsYSovr
dAngRef = 0
end
nRef1 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X1r), Y1r, 0), 90)
nRef2 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X2r), Y2r, 0), dAngRef)
nRef3 = EgtAddFixture( 'RefD140SH', Point3d( MB.AdjustXFixture( X3r), Y3r, 0), dAngRef)
nFix1 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X1), Y1, 0))
nFix2 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X1), Y2, 0), 180)
nFix3 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.66*X1+0.34*X2), Y1, 0))
nFix4 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.66*X1+0.34*X2), Y2, 0), 180)
nFix5 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.34*X1+0.66*X2), Y1, 0))
nFix6 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( 0.34*X1+0.66*X2), Y2, 0), 180)
nFix7 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X2), Y1, 0))
nFix8 = EgtAddFixture( 'Sub80X40H80', Point3d( MB.AdjustXFixture( X2), Y2, 0), 180)
-- *** Lavorazioni ***
local bMakeGhost = EgtIf( bFirstStep, true, false)
-- ricavo minimo e massimo del solido del pezzo
b3SolidOnTab = EgtGetBBoxGlob( Ls, GDB_BB.EXACT)
pMin = b3SolidOnTab:getMin()
pMax = b3SolidOnTab:getMax()
-- print Machining table
for i = nIndexStartMach, #tLocMach do
DoorOutLog( 'L'..tostring( i) .. ' EN='.. (tLocMach[i].On or ' ') ..' N='.. tLocMach[i].Name .. ' O='.. (tLocMach[i].Oper or ' ') ..
' M='.. (tLocMach[i].Mach or ' ') .. ' MAC='.. (tLocMach[i].MachName or ' '), -1)
end
-- solo il primo giro aggiusto i profili bevel per essere coerente con la sequenza di tabella
if bFirstStep and ( not bShiftMchng or bSmallShiftedDoor) then
for i = 1, #tLocMach do
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name)
-- Applico le lavorazioni
for j = 1, #EntList do
-- OPERAZIONI
if tLocMach[i].Oper and tLocMach[i].Oper == 'AdjustBevel' then
local sNewName
_, sNewName = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep)
end
end
end
end
end
end
-- conteggio lavorazioni saltate
nNumMachSkipResult = 0
-- variabile per conteggio lavorazioni
nNumMach = 0
nNumSkip = 0
-- se porta ribatata inverto anche le variabili contatori lavorazioni sopra e sottp
if bFlip then
local nValAppo = nNumGeomBottom
nNumGeomBottom = nNumGeomTop
nNumGeomTop = nValAppo
end
local bEnBreak = false
-- Machining adding, only for selected machine
-- faccio tutto in un unico giro per non dover avere due contatori di break, uno per le operazioni e uno per le lavorazioni
for i = nIndexStartMach, #tLocMach do
-- se devo uscire dal ciclo
if bEnBreak then break end
if tLocMach[i].On ~= 0 then
sLocMachId = tLocMach[i].MachId
if not sLocMachId then sLocMachId = 1 end
if sLocMachId == nNumMachFromTable then
-- Recupero le entità
local sHide = EgtIf( bFirstStep, '','_HIDE')
local EntList = MB.FindEntitiesWithName( Pz, tLocMach[i].Name..sHide)
-- Applico le lavorazioni
for j = 1, #EntList do
local nNewIdEnt
local nNewIdEnt2
local nLocMach
-- OPERAZIONI
if tLocMach[i].Oper then
if tLocMach[i].Oper == 'AdjustBevel' then
local sNewName
-- ottengo il nome del lato lavorato
local sEdge = EgtGetName( EgtGetParent( EntList[j]))
bLocMach, sNewName, nNewIdEnt, nNewIdEnt2 = MB.AdjustBevel( EntList[j], tLocMach[i].Name, bFirstStep, nil, bMakeGhost, bWiderDoor, sEdge, true)
if bLocMach then
local bInsLav = false
-- faccio il test per vedere se la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
nLocMach = nMach
if nMach == 1 then
bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
-- se la lavorazione è applicabile e non scatena lo shift
-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then
-- se la lavorazione è applicabile
if bInsLav then
if sEdge then
-- se porta large wide e prima fase inserisco l'eventuale profilo di lavorazione del solo lato lock
if bWiderDoor and bFirstStep then
if ( string.lower( sEdge) == 'left' and not bAtRight) or ( string.lower( sEdge) == 'right' and bAtRight) then
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
end
else
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
end
-- if bFirstStep then
-- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura
if string.lower( sEdge) == 'left' then
local dOffsLoc = 0
if bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'right' then
local dOffsLoc = 0
if bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'top' then
local dOffsLoc = 0
if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sTopTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[3]
local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[3] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
if nNewIdEnt2 then
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc)
end
elseif string.lower( sEdge) == 'bottom' then
local dOffsLoc = 0
if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
end
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
if nNewIdEnt2 then
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc)
end
end
-- end
end
end
else
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustVertCurve' then
bOk, nNewIdEnt = MB.AdjustVertCurve( EntList[j], bMakeGhost)
elseif tLocMach[i].Oper == 'AdjustRoughCurve' then
bOk, nNewIdEnt = MB.AdjustThrouCurve( EntList[j], bMakeGhost, true)
elseif tLocMach[i].Oper == 'AdjustThrouCurve' then
-- ottengo il nome del lato lavorato
local sEdge = EgtGetName( EgtGetParent( EntList[j]))
bLocMach, nNewIdEnt, nNewIdEnt2 = MB.AdjustThrouCurve( EntList[j], bMakeGhost, nil, bWiderDoor, sEdge, true, bFirstStep)
if bLocMach then
local bInsLav = false
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
nLocMach = nMach
if nMach == 1 then
bInsLav = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
-- se la lavorazione è applicabile e non scatena lo shift
-- if bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then
-- se la lavorazione è applicabile
if bInsLav then
if sEdge then
-- se porta large wide e prima fase inserisco l'eventuale profilo di lavorazione del solo lato lock
if bWiderDoor and bFirstStep then
if ( string.lower( sEdge) == 'left' and not bAtRight) or ( string.lower( sEdge) == 'right' and bAtRight) then
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
end
else
if #sMachProf > 0 then
sMachProf = sMachProf .. ',' .. sEdge
else
sMachProf = sEdge
end
end
-- if bFirstStep then
-- in base a quale lato è verifico se il sovramateriale supera il valore massimo e genero sgrossatura
if string.lower( sEdge) == 'left' then
local dOffsLoc = 0
if bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dLeftOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'right' then
local dOffsLoc = 0
if bAtRight then
if sLockTrim == 'BD' or sLockTrim == 'BD_LK' or sLockTrim == 'BU' or sLockTrim == 'BU_LK' or
sLockTrim == 'BDEB' or sLockTrim == 'BDEB_LK' or sLockTrim == 'BUEB' or sLockTrim == 'BUEB_LK' then
dOffsLoc = dThickDoor * TAN3
elseif sLockTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[2]
local dMaxInsPrf = sqrt((tsRadiusProf[2]*tsRadiusProf[2])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[2] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
elseif not bAtRight then
if sHingeTrim == 'BD' or sHingeTrim == 'BU' or sHingeTrim == 'BDEB' or sHingeTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sHingeTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[1]
local dMaxInsPrf = sqrt((tsRadiusProf[1]*tsRadiusProf[1])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[1] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
end
MB.MakeRoughPaths( dRightOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, false, bFlip, nil, dOffsLoc)
elseif string.lower( sEdge) == 'top' then
local dOffsLoc = 0
if sTopTrim == 'BD' or sTopTrim == 'BU' or sTopTrim == 'BDEB' or sTopTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
elseif sTopTrim == 'CV' then
-- calcolo minimo ingombro profilo
local dAltProf = dThickDoor/2 - tsPlaneProf[3]
local dMaxInsPrf = sqrt((tsRadiusProf[3]*tsRadiusProf[3])-(dAltProf*dAltProf))
dOffsLoc = tsRadiusProf[3] - dMaxInsPrf
-- assegno al nuovo percorso il delta tra il fondo profilo e il bordo porta
EgtSetInfo( nNewIdEnt, 'OFFSTOPATH', dOffsLoc)
end
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
if nNewIdEnt2 then
MB.MakeRoughPaths( dTopOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc)
end
elseif string.lower( sEdge) == 'bottom' then
local dOffsLoc = 0
if sBottomTrim == 'BD' or sBottomTrim == 'BU' or sBottomTrim == 'BDEB' or sBottomTrim == 'BUEB' then
dOffsLoc = dThickDoor * TAN3
end
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt, true, bFlip, nil, dOffsLoc)
if nNewIdEnt2 then
MB.MakeRoughPaths( dBottomOffs, dMaxOverMat, dStepOverMat, nNewIdEnt2, true, bFlip, nil, dOffsLoc)
end
end
-- end
end
end
else
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustThrouIsle' then
bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustThrouIsle( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth)
if not bLocMach then -- se operazione fallita
bOk = false
end
if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
if nMach == 11 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach})
elseif nMach == 12 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp})
elseif nMach == 13 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw})
end
end
nNumMachSkip = nNumMachSkipResult
else -- se non skippata provo a verificare se la lavorazione è applicabile
local bInsLav = true
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
nLocMach = nMach
local sResMach
if nMach == 1 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
-- se la lavorazione non è applicabile e non scatena lo shift
-- if not bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then
-- se la lavorazione non è applicabile
if not bInsLav then
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
if nMach == 1 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].Mach})
elseif nMach == 2 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachUp})
elseif nMach == 3 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw})
end
end
-- se nome lavorazione non nullo, incremento i contatori
if sResMach and #sResMach > 0 then
-- aumento di 1 il numero di lavorazioni skippate
nNumMachSkip = nNumMachSkip + 1
-- ricambio la nota come non lavorabile in questa fase
EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10)
-- incremento il numero di lavorazioni da sotto
nNumGeomBottom = nNumGeomBottom + 1
end
end
end
elseif tLocMach[i].Oper == 'AdjustHorizAS' then
bLocMach, nNewIdEnt = MB.AdjustHorizAS( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustHorNegativeAS' then
bLocMach, nNewIdEnt = MB.AdjustHorNegativeAS( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustMortise' then
bLocMach,_, nNewIdEnt = MB.AdjustMortise( EntList[j], 0, NO_WORK_UNDERSQUARE, bMakeGhost )
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustVertHole' then
bLocMach, nNumMachSkipResult, nNewIdEnt = MB.AdjustVertHole( EntList[j], b3Solid:getDimZ(), pMin, pMax, nNumMachSkip, bFirstStep, bWorkUnder, bMakeGhost, dExtraThruDepth)
if not bLocMach then
bOk = false
end
if nNumMachSkipResult > nNumMachSkip then -- se lavorazione skippata la inserisco nella tabella
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
if nMach == 11 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 1 ,tLocMach[i].Mach})
elseif nMach == 12 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 2 ,tLocMach[i].MachUp})
elseif nMach == 13 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { 3 ,tLocMach[i].MachDw})
end
end
nNumMachSkip = nNumMachSkipResult
else -- se non skippata provo a verificare se la lavorazione è applicabile
local bInsLav = true
-- faccio un test per vedere che la lavorazione è applicabile
local nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
nLocMach = nMach
local sResMach
if nMach == 1 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].Mach, nNewIdEnt)
elseif nMach == 2 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachUp, nNewIdEnt)
elseif nMach == 3 then
bInsLav, sResMach = MB.TestMachining( tLocMach[i].MachDw, nNewIdEnt)
end
-- se la lavorazione non è applicabile e non scatena lo shift
-- if not bInsLav and ( bShiftMchng or not tLocMach[i].Shift or tLocMach[i].Shift == 0) then
-- se la lavorazione non è applicabile
if not bInsLav then
if bFirstStep then
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
if nMach == 1 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].Mach})
elseif nMach == 2 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachUp})
elseif nMach == 3 then
EgtSetInfo( nNewIdEnt, 'JoinMach', { nMach ,tLocMach[i].MachDw})
end
end
-- se nome lavorazione non nullo, incremento i contatori
if sResMach and #sResMach > 0 then
-- aumento di 1 il numero di lavorazioni skippate
nNumMachSkip = nNumMachSkip + 1
-- ricambio la nota come non lavorabile in questa fase
EgtSetInfo( nNewIdEnt, 'Mach', nMach + 10)
-- incremento il numero di lavorazioni da sotto
nNumGeomBottom = nNumGeomBottom + 1
end
end
end
elseif tLocMach[i].Oper == 'AdjustHole' then
bLocMach, nNewIdEnt = MB.AdjustHole( EntList[j], bMakeGhost)
if not bLocMach then
bOk = false
end
elseif tLocMach[i].Oper == 'AdjustBladeVertCurve' then
bOk, nNewIdEnt = MB.AdjustBladeVertCurve( EntList[j], bMakeGhost)
end
else -- se nessuna operazione
if bMakeGhost then
nNewIdEnt = MB.MakeGhostCopy( EntList[j])
else
nNewIdEnt = EntList[j]
end
end
local nMach
if nNewIdEnt then
nMach = EgtGetInfo( nNewIdEnt, 'Mach', 'i') or 1
else
nMach = 0
end
if nMach > 30 and nMach < 40 then nMach = nMach - 30 end
-- se porta large width e la geoemtria è lavorabile, verifico se è in posizione lavorabile
if bWiderDoor and nMach >= 1 and nMach <= 3 then
-- considero solo entità con il nome che contiene '_HIDE'
local sNameEnt = EgtGetName( nNewIdEnt)
if sNameEnt and string.find( sNameEnt, '_HIDE') then
local b3f1 = EgtGetBBoxGlob( nNewIdEnt, GDB_BB.EXACT)
local dYmin = b3f1:getMin():getY()
-- se il punto minimo è più in basso esco dalla funzione
if dYmin < ( pMax:getY() - dWideDoorWidth) then
nNumMachSkip = nNumMachSkip + 1
nMach = nMach + 10
EgtSetInfo( nNewIdEnt, 'Mach', nMach)
EgtSetInfo( nNewIdEnt, 'SkipByLowerPos', 1)
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
end
if nNewIdEnt2 then
sNameEnt = EgtGetName( nNewIdEnt2)
local nMach2 = nMach
if sNameEnt and string.find( sNameEnt, '_HIDE') then
local b3f1 = EgtGetBBoxGlob( nNewIdEnt2, GDB_BB.EXACT)
local dYmin = b3f1:getMin():getY()
-- se il punto minimo è più in basso esco dalla funzione
if dYmin < ( pMax:getY() - dWideDoorWidth) then
nNumMachSkip = nNumMachSkip + 1
if nMach2 >= 1 and nMach2 <= 3 then
nMach2 = nMach2 + 10
end
EgtSetInfo( nNewIdEnt2, 'Mach', nMach2)
EgtSetInfo( nNewIdEnt2, 'SkipByLowerPos', 1)
-- inserisco in tabella solo se non già presente
tSecMachTab = AddMachIntable( tLocMach[i], tSecMachTab, i)
end
end
end
end
local bScroll = true
-- LAVORAZIONI
-- se prima lavorazione, valida, con chiave Shift abilitata, esco dal giro
--[[
if ( nMach > 0 and nMach < 4) and
not bShiftMchng and
tLocMach[i].Shift == 1 then
bShiftMchng = true -- flag per traslazione Y
-- nIndexStartMach = i -- ripartenza da questa posizione
nIndexStartMach = 1 -- ripartenza dall'inizio
nNumMach = 0 -- azzero le lavorazioni in modo da ricreare la disposizione traslata
bScroll = false -- salto l'applicazione delle lavorazioni in seguito
bEnBreak = true -- blocco il for della scansione tabella
-- cancello tutti i percorsi ghost
local DelList = MB.FindEntitiesWithPartName( Pz, '_HIDE')
-- ciclo su tutte le entità trovate
for j = 1, #DelList do
EgtErase( DelList[j] )
end
DelList = nil
-- se fase di ripresa rimetto la nota mach disabilitata
if not bFirstStep then
nMach = nMach + 10
EgtSetInfo( EntList[j], 'Mach', nMach)
nNumMachSkip = nNumMachSkip + 1
end
end
--]]
if not bScroll then
break -- esco dal ciclo for j
else
if nMach > 0 and nMach < 4 then -- se è fuori range non ci entro nemmeno
-- carico id entità in una tabella
local tListSameMach = {}
table.insert( tListSameMach, nNewIdEnt)
local bCalMach = true
-- se non primo passo e nota JoinMach differisce dal mach e dalla lavorazione
if not bFirstStep then
local sJoinMach = EgtGetInfo( nNewIdEnt, 'JoinMach')
if sJoinMach and #sJoinMach > 1 then
local tJoinMach = EgtSplitString( sJoinMach)
if tJoinMach and #tJoinMach == 2 then
local nNumMachRef = tonumber( tJoinMach[1])
local sMachRefJoin = tJoinMach[2]
if nNumMachRef ~= nMach then
bCalMach = false
elseif nNumMachRef == 1 and sMachRefJoin and tLocMach[i].Mach and tLocMach[i].Mach ~= sMachRefJoin then
bCalMach = false
elseif nNumMachRef == 2 and sMachRefJoin and tLocMach[i].MachUp and tLocMach[i].MachUp ~= sMachRefJoin then
bCalMach = false
elseif nNumMachRef == 3 and sMachRefJoin and tLocMach[i].MachDw and tLocMach[i].MachDw ~= sMachRefJoin then
bCalMach = false
end
end
end
end
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tLocMach[i].Name, nNumGroup, tLocMach[i].Mach,
tLocMach[i].MachUp, tLocMach[i].MachDw, bOk, nNumMach, false,
NOT_GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed, bCalMach)
else
local sLocMachName
if not nLocMach or nLocMach == 1 then
sLocMachName = tLocMach[i].Mach
elseif nLocMach == 2 then
sLocMachName = tLocMach[i].MachUp
elseif nLocMach == 3 then
sLocMachName = tLocMach[i].MachDw
elseif nLocMach == 21 then -- caso particolare quando falliscono sia la lavorazione top che bottom
sLocMachName = tLocMach[i].Mach
if tLocMach[i].MachUp then
sLocMachName = sLocMachName .. ' + ' .. tLocMach[i].MachUp
end
end
DoorOutLog( EgtDoorsMsg[497]..tostring( EntList[j])..' '..tLocMach[i].Name.. EgtDoorsMsg[595].. EgtIf( sLocMachName, sLocMachName, '') ..
EgtDoorsMsg[596]..tostring( nNumPhase), 0)
nNumSkip = nNumSkip + 1
end
end
end
end
end
end -- end for
local i = 1
while i <= #tLocMachOrd and not bEnBreak do
-- carico tutto il gruppo in una tabella
local tGroup = {}
local nNumGrp = tLocMachOrd[i].Group
local sProperty = tLocMachOrd[i].Property
tGroup, i = MB.GetGroup( tLocMachOrd, i, nNumGrp, sProperty)
if sProperty and nNumGrp > 0 then -- se esiste proprietà del gruppo e non è 0
if sProperty == 'MinDist' then -- ottimizzare alla minima distanza
-- prendo l'ultima lavorazione inserita ( lavorazione o disposizione)
local LastMch = EgtGetLastOperation()
local EndLastMach
-- se l'ultima lavorazione non sia nulla o non sia disposizione mi faccio dare il punto finale
if EgtGetOperationType(LastMch) ~= MCH_OY.DISP and EgtGetOperationType(LastMch) ~= MCH_OY.NONE then
EgtSetCurrMachining( LastMch)
EndLastMach = EgtGetMachiningEndPoint()
end
local tMachining = {}
-- creo lavorazioni del gruppo
for k = 1, #tGroup do
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE')
local bAdjustHead = false
-- Applico le lavorazioni
for j = 1, #EntList do
-- LAVORAZIONI
local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMach = nMach - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
local sMachining = EgtGetInfo( EntList[j], 'Machining')
-- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima
if nMach > 0 and nMach < 4 then nMach = 1 end
-- se è fuori range o non corrispondono le lavorazioni
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach, tMachining = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach,
tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead,
GEN_MACH, tMachining, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
-- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata
-- tolgo di mezzo le note secondarie
-- for j = 1, #EntList do
-- EgtRemoveInfo( EntList[j], 'Mach2nd')
-- end
end
-- ordino le lavorazioni
if #tMachining > 1 then
-- Tavole per fresature da ordinare
local TabMill = {}
local TabMStEnP = {}
local TabZMach = {}
for k = 1, #tMachining do
-- Se appartiene alla fase corrente e fresatura non vuota
if EgtGetOperationPhase( tMachining[k][1]) == nNumPhase then
EgtSetCurrMachining( tMachining[k][1])
local ptStart = EgtGetMachiningStartPoint()
local ptEnd = EgtGetMachiningEndPoint()
if ptStart and ptEnd then
table.insert( TabMill, tMachining[k][1])
table.insert( TabMStEnP, { ptStart, ptEnd})
MB.InsZedByTool( TabZMach, tMachining, k)
end
end
end
-- calcolo ordinamento
EgtSpInit()
for k = 1, #TabMill do
EgtSpAddPoint( TabMStEnP[k][1]:getX(), TabMStEnP[k][1]:getY(), TabZMach[k], 0, 0,
TabMStEnP[k][2]:getX(), TabMStEnP[k][2]:getY(), TabZMach[k], 0, 0)
end
if EndLastMach then
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,EndLastMach:getX(),EndLastMach:getY(),0,90,90)
else
EgtSpSetOpenBound(true,SHP_OB.NEAR_PNT,-2000,0,0,90,90)
end
local vMillOrd = EgtSpCalculate(SHP_TY.OPEN)
EgtSpTerminate()
-- applico ordinamento calcolato
-- parto da LastMch precedente
if vMillOrd then
for k = 1, #vMillOrd do
EgtRelocateGlob(TabMill[vMillOrd[k]],LastMch,GDB_IN.AFTER)
LastMch = TabMill[vMillOrd[k]]
end
end
end
elseif sProperty == 'Layer' then -- lavorazione layer
-- ottengo tutte le entità del gruppo
local EntListGrp = MB.LoadEntitiesFromGroup( tGroup, Pz, '_HIDE')
-- Applico le lavorazioni
for j = 1, #EntListGrp do
local nParendId = EgtGetParent(EntListGrp[j])
-- Recupero la prima entità del layer padre
local EntList = MB.FindEntities( nParendId, true)
-- LAVORAZIONI
local nMach = 1
-- riciclo per prendere tutte le entità di un gruppo che devono essere lavorate assieme
bOk, nNumMach = MakeGroupMachining( EntList, nParendId, tGroup, nMach, nNumGrp,
nNumMach, bOk, '_HIDE', dMaxDistToChain, EndLastMach,
dBladePerpLeadIn, dPercRedFeed)
end
elseif sProperty == '' then -- proprietà nulla
-- creo lavorazioni del gruppo
for k = 1, #tGroup do
-- Recupero le entità
local EntList = MB.FindEntitiesWithName( Pz, tGroup[k].Name..'_HIDE')
local bAdjustHead = false
-- Applico le lavorazioni
for j = 1, #EntList do
-- LAVORAZIONI
local nMach = EgtGetInfo( EntList[j], 'Mach', 'i') or 1
nMach = nMach - 30 -- se lavorazione corretta ottengo 1
local nMach2nd = EgtGetInfo( EntList[j], 'Mach2nd', 'i') or 0
local sMachining = EgtGetInfo( EntList[j], 'Machining')
-- con questa tabella non ci sono seconde o terze lavorazioni, solo la prima
if nMach > 0 and nMach < 4 then nMach = 1 end
if sMachining and nMach == 1 and nMach2nd == 0 and sMachining == tGroup[k].Mach then
-- cerco di unire più entità nella stessa lavorazione ( non da sotto e non oltre una certa distanza)
local tListSameMach = MB.FindEntitiesCompMach( EntList[j], EntList, sMachining, tGroup[k].Join, dMaxDistToChain)
-- se più di 1 entità le ordino
if #tListSameMach > 1 then
tListSameMach = MB.OrderEnt( tListSameMach, EndLastMach)
EndLastMach = EgtSP( tListSameMach[#tListSameMach], GDB_ID.ROOT )
end
bOk, nNumMach = InsertMachiningByMachNum( tListSameMach, nMach, tGroup[k].Name, nNumGrp, tGroup[k].Mach,
tGroup[k].MachUp, tGroup[k].MachDw, bOk, nNumMach, bAdjustHead,
GEN_MACH, nil, dBladePerpLeadIn, dPercRedFeed)
-- se ho assegnato lavorazione a più entità, marco quelle che ho già fatto
SetInfoTable( tListSameMach, 'Mach2nd', 1)
local nNewMach = EgtGetInfo( tListSameMach[1], 'Mach', 'i') or 1
if nNewMach > 30 and nNewMach < 40 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-20) -- assegno nota per non lavorarla di nuovo
elseif nNewMach > 40 and nNewMach < 50 then
SetInfoTable( tListSameMach, 'Mach', nNewMach-30) -- assegno nota per non lavorarla di nuovo
end
end
end
-- 11/01/2019 commento la cancellazione della nota per evitare di lavorare una seconda volta una geometria già lavorata
-- tolgo di mezzo le note secondarie
-- for j = 1, #EntList do
-- EgtRemoveInfo( EntList[j], 'Mach2nd')
-- end
end
end
elseif nNumGrp == 0 then -- se lavorazioni in gruppo 0 do errore
DGD.ERR = -15
if DGD.EMC and #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
else
DGD.EMC = '\n' .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
end
if DGD.ERM and #DGD.ERM > 0 then
DGD.ERM = DGD.ERM .. ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
else
DGD.ERM = ' ' .. string.format(EgtDoorsMsg[639], tGroup[1].Name) -- con gruppo 0 c'è solo un'istanza
end
end
i = i + 1
end
-- se ci sono state lavorazioni accodo la disposizione delle fase
if nNumMach > 0 then
sTotDispMode = sTotDispMode .. ' ' .. sDispMode .. '\n'
else -- altrimenti nessuna lavorazione
if not bFirstStep then -- se non è il primo giro elimino la fase vuota
-- se ho più di una fase elimino l'ultima fase
if nNumPhase > 1 then
EgtRemoveLastPhase()
end
-- setto corrente fase precedente
if nPrevPhase then
EgtSetCurrPhase(nPrevPhase)
nNumPhase = nPrevPhase
end
end
end
-- se sono al primissimo giro
if not bGenFirstStep then
-- la lavorazione di traslazione ho rotazione (porta larga) hanno priorità sul ribaltamento
-- se trovata traslazione setto il flag per il prossimo giro
if bShiftMchng then
bGenFirstStep = true
if not bFirstStep then -- se sono già in ripresa porta resetto il contatore di lavorazioni saltate
nNumMachSkip = 0 -- resetto per il prossimo giro
end
else
-- se nessuna geometria skippata esco
if nNumMachSkip and nNumMachSkip == 0 then bWork = false end
-- se lavorazioni skippate abilito il ribaltamento porta in altra fase
if nNumMachSkip and nNumMachSkip > 0 then
-- con lavorazioni skippate ma già con pezzo non in prima fase e non shiftato, esco
if not bFirstStep then
bWork = false
else
bFirstStep = false
end
nNumMachSkip = 0 -- resetto per il prossimo giro
end
end
else -- altrimenti ho già fatto un giro e ho trovato la traslazione
-- se nessuna geometria skippata esco
if nNumMachSkip == 0 then bWork = false end
-- se lavorazioni skippate abilito il ribaltamento porta in altra fase
if nNumMachSkip and nNumMachSkip > 0 then
nNumMachSkip = 0 -- resetto per il prossimo giro
if bFirstStep then -- se ho terminato il giro con eventuale traslazione o rotazione disabilito la traslazione
-- disativo la traslazione sul giro successvo
bShiftMchng = false
-- disattivo il flag che indica di disporre la porta subito traslata
bSmallShiftedDoor = false
-- disattivo il flag che indica la porta larga
bWiderDoor = false
end
bFirstStep = false
end
end
-- se porta larga inibisco il ribaltamento
-- if bWiderDoor then bWork = false end
-- controllo di sicurezza
if nNumCycle > 4 then bWork = false end
nNumCycle = nNumCycle + 1
end -- end while
--------------------------
--------------------------
-- *** Tools Setup ***
--------------------------
--------------------------
-- provo a importare l'attrezzaggio di default, se fallisce passo gli altri
bSetUp = EgtImportSetup()
sListTool = ''
if bSetUp then -- se importato quello di default
sSetup = EgtGetDefaultSetupName()
-- verifico se l'attrezzaggio è idoneo
bSetUp, tListError = EgtVerifyCurrSetup()
-- se attrezzaggio andato a buon fine setto il nome dell'attrezzaggio di default
if bSetUp then
-- assegno nota con il nome del file setup assegnato
EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup)
else -- preparo la lista degli utensili mancanti
sListTool = string.format( EgtDoorsMsg[552], sSetup) .. ' (Default)'
sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553]
for k = 1, #tListError do
sListTool = sListTool .. '\n ' .. tListError[k]
end
end
else
sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], ' ') .. ' (from Default)'
end
-- se fallito quello di default o utensili mancanti provo quelli indicati nel CurrCamInfo
if not bSetUp then
local sDefSetUp = sSetup -- mi tengo via il nome dell'attrezzaggio di default
local nContImport = 0
-- ciclo tra quelli disponibili
for k = 1, 50 do
if not bSetUp then
if k == 1 then
sSetup = mCamData[nNumMachFromCam].Setup1
elseif k == 2 then
sSetup = mCamData[nNumMachFromCam].Setup2
elseif k == 3 then
sSetup = mCamData[nNumMachFromCam].Setup3
elseif k == 4 then
sSetup = mCamData[nNumMachFromCam].Setup4
elseif k == 5 then
sSetup = mCamData[nNumMachFromCam].Setup5
elseif k == 6 then
sSetup = mCamData[nNumMachFromCam].Setup6
elseif k == 7 then
sSetup = mCamData[nNumMachFromCam].Setup7
elseif k == 8 then
sSetup = mCamData[nNumMachFromCam].Setup8
elseif k == 9 then
sSetup = mCamData[nNumMachFromCam].Setup9
elseif k == 10 then
sSetup = mCamData[nNumMachFromCam].Setup10
elseif k == 11 then
sSetup = mCamData[nNumMachFromCam].Setup11
elseif k == 12 then
sSetup = mCamData[nNumMachFromCam].Setup12
elseif k == 13 then
sSetup = mCamData[nNumMachFromCam].Setup13
elseif k == 14 then
sSetup = mCamData[nNumMachFromCam].Setup14
elseif k == 15 then
sSetup = mCamData[nNumMachFromCam].Setup15
elseif k == 16 then
sSetup = mCamData[nNumMachFromCam].Setup16
elseif k == 17 then
sSetup = mCamData[nNumMachFromCam].Setup17
elseif k == 18 then
sSetup = mCamData[nNumMachFromCam].Setup18
elseif k == 19 then
sSetup = mCamData[nNumMachFromCam].Setup19
elseif k == 20 then
sSetup = mCamData[nNumMachFromCam].Setup20
elseif k == 21 then
sSetup = mCamData[nNumMachFromCam].Setup21
elseif k == 22 then
sSetup = mCamData[nNumMachFromCam].Setup22
elseif k == 23 then
sSetup = mCamData[nNumMachFromCam].Setup23
elseif k == 24 then
sSetup = mCamData[nNumMachFromCam].Setup24
elseif k == 25 then
sSetup = mCamData[nNumMachFromCam].Setup25
elseif k == 26 then
sSetup = mCamData[nNumMachFromCam].Setup26
elseif k == 27 then
sSetup = mCamData[nNumMachFromCam].Setup27
elseif k == 28 then
sSetup = mCamData[nNumMachFromCam].Setup28
elseif k == 29 then
sSetup = mCamData[nNumMachFromCam].Setup29
elseif k == 30 then
sSetup = mCamData[nNumMachFromCam].Setup30
elseif k == 31 then
sSetup = mCamData[nNumMachFromCam].Setup31
elseif k == 32 then
sSetup = mCamData[nNumMachFromCam].Setup32
elseif k == 33 then
sSetup = mCamData[nNumMachFromCam].Setup33
elseif k == 34 then
sSetup = mCamData[nNumMachFromCam].Setup34
elseif k == 35 then
sSetup = mCamData[nNumMachFromCam].Setup35
elseif k == 36 then
sSetup = mCamData[nNumMachFromCam].Setup36
elseif k == 37 then
sSetup = mCamData[nNumMachFromCam].Setup37
elseif k == 38 then
sSetup = mCamData[nNumMachFromCam].Setup38
elseif k == 39 then
sSetup = mCamData[nNumMachFromCam].Setup39
elseif k == 40 then
sSetup = mCamData[nNumMachFromCam].Setup40
elseif k == 41 then
sSetup = mCamData[nNumMachFromCam].Setup41
elseif k == 42 then
sSetup = mCamData[nNumMachFromCam].Setup42
elseif k == 43 then
sSetup = mCamData[nNumMachFromCam].Setup43
elseif k == 44 then
sSetup = mCamData[nNumMachFromCam].Setup44
elseif k == 45 then
sSetup = mCamData[nNumMachFromCam].Setup45
elseif k == 46 then
sSetup = mCamData[nNumMachFromCam].Setup46
elseif k == 47 then
sSetup = mCamData[nNumMachFromCam].Setup47
elseif k == 48 then
sSetup = mCamData[nNumMachFromCam].Setup48
elseif k == 49 then
sSetup = mCamData[nNumMachFromCam].Setup49
elseif k == 50 then
sSetup = mCamData[nNumMachFromCam].Setup50
end
-- se nome attrezzaggio non è vuoto
if sSetup and #sSetup > 0 then
bSetUp = EgtImportSetup(sSetup)
end
if bSetUp then -- se importato il fle da CurrCamInfo
nContImport = nContImport + 1
-- verifico se l'attrezzaggio è idoneo
bSetUp, tListError = EgtVerifyCurrSetup()
if bSetUp then -- se è andato bene
-- assegno nota con il nome del file setup assegnato
EgtSetInfo( EgtGetCurrSetup(), 'Name', sSetup)
break
else -- se utensili mancanti prendo la lista e passo al successivo
sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[552], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k)
sListTool = sListTool .. '\n ' .. EgtDoorsMsg[553]
for k = 1, #tListError do
sListTool = sListTool .. '\n ' .. tListError[k]
end
end
else -- se non importato carico il messaggio di errore e passo al successivo
sListTool = sListTool .. '\n ' .. string.format( EgtDoorsMsg[554], sSetup) .. string.format(' (from CurrCamInfo Setup%s)', k)
end
end
end
-- se nessuno è andato bene verifico se il primo era stato importato
if not bSetUp then
-- se ho importato almeno un attrezzaggio do errore
if ( sDefSetUp and #sDefSetUp > 0) or
nContImport > 0 then
if DGD.EMC and #DGD.EMC > 0 then
DGD.EMC = DGD.EMC .. '\n' .. ' ' .. EgtDoorsMsg[551]
else
DGD.EMC = ' ' .. EgtDoorsMsg[551]
end
bOk = false
if #sListTool > 0 then
DGD.EMC = DGD.EMC .. sListTool
end
else -- setup default non definito
-- assegno ugualmente un attrezzaggio vuoto
EgtSetInfo( EgtGetCurrSetup(), 'Name', EgtDoorsMsg[555])
end
end
end
if nNumGroup > 1 then sNumGroup = '_'..EgtNumToString(nNumGroup,0) end
-- Eventuale messaggio di errore
if not bOk then
DoorOutLog( string.format(EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina
DGD.ERR = 20
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1)
-- stampo gli errori del machiningBase
if DGD.EMC and #DGD.EMC > 0 then
DoorOutLog( DGD.EMC, 0)
end
DoorOutLog( string.format( EgtDoorsMsg[475], MachName), 0) -- Error on machining calculation
-- cancello il file cn e il txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.cnc')
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con l'errore
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', string.format( EgtDoorsMsg[475], MachName))
if not DGD.NCGEN then -- modificato not DGD con not DGD.NCGEN perche ho incluso EgtDoorsData dove esiste DGD
if DGD.EMC and #DGD.EMC > 0 then
EgtOutBox( DGD.EMC .. '\n' .. string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation
else
EgtOutBox( string.format( EgtDoorsMsg[475], MachName), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on machining calculation
end
end
-- Salvo progetto
EgtSaveFile()
return false, nNumGroup
end
-- Applica tutte le lavorazioni ( che comprende anche l'aggiornamento, EgtUpdateAllMachinings con il calcolo assi macchina e movimenti tra lavorazioni e finale)
EgtApplyAllMachinings( false, false)
-- Salvo progetto
EgtSaveFile()
-- Estimation
bOk = EgtEstimate( sFileDir..sFileName..sNumGroup..'.html', 'EgtCam5 - '..sFilePath)
-- NC code generation
bOk = EgtGenerate( sFileDir..sFileName..sNumGroup..'.cnc', 'EgtCam5 - '..sFilePath)
if bOk then
if not DGD.ERR then DGD.ERR = 0 end
DoorOutLog( string.format( '\n'..EgtDoorsMsg[494], MachName), 0) -- inizio lavorazione su macchina
DoorOutLog( ' Err=' .. tostring( DGD.ERR), 1)
if not DGD.NCGEN then
if DGD.ERM and #DGD.ERM > 0 then
DoorOutLog( DGD.ERM, 0) -- stampo la disposizione nel log
end
end
DoorOutLog( sTotDispMode, 0) -- stampo la disposizione nel log
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt', sTotDispMode)
else
DGD.ERR = 20
DGD.EMC = DGD.EMC .. string.format(EgtDoorsMsg[478], MachName, sSetup)
-- cancello e ricreo il file txt
EgtEraseFile( sFileDir..sFileName..sNumGroup..'.txt')
--ricreo il file txt con la disposizione
WriteErrFile( sFileDir..sFileName..sNumGroup..'.txt')
-- scrivo messaggio nei file log
DoorOutLog( string.format(EgtDoorsMsg[478], MachName, sSetup), 0) -- Error on Nc part program generation
-- se lanciato da DMach stampo anche un messaggio a video
if not DGD or not DGD.NCGEN then
EgtOutBox( string.format(EgtDoorsMsg[478], MachName, sSetup), EgtDoorsMsg[476], EgtDoorsMsg[477]) -- Error on Nc part program generation
end
return false, nNumGroup
end
-- reset librerie locali
package.loaded[MachiningsTable] = nil
package.loaded[MachiningsTableOrd] = nil
return true, nNumGroup
end
return MachiningLoc