Files
DataBeamWall/ShowNesting.lua
Dario Sassi 731759bcf3 DataBeamWall :
- aggiunto comando ShowNesting.
2025-07-24 12:36:18 +02:00

106 lines
3.4 KiB
Lua

-- ShowNesting.lua by Egaltech s.r.l. 2025/07/24
-- Gestione visualizzazione pareti come nesting
-- Intestazioni
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-----------------------------------------------------------------------------------------
local function IsNestAux( ObjId)
local sName = EgtGetName( ObjId)
return ( sName == 'Part' or
sName == 'Box' or
sName == 'Outline' or
sName == 'Processings' or
sName == 'Solid')
end
-----------------------------------------------------------------------------------------
local function GetFirstNestPart( GroupId)
local PartId = EgtGetFirstInGroup( GroupId)
while PartId and IsNestAux( PartId) do
PartId = EgtGetNext( PartId)
end
return PartId
end
-----------------------------------------------------------------------------------------
local function GetNextNestPart( PartId)
PartId = EgtGetNext( PartId)
while PartId and IsNestAux( PartId) do
PartId = EgtGetNext( PartId)
end
return PartId
end
-----------------------------------------------------------------------------------------
-- recupero l'eventuale gruppo di nesting
local RawPartsId = EgtGetFirstNameInGroup( GDB_ID.ROOT, 'RawParts')
if not RawPartsId then
EgtOutBox( "There is no nesting", 'ShowNesting', 'WARNING', 'OK')
return
end
-- ciclo sui grezzi del nesting
local RawId = EgtGetFirstInGroup( RawPartsId)
while RawId do
-- recupero il primo oggetto nel gruppo e verifico se devo assemblare o disassemblare
local AsseId = GetFirstNestPart( RawId)
if not AsseId then return end
local bMake = ( EgtGetGroupObjs( AsseId) == 0)
-- sistemo stato di visualizzazione del grezzo
EgtSetStatus( RawId, EgtIf( bMake, GDB_ST.ON, GDB_ST.OFF))
-- ciclo sul gruppo di assemblaggio
while AsseId do
-- recupero il successivo nel gruppo dell'assemblato
local NextId = GetNextNestPart( AsseId)
-- costruisco l'assemblato
if bMake then
-- recupero il pezzo sorgente
local SouId = EgtGetInfo( AsseId, GDB_SI.SOURCE, 'i')
if SouId then
EgtSetMode( SouId, GDB_MD.STD)
EgtSetStatus( SouId, GDB_ST.ON)
-- se già utilizzato, ne faccio una copia
if not EgtIsPart( SouId) then
local CopyId = EgtCopy( SouId, GDB_ID.ROOT)
if CopyId then
EgtRemoveInfo( CopyId, GDB_SI.BASE)
EgtRemoveInfo( CopyId, GDB_SI.LIST)
EgtSetInfo( CopyId, GDB_SI.COPY, SouId)
SouId = CopyId
EgtSetInfo( AsseId, GDB_SI.SOURCE, SouId)
end
end
EgtSetStatus( EgtGetFirstNameInGroup( SouId, 'Box') or GDB_ID.NULL, GDB_ST.OFF)
EgtGroupSwap( SouId, AsseId, true, true)
end
-- ritorno ai pezzi
else
local BasId = EgtGetInfo( AsseId, GDB_SI.BASE, 'i')
if BasId then
EgtGroupSwap( AsseId, BasId, true, true)
local CopId = EgtGetInfo( AsseId, GDB_SI.COPY, 'i')
if CopId then
EgtErase( AsseId)
EgtSetInfo( BasId, GDB_SI.SOURCE, CopId)
else
EgtSetStatus( EgtGetFirstNameInGroup( AsseId, 'Box') or GDB_ID.NULL, GDB_ST.ON)
end
end
end
-- passo al successivo
AsseId = NextId
end
-- passo al successivo
RawId = EgtGetNext( RawId)
end
EgtZoom( SCE_ZM.ALL)
-- end