- Correzioni e migliorie su pezzo di esempio
- Gestione avvio script solo quando eseguiti precedenti - Correzioni varie
This commit is contained in:
+59
-25
@@ -13,31 +13,56 @@ EgtOutLog( ' RunViewManager started', 1)
|
||||
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'})
|
||||
local nVisibilityMode = LAYER_VIEW_TYPE.ALL -- 1 = All, 2 = Till Selected, 3 = Only Selected
|
||||
local nShellType = SHELL_VIEW_TYPE.ALL -- 1 = All, 2 = Outer, 3 = Inner, 4 = infill
|
||||
local nOldSelLayerId = GDB_ID.NULL
|
||||
|
||||
-- leggo ultimi valori
|
||||
local nViewId = EgtGetFirstNameInGroup( GDB_ID.ROOT, VIEWPARAMS)
|
||||
if nViewId then
|
||||
nVisibilityMode = EgtGetInfo( nViewId, KEY_LAYER_VIEW, 'i')
|
||||
nShellType = EgtGetInfo( nViewId, KEY_SHELL_VIEW, 'i')
|
||||
nOldSelLayerId = EgtGetInfo( nViewId, KEY_SEL_LAYER, 'i') or GDB_ID.NULL
|
||||
end
|
||||
local sLayerViewCombo = ''
|
||||
if nVisibilityMode == LAYER_VIEW_TYPE.TILL_SEL then
|
||||
sLayerViewCombo = 'CB:All,*Till Selected,Only Selected'
|
||||
elseif nVisibilityMode == LAYER_VIEW_TYPE.ONLY_SEL then
|
||||
sLayerViewCombo = 'CB:All,Till Selected,*Only Selected'
|
||||
else
|
||||
sLayerViewCombo = 'CB:*All,Till Selected,Only Selected'
|
||||
end
|
||||
local sShellViewCombo = ''
|
||||
if nShellType == SHELL_VIEW_TYPE.OUTER then
|
||||
sShellViewCombo = 'CB:All,*Outer,Inner,Infill'
|
||||
elseif nShellType == SHELL_VIEW_TYPE.INNER then
|
||||
sShellViewCombo = 'CB:All,Outer,*Inner,Infill'
|
||||
elseif nShellType == SHELL_VIEW_TYPE.INFILL then
|
||||
sShellViewCombo = 'CB:All,Outer,Inner,*Infill'
|
||||
else
|
||||
sShellViewCombo = 'CB:*All,Outer,Inner,Infill'
|
||||
end
|
||||
|
||||
ViewValues = EgtDialogBox( 'Slicing visibility manager', { 'Visibility Mode', sLayerViewCombo},
|
||||
{ 'Shell type', sShellViewCombo})
|
||||
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
|
||||
nVisibilityMode = LAYER_VIEW_TYPE.ALL
|
||||
elseif ViewValues[1] == 'Till Selected' then
|
||||
nVisibilityMode = 2
|
||||
nVisibilityMode = LAYER_VIEW_TYPE.TILL_SEL
|
||||
elseif ViewValues[1] == 'Only Selected' then
|
||||
nVisibilityMode = 3
|
||||
nVisibilityMode = LAYER_VIEW_TYPE.ONLY_SEL
|
||||
end
|
||||
local nShellType = 0 -- 1 = All, 2 = Outer, 3 = Inner, 4 = infill
|
||||
if ViewValues[2] == 'All' then
|
||||
nShellType = 1
|
||||
nShellType = SHELL_VIEW_TYPE.ALL
|
||||
elseif ViewValues[2] == 'Outer' then
|
||||
nShellType = 2
|
||||
nShellType = SHELL_VIEW_TYPE.OUTER
|
||||
elseif ViewValues[2] == 'Inner' then
|
||||
nShellType = 3
|
||||
nShellType = SHELL_VIEW_TYPE.INNER
|
||||
elseif ViewValues[2] == 'Infill' then
|
||||
nShellType = 4
|
||||
nShellType = SHELL_VIEW_TYPE.INFILL
|
||||
end
|
||||
local nInnerNumber = tonumber(ViewValues[3])
|
||||
|
||||
-- Recupero ultimo layer selezionato
|
||||
-- verifico sia un pezzo valido
|
||||
@@ -53,12 +78,16 @@ function RunViewManager.Exec()
|
||||
nSelLayerId = EgtGetParent( nSelLayerId)
|
||||
end
|
||||
if not bFound then
|
||||
if nVisibilityMode ~= 1 then
|
||||
EgtOutBox( 'No selected element!', 'Warning', 'WARNING')
|
||||
return
|
||||
if nOldSelLayerId and nOldSelLayerId ~= GDB_ID.NULL then
|
||||
nSelLayerId = nOldSelLayerId
|
||||
else
|
||||
nSelLayerId = GDB_ID.NULL
|
||||
sSelLayerName = ''
|
||||
if nVisibilityMode ~= LAYER_VIEW_TYPE.ALL then
|
||||
EgtOutBox( 'No selected element!', 'Warning', 'WARNING')
|
||||
return
|
||||
else
|
||||
nSelLayerId = GDB_ID.NULL
|
||||
sSelLayerName = ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,11 +99,11 @@ function RunViewManager.Exec()
|
||||
local nLayerIndex = 1
|
||||
local nLayerId = EgtGetFirstNameInGroup( nPartId, SLICE_LAYER .. nLayerIndex)
|
||||
while nLayerId do
|
||||
if nVisibilityMode == 1 then -- All
|
||||
if nVisibilityMode == LAYER_VIEW_TYPE.ALL then
|
||||
EgtSetStatus( nLayerId, GDB_ST.ON)
|
||||
elseif nVisibilityMode == 2 then -- Till Selected
|
||||
elseif nVisibilityMode == LAYER_VIEW_TYPE.TILL_SEL then
|
||||
EgtSetStatus( nLayerId, EgtIf( nLayerId <= nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
|
||||
elseif nVisibilityMode == 3 then -- Only Selected
|
||||
elseif nVisibilityMode == LAYER_VIEW_TYPE.ONLY_SEL then
|
||||
EgtSetStatus( nLayerId, EgtIf( nLayerId == nSelLayerId, GDB_ST.ON, GDB_ST.OFF))
|
||||
end
|
||||
local nCrvId = EgtGetFirstGroupInGroup( nLayerId)
|
||||
@@ -83,21 +112,21 @@ function RunViewManager.Exec()
|
||||
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))
|
||||
EgtSetStatus( nShellId, EgtIf( nShellType == SHELL_VIEW_TYPE.ALL or ( nShellType == SHELL_VIEW_TYPE.OUTER and nType == TYPE.OUTER_SHELL) or (nShellType == SHELL_VIEW_TYPE.INNER and nType == TYPE.INNER_SHELL), 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))
|
||||
EgtSetStatus( nSurfId, EgtIf( nShellType == SHELL_VIEW_TYPE.ALL or ( nShellType == SHELL_VIEW_TYPE.OUTER and nType == TYPE.OUTER_SHELL) or (nShellType == SHELL_VIEW_TYPE.INNER and nType == TYPE.INNER_SHELL), 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))
|
||||
EgtSetStatus( nShellId, EgtIf( nType and ( nShellType == SHELL_VIEW_TYPE.ALL or ( nShellType == SHELL_VIEW_TYPE.OUTER and nType == TYPE.OUTER_SHELL) or (nShellType == SHELL_VIEW_TYPE.INNER and nType == TYPE.INNER_SHELL)), GDB_ST.ON, GDB_ST.OFF))
|
||||
nShellId = EgtGetNext( nShellId)
|
||||
end
|
||||
nCrvId = EgtGetNext( nCrvId)
|
||||
@@ -109,6 +138,11 @@ function RunViewManager.Exec()
|
||||
nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex)
|
||||
end
|
||||
|
||||
-- riporto impostazioni in gruppo apposito
|
||||
EgtSetInfo( nViewId, KEY_LAYER_VIEW, nVisibilityMode)
|
||||
EgtSetInfo( nViewId, KEY_SHELL_VIEW, nShellType)
|
||||
EgtSetInfo( nViewId, KEY_SEL_LAYER, nSelLayerId)
|
||||
|
||||
EgtDraw()
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user