118 lines
4.5 KiB
Lua
118 lines
4.5 KiB
Lua
-- RunViewManager.lua by Egaltech s.r.l. 2022/04/05
|
|
-- Gestione visualizzazione per Stampa 3d
|
|
|
|
-- Tabella per definizione modulo
|
|
local RunViewManager = {}
|
|
|
|
-- Intestazioni
|
|
require( 'EgtBase')
|
|
|
|
EgtOutLog( ' RunViewManager started', 1)
|
|
|
|
-- Costanti generali
|
|
local AMD = require( 'AddManData')
|
|
|
|
function RunViewManager.Exec()
|
|
ViewValues = EgtDialogBox( 'Slicing visibility manager', { 'Visibility Mode', 'CB:*All,Till Selected,Only Selected'},
|
|
{ 'Shell type', 'CB:*All,Outer,Inner,Infill'},
|
|
{ 'Inner Number', '1'})
|
|
if not ViewValues or #ViewValues < 2 then return end
|
|
|
|
|
|
local nVisibilityMode = 1 -- 1 = All, 2 = Till Selected, 3 = Only Selected
|
|
if ViewValues[1] == 'All' then
|
|
nVisibilityMode = 1
|
|
elseif ViewValues[1] == 'Till Selected' then
|
|
nVisibilityMode = 2
|
|
elseif ViewValues[1] == 'Only Selected' then
|
|
nVisibilityMode = 3
|
|
end
|
|
local nShellType = 0 -- 1 = All, 2 = Outer, 3 = Inner, 4 = infill
|
|
if ViewValues[2] == 'All' then
|
|
nShellType = 1
|
|
elseif ViewValues[2] == 'Outer' then
|
|
nShellType = 2
|
|
elseif ViewValues[2] == 'Inner' then
|
|
nShellType = 3
|
|
elseif ViewValues[2] == 'Infill' then
|
|
nShellType = 4
|
|
end
|
|
local nInnerNumber = tonumber(ViewValues[3])
|
|
|
|
-- Recupero ultimo layer selezionato
|
|
-- verifico sia un pezzo valido
|
|
local sSelLayerName = ''
|
|
local bFound = false
|
|
local nSelLayerId = EgtGetLastSelectedObj()
|
|
while nSelLayerId do
|
|
local sSelLayerName = EgtGetName( nSelLayerId)
|
|
if sSelLayerName and sSelLayerName:sub(1, 5) == SLICE_LAYER then
|
|
bFound = true
|
|
break
|
|
end
|
|
nSelLayerId = EgtGetParent( nSelLayerId)
|
|
end
|
|
if not bFound then
|
|
if nVisibilityMode ~= 1 then
|
|
EgtOutBox( 'No selected element!', 'Warning', 'WARNING')
|
|
return
|
|
else
|
|
nSelLayerId = GDB_ID.NULL
|
|
sSelLayerName = ''
|
|
end
|
|
end
|
|
|
|
-- ciclo sui pezzi
|
|
local nPartIndex = 1
|
|
local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
|
|
while nPartId do
|
|
-- ciclo sui layer per dis/attivare il resto
|
|
local nLayerIndex = 1
|
|
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
|
|
while nLayerId do
|
|
if nVisibilityMode == 1 then -- All
|
|
EgtSetStatus( nLayerId, GDB_ST.ON)
|
|
elseif nVisibilityMode == 2 then -- Till Selected
|
|
EgtSetStatus( nLayerId, EgtIf( nLayerId <= nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
|
|
elseif nVisibilityMode == 3 then -- Only Selected
|
|
EgtSetStatus( nLayerId, EgtIf( nLayerId == nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
|
|
end
|
|
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
|
|
while nCrvId do
|
|
local nPathId = EgtGetFirstNameInGroup( nCrvId, PATH_GRP)
|
|
local nShellId = EgtGetFirstInGroup( nPathId)
|
|
while nShellId do
|
|
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
|
|
EgtSetStatus( nShellId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
|
|
nShellId = EgtGetNext( nShellId)
|
|
end
|
|
local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP)
|
|
local nSurfId = EgtGetFirstInGroup( nSolidId)
|
|
while nSurfId do
|
|
local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i')
|
|
EgtSetStatus( nSurfId, EgtIf( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber), GDB_ST.ON, GDB_ST.OFF))
|
|
nSurfId = EgtGetNext( nSurfId)
|
|
end
|
|
local nToolPathId = EgtGetFirstNameInGroup( nCrvId, TOOLPATH_GRP)
|
|
nShellId = EgtGetFirstInGroup( nToolPathId)
|
|
while nShellId do
|
|
local nType = EgtGetInfo( nShellId, KEY_TYPE, 'i')
|
|
EgtSetStatus( nShellId, EgtIf( nType and ( nShellType == 1 or ( nShellType == 2 and nType == 0) or (nShellType == 3 and nType == nInnerNumber)), GDB_ST.ON, GDB_ST.OFF))
|
|
nShellId = EgtGetNext( nShellId)
|
|
end
|
|
nCrvId = EgtGetNext( nCrvId)
|
|
end
|
|
nLayerIndex = nLayerIndex + 1
|
|
nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
|
|
end
|
|
nPartIndex = nPartIndex + 1
|
|
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
|
|
end
|
|
|
|
EgtDraw()
|
|
|
|
end
|
|
|
|
---------------------------------------------------------------------
|
|
return RunViewManager
|