-- RunSlicePalette.lua by Egaltech s.r.l. 2022/08/23 -- Gestione visualizzazione per Stampa 3d -- Tabella per definizione modulo local RunSlicePalette = {} -- Intestazioni require( 'EgtBase') EgtOutLog( ' RunSlicePalette started', 1) -- Costanti generali local AMD = require( 'AddManData') -- Librerie _G.package.loaded.RunCalcSolids = nil local CSOLIDS = require( 'RunCalcSolids') --------------------------------------------------------------------- function RunSlicePalette.UpdateColors( nPaletteType) -- ciclo sui pezzi local nPartIndex = 1 local nPartId = EgtGetFirstNameInGroup( GDB_ID.ROOT, PART .. nPartIndex) while nPartId do -- eventuale calcolo dei solidi local bHasSolids = EgtGetInfo( nPartId, KEY_HAS_SOLIDS, 'b') or false if not bHasSolids then EgtSetInfo( nPartId, KEY_CALC_SOLIDS, true) CSOLIDS.Exec() end -- 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 < TYPE.OUTER_SHELL or nType > TYPE.AUX_SOLID then nType = nOldType end nOldType = nType -- scelta del colore if nType == TYPE.OUTER_SHELL or nType == TYPE.EXTRA_OUTER_SHELL then Color = EgtStdColor( 'TEAL') elseif nType == TYPE.INNER_SHELL or nType == TYPE.EXTRA_SHELL then Color = EgtStdColor( 'ORANGE') elseif nType == TYPE.INFILL then Color = EgtStdColor( 'YELLOW') elseif nType == TYPE.LINK then Color = EgtStdColor( 'GRAY') elseif nType == TYPE.COASTING then Color = EgtStdColor( 'BLUE') elseif nType == TYPE.WIPE then Color = EgtStdColor( 'LIME') elseif nType == TYPE.RIB then Color = EgtStdColor( 'OLIVE') elseif nType == TYPE.AUX_SOLID then Color = EgtStdColor( 'AQUA') 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 nViewId = EgtGetFirstNameInGroup( GDB_ID.ROOT, VIEWPARAMS) or GDB_ID.NULL local nOldPaletteType = EgtGetInfo( nViewId, 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( nViewId, KEY_PALETTE, nPaletteType) RunSlicePalette.UpdateColors( nPaletteType) end --------------------------------------------------------------------- return RunSlicePalette