-- RunSlicePalette.lua by Egaltech s.r.l. 2022/04/05 -- Gestione visualizzazione per Stampa 3d -- Tabella per definizione modulo local RunSlicePalette = {} -- Intestazioni require( 'EgtBase') EgtOutLog( ' RunSlicePalette started', 1) -- Costanti generali local AMD = require( 'AddManData') function RunSlicePalette.UpdateColors( nPaletteType) -- 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 local nCrvId = EgtGetFirstGroupInGroup( nLayerId) while nCrvId do local nSolidId = EgtGetFirstNameInGroup( nCrvId, SOLID_GRP) local nSurfId = EgtGetFirstInGroup( nSolidId) local nOldType = 0 while nSurfId do local Color = EgtStdColor( 'GRAY') if nPaletteType == PALETTE_TYPE.IN_OUT then local nType = EgtGetInfo( nSurfId, KEY_TYPE, 'i') if not nType or ( nType ~= 1 and nType ~= 2 and nType ~= 3 and nType ~= 4) then nType = nOldType end nOldType = nType -- scelta del colore if nType == TYPE.OUTER_SHELL then Color = EgtStdColor( 'TEAL') elseif nType == TYPE.INNER_SHELL then Color = EgtStdColor( 'ORANGE') elseif nType == TYPE.LINK then Color = EgtStdColor( 'GRAY') elseif nType == TYPE.INFILL then Color = EgtStdColor( 'YELLOW') end else local nResult = EgtGetInfo( nLayerId, KEY_RESULT, 'i') if nResult == RESULT.OK then Color = EgtStdColor( 'GREEN') elseif nResult == RESULT.KO_MINUS then Color = EgtStdColor( 'ORANGE') elseif nResult == RESULT.KO_PLUS then Color = EgtStdColor( 'RED') end end EgtSetColor( nSurfId, Color) nSurfId = EgtGetNext( nSurfId) 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 function RunSlicePalette.Exec() local nParamsGrp = EgtGetFirstNameInGroup( GDB_ID.ROOT, PARAMS_GRP) or GDB_ID.NULL local nOldPaletteType = EgtGetInfo( nParamsGrp, KEY_PALETTE, 'i') local sCombo = EgtIf( not nOldPaletteType or nOldPaletteType == 1, 'CB:*In/Out,Results', 'CB:In/Out,*Results') ViewValues = EgtDialogBox( 'Slice Palette', { 'Type', sCombo}) if not ViewValues or #ViewValues < 1 then return end local nPaletteType = PALETTE_TYPE.IN_OUT -- 1 = In/Out, 2 = Results if ViewValues[1] == 'In/Out' then nPaletteType = PALETTE_TYPE.IN_OUT elseif ViewValues[1] == 'Results' then nPaletteType = PALETTE_TYPE.RESULTS end EgtSetInfo( nParamsGrp, KEY_PALETTE, nPaletteType) RunSlicePalette.UpdateColors( nPaletteType) end --------------------------------------------------------------------- return RunSlicePalette