TA的每日心情 | 慵懒 2025-8-25 15:23 |
---|
签到天数: 85 天 [LV.6]常住居民II
|
切换层
: Q% L7 D, b& O' T
$ a8 O' J+ Z6 {; _, B- ;;v1.2 添加注释: E( }! q4 A8 x* y1 o# V- C. A+ e& A
- ;;v1.1 整理结构* U% v/ X4 C N+ @4 n2 W
- ;;v1.0 初稿
; P! }5 f0 h: u5 `! o7 v5 N' a - axlCmdRegister("nextlayer" 'dbNextLayer)
. }7 H8 c2 G# I f8 b - axlCmdRegister("lastlayer" 'dbLastLayer) M. V: n6 C- c; Y; H
- ;;---------------------------------------------------------
5 V* h$ b! ^; I! y" o* D - ;;change_layer.il
' C5 {! @1 V! p' L- C& N4 L - ;;指令:nextlayer 和 lastlayer0 q+ z# q4 _1 A( P
- ;;功能:从第一层开始,让所有的非地层轮流显示。0 b9 U; `" s0 n" |3 e! |
- ;;描述:v1.2% H/ g: ^7 g: `& |! u% s& P% h
- ;; 系统默认的+和-是用来轮循当前激活层(Active Class and Subclass),可以改成这个。
* `8 e7 V7 \& F# R! W - ;; 该命令不改变当前激活层,而是改变可见层。
3 Q+ I _% L. P1 S - ;; 15.2未测试/ z! R* ~/ H; ?' D
- ;;---------------------------------------------------------- l) F% a2 x. t( Y$ S7 J3 k
- 4 d& Y9 O+ A! v1 }5 D; f
- temp_curLayer = nil ;全局变量,
+ u2 ^+ N' r2 B( f* Q4 s - 6 w; V2 `" B! z0 V7 {
- procedure(dbNextLayer()
; R! S0 _: } k; }: [ - (let ()4 v$ \& u: }, J: ~# i
- _dbSetLayerVisible("Next")
# Q$ V5 m5 {& S5 V - ))
, u2 P& o D, T7 J8 S6 s - 3 ^7 ^3 o* Q/ x
- procedure(dbLastLayer()
2 x6 _: `6 q; y3 h6 y. ]% n- r - (let ()0 p% P( Q, Z8 g( \; H" f+ Y! m3 e) Y
- _dbSetLayerVisible("Last")% `* H1 {9 j: R( j: L4 d Y
- ))' f% m+ s# S+ p! q# @9 ^% S
- / B" W; h; L$ D' G6 Q8 d$ T* g& C
- ;;设置层显示' V/ \+ u9 R& a: D. }3 v
- procedure(_dbSetLayerVisible(direction)
8 f2 @5 `# N- ?, h& J9 ` - (let (item allLayers itemClass) y J2 ~: u1 `, a0 j
: ]1 \9 v N. [0 T5 s4 j7 l, r- foreach(item axlSubclasses("etch") ;获取etch class下的的所有subclass的字符串/ B8 q8 R G8 s$ r3 Y
- unless(index(item "GND") ;把字符串不含GND的层先收集起来
% d0 I3 Z" m* t5 z' k! D+ G - allLayers = cons(item allLayers) ;收集* l6 B7 \5 x$ f6 g- ]
- )% S& o. Y' m% J6 C/ ?. |& g5 d
- )
$ v& L) w6 M4 ] T U& V - allLayers = reverse(allLayers) ;因为cons是在list开头增加,所有颠倒一下
! e6 v* h' W5 f9 W" i* R; [4 C - 4 {( ?( p$ [) @
- when(allLayers
/ U: k7 Y! f0 Z: e r M - temp_curLayer = _dbSearchLayer(allLayers direction) ;获取下一个要显示的层2 Y- k( q* y! c5 o# j
- axlVisibleDesign(nil) ;关闭所有层显示8 N, z0 f& S2 x0 @) c7 G
- foreach(itemClass '("pin" "via class" "drc error class" "etch")
; o" ~- e6 X. P- }8 x- v - axlVisibleLayer(strcat(itemClass "/" temp_curLayer) t) ;打开这些层
6 N: }2 {" G) J/ p - )
8 c3 q# s5 A& x- N5 Z/ G - axlVisibleUpdate(nil) ;刷新层显示4 l, \" w6 K9 i# q4 R) |- S9 [
- ) W& d3 n1 M4 F& q( g. a
- ))
' P1 Z& W" H* b5 `, f# @
+ h# V1 K+ G$ G4 H- ;;寻找下一个要显示的层
5 v f: B4 L( r - procedure(_dbSearchLayer(allLayers direction)2 X$ Z0 O9 t! I
- (let (curIndex nextIndex)/ U7 A* z! [, P3 B* ] x4 y. h
-
' y& h; P8 d5 v& k - if(temp_curLayer then
- r& c0 b- k7 Q) z - curIndex = lindex(allLayers temp_curLayer) ;计算当前层在所有层中的序号% m- b% H% X' M3 W$ j
- if(direction == "Next" then ;如果是NEXT,序号就+11 \- ?4 D: c- G+ X- c
- nextIndex = curIndex + 1$ ]1 Z9 _- S0 G+ S3 I. g
- when(nextIndex > length(allLayers) ;当序号超出list的长度,自动恢复到list开头) q% j- Y; ]7 {6 f4 |! w
- nextIndex = 1$ `" f% q, K+ q5 |7 I
- )
7 s+ [! e) B! F% n4 X- b! _ - else! t- _) k) D$ X7 L
- nextIndex = curIndex - 1 ;如果是LAST,序号就-1
/ A- A. e& @8 N6 e; W# |5 A5 Q7 q - when(nextIndex < 1
5 K1 t9 z) o2 x9 a# B1 w. a: Y - nextIndex = length(allLayers) ;当序号小于1,自动恢复到list尾8 u% ?2 H$ u0 E1 R1 d( h
- ). p0 |8 T- z" `0 N. h1 ?
- )% R+ s2 y- u1 H; o8 p% r
- temp_curLayer = nthelem(nextIndex allLayers) ;根据序号,计算下一个层的层名
7 e F$ [% L5 n5 X5 H/ C - else
* J5 `+ A' {' j - temp_curLayer = car(allLayers) ;如果第一次运行,就显示第一层# i8 \! [/ d$ X8 H* V* P
- )8 y0 [8 v6 J/ r9 R0 k7 f8 o
- temp_curLayer ;运行的最后一行表示返回值。这一行写不写都行,if和else里面最后一行本来就返回temp_curLayer了。
( N1 ?; O7 z+ I& r - ))
1 a3 v" o/ E2 V" Y - , E+ ]+ ?% Q$ p/ q+ P
3 N+ w; s# I1 S9 x* I( q; m-
复制代码 |
|