Files
trimming/ResetSelect.lua
T
Riccardo Elitropi 5dd7acad75 Trimming 3.1a1 :
- Primo Commit
2026-01-19 11:31:08 +01:00

56 lines
2.0 KiB
Lua

-- ResetSelect.lua by Egalware s.r.l. 2026/01/05
require( 'EgtBase')
_ENV = EgtProtectGlobal()
EgtEnableDebug( false)
-- Carico le costanti di Trimming
EgtAddToPackagePath( EgtGetSourceDir() .. '?.lua')
local GlobVar = require( 'TrimmingLib')
-- Costante di Errore
local ERROR_SELECTION = 'Error in Surf Selection : '
-- Recupero il Part e Layer di Trimming corrente
local nCurrPartId = EgtGetCurrPart()
local nCurrLayerId = EgtGetCurrLayer()
local nTrimmingLayer = GlobVar.GetTrimmingLayerRefId( nCurrLayerId)
if not nTrimmingLayer or nTrimmingLayer == GDB_ID.NULL then
EgtOutBox( ERROR_SELECTION .. 'Not a valid Trimming Layer', 'Error', 'ERROR', 'OK')
return
end
-- Chiedo all'Utente la conferma dell'operazione
local bRemove = EgtOutBox( 'Do you want to remove the last Selected Surface ?', 'Deleting', 'QUESTION', 'YESNO')
if not bRemove then return end
-- Rendo invisibili gli altri Layer di Trimmatura e tutti i Layer Temporanei
-- NB. Il focus va sul Layer corrente
EgtSetStatus( nTrimmingLayer, GDB_ST.ON)
local nId = EgtGetFirstInGroup( nCurrPartId)
while nId do
if nId ~= nTrimmingLayer and GlobVar.IsTrimmingLayer( nId) then EgtSetStatus( nId, GDB_ST.OFF) end
nId = EgtGetNext( nId)
end
-- Rimuovo Tutte le Entità ad Eccezione delle Superfici Selezionate ( nel caso Le rendo Visibili)
local vIdToErase = {}
nId = EgtGetFirstInGroup( nTrimmingLayer)
while nId do
local sName = EgtGetName( nId)
if sName ~= SELECTION_SURF_NAME then table.insert( vIdToErase, nId)
else EgtSetStatus( nId, GDB_ST.ON) end
nId = EgtGetNext( nId)
end
EgtErase( vIdToErase)
-- Se Esiste un Layer di Edit o di Store, lo Rimuovo
local vEditOrStoreLayerIds = GlobVar.GetAllEditOrStoredLayer( nTrimmingLayer)
if vEditOrStoreLayerIds ~= nil and #vEditOrStoreLayerIds ~= 0 then EgtErase( vEditOrStoreLayerIds) end
-- Recupero l'ultima(le ultime) Supercicie(i) aggiunta(e) e la(e) elimino
local vLastSurfIds = EgtGetInfo( nTrimmingLayer, KEY_SELECTION_LAST_IDS, 'vi')
if vLastSurfIds ~= nil and #vLastSurfIds ~= 0 then EgtErase( vLastSurfIds) end
-- Aggiorno la grafica
EgtDraw()