Files
egwwindowlua/CAMAuto/LuaLibs/WinLib.lua
T
andrea.villa aeeaac3326 - Nuova gestione AddOperation
- Prima versione ordinamento lavorazioni
- In WinLib funzioni base per ordinamento
2024-10-03 11:54:17 +02:00

114 lines
4.4 KiB
Lua

-- WinLib.lua by Egalware s.r.l. 2024/06/14
-- Libreria globale per Serramenti
-- Tabella per definizione modulo
local WinLib = {}
-- Include
require( 'EgtBase')
local WinData = require( 'WinData')
EgtOutLog( ' WinLib started', 1)
-------------------------------------------------------------------------------------------------------------
-- restituisce le facce della parte interessate dalla feature Proc
function WinLib.GetAffectedFaces( Proc, Part)
local vtFacesAffected = { bTop = false, bBottom = false, bFront = false, bBack = false, bLeft = false, bRight = false}
if Proc.b3Box and not Proc.b3Box:isEmpty() then
-- caso speciale foro
if Proc.sType == 'Hole' and Proc.ReferenceSide then
if Proc.ReferenceSide == Part.SideNames.sLeft then
vtFacesAffected.bLeft = true
elseif Proc.ReferenceSide == Part.SideNames.sRight then
vtFacesAffected.bRight = true
elseif Proc.ReferenceSide == Part.SideNames.sFront then
vtFacesAffected.bFront = true
elseif Proc.ReferenceSide == Part.SideNames.sBack then
vtFacesAffected.bBack = true
end
-- caso speciale profilo
elseif Proc.sType == 'Profiling' then
if not Part.SideNames then
Part.SideNames = {}
end
if Proc.b3Box:getMax():getX() < Part.b3FinishedPart:getCenter():getX() then
vtFacesAffected.bLeft = true
Part.SideNames.sLeft = Proc.sEntityName
elseif Proc.b3Box:getMin():getX() > Part.b3FinishedPart:getCenter():getX() then
vtFacesAffected.bRight = true
Part.SideNames.sRight = Proc.sEntityName
elseif Proc.b3Box:getMax():getY() < Part.b3FinishedPart:getCenter():getY() then
vtFacesAffected.bFront = true
Part.SideNames.sFront = Proc.sEntityName
elseif Proc.b3Box:getMin():getY() > Part.b3FinishedPart:getCenter():getY() then
vtFacesAffected.bBack = true
Part.SideNames.sBack = Proc.sEntityName
end
-- caso standard
else
if Proc.b3Box:getMax():getZ() > Part.b3FinishedPart:getMax():getZ() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bTop = true
end
if Proc.b3Box:getMin():getZ() < Part.b3FinishedPart:getMin():getZ() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bBottom = true
end
if Proc.b3Box:getMin():getY() < Part.b3FinishedPart:getMin():getY() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bFront = true
end
if Proc.b3Box:getMax():getY() > Part.b3FinishedPart:getMax():getY() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bBack = true
end
if Proc.b3Box:getMin():getX() < Part.b3FinishedPart:getMin():getX() + 500 * GEO.EPS_SMALL then
vtFacesAffected.bLeft = true
end
if Proc.b3Box:getMax():getX() > Part.b3FinishedPart:getMax():getX() - 500 * GEO.EPS_SMALL then
vtFacesAffected.bRight = true
end
end
end
return vtFacesAffected
end
-------------------------------------------------------------------------------------------------------------
function WinLib.SwapElements( Table, Pos1, Pos2)
Table[Pos1], Table[Pos2] = Table[Pos2], Table[Pos1]
return Table
end
-------------------------------------------------------------------------------------------------------------
function WinLib.ChangeElementPositionInTable( Table, nCurrentPosition, nTargetPosition)
-- se indici uguali esco subito
if nTargetPosition == nCurrentPosition then
return Table
end
local Item = Table[nCurrentPosition]
if nTargetPosition > nCurrentPosition then
nTargetPosition = nTargetPosition - 1
end
table.remove( Table, nCurrentPosition)
table.insert( Table, nTargetPosition, Item)
return Table
end
-------------------------------------------------------------------------------------------------------------
function WinLib.GetAddGroup( PartId)
-- recupero il nome del gruppo di lavoro corrente
local sMchGrp = EgtGetMachGroupName( EgtGetCurrMachGroup() or GDB_ID.NULL)
if not sMchGrp then
return nil, nil
end
-- cerco il gruppo aggiuntivo omonimo nel pezzo e se esiste lo restituisco
local AddGrpId = EgtGetFirstNameInGroup( PartId or GDB_ID.NULL, sMchGrp)
-- restituisco Id e Nome
return AddGrpId, sMchGrp
end
-------------------------------------------------------------------------------------------------------------
return WinLib