本文分享一个用于 Cadence Virtuoso 的 Skill 脚本,能在 LSW(Layer Select Window)中按列表循环显示指定的一组 Layer。适用于版图中图层较多、手动切换耗时的场景,按一次热键就会切换到下一组并将其它图层隐藏,以便集中查看或编辑特定层组合,减少手工在 LSW 中反复勾选的时间。
演示

数据结构
全局变量 cycleLayerList 是一个顶层 list,每一项是一个“组”(二级 list),组内每个元素是一个 layer 描述(例如 list("METAL1" "drawing"))。
- 示例组
list(
list("METAL1" "drawing")
list("METAL1" "pin")
list("METAL1" "slot")
)
表示该组的 entry layer 为 ("METAL1","drawing"),同时要显示的其他 layer 为 ("METAL1","pin") 和 ("METAL1","slot")。
行为概述
每次触发主函数 cl_cycleEntryLayer() 时,从 cycleLayerList 中按索引取出当前组:
- 把该组第一个元素设为 entry layer(主要绘图层);
- 隐藏所有 layer;
- 将该组剩余元素设为可见;
- 更新索引(循环递增),下次触发进入下一组。
运行流程
- 初始化与索引管理:
- 函数读取保存在函数属性里的索引
get('cl_cycleEntryLayer 'index);若不存在则初始化为0。 - 通过
length(cycleLayerList)得到组数,用mod(currentIndex + 1 layerPairLen)计算下一次应使用的索引,实现循环。 - 用
putprop('cl_cycleEntryLayer currentIndex 'index)保存索引,保证多次调用在不同会话中也能连续循环。
- 函数读取保存在函数属性里的索引
- 选择并设置 Layer:
currentLayerPair = nth(currentIndex cycleLayerList):取出当前组(nth 在 Skill 中以 0 为起点)。drawingLayer = car(currentLayerPair):取出组内第一个元素,作为 entry layer。seriesLayer = cdr(currentLayerPair):取出组内剩余元素,作为要同时显示的 layer 列表。leSetEntryLayer(drawingLayer):设置 entry layer。leSetAllLayerVisible(nil):先隐藏所有 layer,保证只显示当前组所需的 layer。foreach(tmp seriesLayer ... leSetLayerVisible(tmp t)):遍历组内其余 layer,设置可见。- 在设置过程中脚本会
println(drawingLayer)与printf("%L\n" tmp)打印当前处理的 layer 到 CIW(Command Interpreter Window),方便调试与确认。
代码部分
cycleLayerList 设置
可以放在 .cdsinit 中,每次启动 icfb时自动load, 也可以写在其它 skill 文件中然后再手动 load
; Please define below in .cdsinit or others...
; Define global variable cycleLayerList containing all layer pairs to cycle through
defvar(cycleLayerList list(
list(
list("METAL1" "drawing")
list("METAL1" "pin")
list("METAL1" "slot")
)
list(
list("METAL2" "drawing")
list("METAL2" "pin")
list("METAL2" "slot")
)
list(
list("METAL3" "drawing")
list("METAL3" "pin")
list("METAL4" "slot")
)
list(
list("METAL4" "drawing")
list("METAL4" "pin")
)
list(
list("METAL5" "drawing")
list("METAL5" "pin")
)
list(
list("METAL6" "drawing")
list("METAL6" "pin")
)
))
主函数
下面是主函数 cl_cycleEntryLayer ,可以自行保存并load
; chiplayout_cycleEntryLayer.il
procedure(cl_cycleEntryLayer()
let((currentIndex currentLayerPair layerPairLen drawingLayer textLayer)
; Get current index from function property, initialize to 0 if not exists
currentIndex = get('cl_cycleEntryLayer 'index)
when(!currentIndex currentIndex = 0)
; Get the layer pair corresponding to current index
currentLayerPair = nth(currentIndex cycleLayerList)
; Extract drawing and TEXT layers
drawingLayer = car(currentLayerPair)
seriesLayer = cdr(currentLayerPair)
println(drawingLayer)
leSetEntryLayer(drawingLayer)
leSetAllLayerVisible(nil)
foreach(tmp seriesLayer
printf("%L\n" tmp)
leSetLayerVisible(tmp t)
)
; Get the length of cycleLayerList
layerPairLen = length(cycleLayerList)
; Calculate next index, reset to 0 if exceeds length (cycle)
currentIndex = mod(currentIndex + 1 layerPairLen)
; Save updated index to function property
putprop('cl_cycleEntryLayer currentIndex 'index)
)
)
快捷键
hiSetBindKey("Layout" "<key>\\" "cl_cycleEntryLayer()")
autoLoad
建议将主函数保存为 chiplayout_cycleEntryLayer.il
并放在 autoLoadAllUsefullSkill 能识别的目录(以前《启动icfb加载指定目录所有skill》讲过的)
- autoLoad新版
- chiplayout.net skill package 当前版图
v1.260103 - 通过网盘分享的文件: 链接: https://pan.baidu.com/s/18l-JENQVx1Xws7E75fzGrQ?pwd=c9es 提取码: c9es 复制这段内容后打开百度网盘手机App,操作更方便哦
- 博主
icfb启动加载结果
LOAD /root/chiplayout.net/skill/released/v1.260103//chiplayout.il
LOAD /root/chiplayout.net/skill/released/v1.260103//chiplayout_labelTravel.ile
LOAD /root/chiplayout.net/skill/released/v1.260103//chiplayout_cycleEntryLayer.il
=== All Skill scripts under </root/chiplayout.net/skill/released/v1.260103/> loaded. ===