TA的每日心情 | 慵懒 2025-6-26 15:13 |
---|
签到天数: 82 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。
7 j$ C8 y' E0 d
* ?2 U# W0 `- f8 e i- ;###############################################################################4 U4 d5 N" h/ V
- ; #
( l' D& k: S; l7 l1 M& A) [2 t- s - ; Command: cline2shape #
( S, E7 f! o$ \) g - ; Skill File: cline2shape.il #
% |% R* n6 k- h' N" c4 r - ; How To Execute: Command> cline2shape #
! {- v# C, E7 U& c! C V - ; #
% g" u+ c; l! W# p) D - ; DISCLAIMER: #
2 M' r; G) w6 {% w, n - ; The user of this command assumes all responsibility and does not #
/ W/ h, x% h8 E- J - ; hold Cadence Design Systems nor the author of this code for any #
. n+ E% Q9 y- V) V+ \& Y - ; unwarranted results or problems due to the use of this code. #
& k" r8 G \5 o9 d. H! D# j, C - ; #
( Y" b+ \' Z* Q4 g4 J/ H7 g - ; This is non-supported code and the user may modify it as needed. #5 u: T& K' C- `# Z9 P: n% v
- ; #
. h+ o8 k; c+ u4 Q7 x- i - ;###############################################################################
/ u" p# C, E( }) Y: P; Q
! `% Z, o- ?0 U- ; demostrates
# |, E2 ^. l1 b! u! a8 g - ; 1) style for an interactive command
' s# Y, i# s% F: Z9 a - ; 2) use of the database tranasction APIs$ a! E* ?& O9 r- Y& k' C
- ; 3) two styles of undo/redo support6 ]2 Z" M0 M E2 `
- ; Added undo support- y& [, {' F/ K
- 8 a1 X6 p7 C5 s8 W1 G$ P
- ; Know Bug: Sometimes the program will not convert all cline segments but it $ T* j' G6 I* N+ u+ z4 R" `5 e
- ; will DELETE all segments. Use at your OWN discretion!6 Q/ q( }+ P) {# ? H' E' J: ^
- ; Select Cancel or Undo before exiting the command to restore
# b! ]% A6 Q9 s$ W7 ] - ; to original Clines.
5 o. w! `$ v. J$ c) J& K0 ]) l$ `% n9 ] - 5 T- g. h, ]4 I5 f9 T
, r1 l+ K8 Q& t" q# h* |! \) o
0 W% n7 O' K% h% C0 ]- 8 X) ^: O1 o" l4 d
- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
! {9 X5 H3 @7 }9 x! s3 c. A# G9 P - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)5 W6 G$ ]9 d9 M/ w4 H
- axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"
" T3 n% c" W6 Z, W- Q - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t): C# L4 e! Q$ a6 ^
8 p8 v% c, H. }/ L- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- v9 v. X; e" u - ; This shows undo where all of the conversions that this user does while
% A: i% s8 `7 P" d( ] - ; in the command a undone as a single operation.
5 d4 j& R0 j" ~4 |& O - ; To convert an existing command to support undo this method is) p7 {# p, u; N; V
- ; typically easier.
1 x* \6 u% U) q6 s' t' x, W - ' h& _2 N6 y$ I; l* h4 j0 h" d w
- procedure(LCB_cline_to_shape()9 t3 C: l9 b1 \6 b$ W: J8 e
- let( (lclines layer polydbid )) t! \0 W0 Z) b) z! C, h# ^7 s
% R" t+ l& A+ A# k5 T- LCB_Setup()% P. z/ u4 k9 _, Q" ~; R, @
( h$ I8 ^9 y+ s- ; cannot have a global transaction if we want undo to roll back each operation
# z* b) Y" P3 W) K" N - LCB_mark = axlDBTransactionStart()
. d9 ~2 ^8 N7 ^+ \4 r4 Q' p* A
! f5 S3 u; K& h: d* t$ \- LCBnotDone = t
% g" p2 j7 ^3 r - while( LCBnotDone
8 m8 W( ?2 V4 h% G# g8 K" Z# ?, T+ t# J% W - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))# i2 Y5 d, U1 I# h, z0 I
2 i* N. T8 I. [8 [: h- foreach( clinedbid lclines5 F% ^& k0 |* Y: P% F8 P; r7 P
- layer = clinedbid->layer6 C' {6 z1 [' h' ?
- polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")$ g, O* n0 n. J8 G3 @
- ( j! T- J6 `' N) C
- axlDeleteObject(clinedbid)
& d) @! i* F- }9 b" \ - J; Y( g6 }- |( f2 Z
- unless( axlDBCreateShape(car(polydbid) t layer)
( q: G4 H5 f! l6 a; D4 S; G - axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
$ M+ p1 p# N P+ Z% E - )8 l* L- `3 _/ z" J( n
- when( cadr(polydbid) o' h# V* ~# ^3 `
- axlDBCreateShape(cadr(polydbid) t layer)
s, }& r9 X+ q0 R7 m: l3 ] - )
! p7 C5 V# B, a7 Q8 |# y# N* k - )
$ \9 Z3 ? e7 n - * x7 n8 q1 u. y) C
- ; marks are only required if undo is using rolling back all database changes- V7 }$ s7 B: Z
- ; when command is active. When undoing each conversion this is not needed
, n( g5 n3 l* @* @4 B0 Y6 n* d - ; nor is Oops functional.# z1 j8 j8 f9 I* r5 ]8 q+ @
- when(LCB_mark axlDBTransactionMark(LCB_mark))' `) H6 J/ b- F e3 C
- )- i j4 c0 g+ w m& Z
- ;LCB_Done() ; just in case
4 _ N7 c2 J, s8 k) i# S2 | - ))
8 q* `7 e# w" |4 o. H0 { - " z6 c; k# r" N O7 s' b
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4 z' J1 }& B3 j9 R0 m" |
- ; This shows undo where each conversion is supported as seperate undo operation
( b F( b5 o! y& g% S - ; in the command a undone as a single operation.. {6 j7 a8 a/ d; T+ w0 E/ e
- ; To convert an existing command to support undo this method is
6 G" N- S# h' j - ; typically easier.* Q9 e9 {4 ]+ _& k$ Q3 V' ~) H
* I$ \$ d4 C! }! N- procedure(LCB_cline_to_shape2()# B# n. P/ `0 C
- let( (lclines layer polydbid doMark )9 `5 k4 F9 _3 T* ]
- / l% V2 E- R$ v, O
- LCB_Setup()5 ]' H& e1 r5 ?' p
+ o2 q# R$ L1 }0 n5 y; S" E- ; cannot have a global transaction if we want undo to roll back each operation! ^, x5 I$ a) j+ f ~
- Q9 n* z' W# j- LCBnotDone = t# i' b, y8 ^3 @
- doMark = 'undoMark% R, F `; ?; K, F% ]9 p
3 [7 `4 P( c T' c4 u, g# A- while(LCBnotDone
% \5 \4 q% E/ @' a. g6 r& ^ - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
" Q0 F* l' d& p! n5 l, g - + a2 N% v: M! P6 l0 e
- ; need to do a start/commit for each operation if we want undo to
! c7 x# ~1 y. | b5 {' ~8 G# x+ Q - ; rollback each change. This mostly disables Oops
7 _( N; z; y' V$ X% d" {3 J - ; don't want to start a transaction unless we have work to do or it will; r9 p( q3 a& A: L3 }5 K3 }
- ; do a unneeded undoMark. % x) J9 y+ d; O1 V
- when(lclines $ j( _- n& b+ C4 T: {8 T: u
- LCB_mark = axlDBTransactionStart(doMark)
+ y6 u, n: R" Q C - )0 E+ U- O) c6 u' l& x8 u: V1 ]! x2 k
- 9 J* ^7 y8 _% Q7 I7 m- d
- foreach( clinedbid lclines8 m& i. b* l, b6 P4 m+ q0 t
- layer = clinedbid->layer
# r5 M. U, e) U( ` - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")3 W! `; B( A$ q8 Q4 e
; q4 g+ S$ z& F/ \- axlDeleteObject(clinedbid)
2 `# @! n' E1 e' a
# W2 ~/ C( _3 ?- unless( axlDBCreateShape(car(polydbid) t layer) " f1 W8 Q1 n$ X0 H4 r: v8 y
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline."): I4 s- f U4 h2 u9 i
- )3 l* S/ q' [& ^3 g f
- when( cadr(polydbid)
( T3 a+ E( r6 _7 `+ u - axlDBCreateShape(cadr(polydbid) t layer) - o; y. u& n( I& P% q) T
- )3 t o% J$ s5 I0 J0 d
- ), q F% w0 S9 ^4 I% A: S* h ^5 P
1 M2 d6 u3 s& z& l, X- ; marks are only required if undo is using rolling back all database changes
6 m {8 V# E/ u; T+ k - ; when command is active. When undoing each conversion this is not needed; S- G$ {: b9 F9 D
- ; nor is Oops functional.
% |) D+ z7 @. Z/ y9 { - when(LCB_mark axlDBTransactionCommit(LCB_mark))
8 a' r0 i+ K' n8 a& k - LCB_mark = nil
4 H. K9 J5 O8 o5 i% c; W3 J - )
% B, |! \4 G$ ~' P& ^' s - LCB_Done() ; just in case
3 n, W& A; W) ^' i - ))! r6 f# @# U& T+ g! k1 k
- $ q1 C' h& s4 A& ^, \1 T( [
- 4 ^& [1 N- J: ?, f9 B
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
& g; q* B7 ~, P) o0 u$ Q - ;; support APIs* z$ | s( |3 A4 H- U' R
, [* B1 s" G% k* ^* n# j5 X9 h- procedure(LCB_Setup()+ m* e: Y" |2 j. h( z
- let( (popup) W1 _* V9 s& @! o2 ~
- axlSetFindFilter(?enabled list("noall" "clines")
7 {- ?" Z; l3 i O - ?onButtons list("noall" "clines"))) O$ n! ]* D8 e. t
- 6 b& S% {( F1 l) o
- popup = axlUIPopupDefine( nil (list, [% N* u* p4 ~# A4 c7 } v1 h! h0 O
- (list "Done" 'LCB_Done)
2 i, T4 z3 `$ x5 o. p7 a2 e - (list "Oop" 'LCB_Oops)
5 l3 P3 {1 Q" W0 H! g. w - (list "Cancel" 'LCB_Cancel)0 C) k) h. V2 u1 @! w4 s; M& _
- ))
, a2 A/ ~. R, g9 I7 }. V5 j; d - 7 `. T- f7 `2 U- P' r: @( F7 p
- ; Snapping is not required by this command but this shows the ability
% H6 Y5 v" x+ n/ |+ U! L0 l0 w$ H- m - ; to add the snap sub-menu to the Right Mouse Popup menu0 r1 \5 Q2 a# `1 `0 o* v0 O
- axlSnapEnableAtRMB()9 W* z" P. n9 S- ?# h+ ]; O
8 f" A# [2 A& l4 i8 k& M4 T- axlUIPopupSet(popup)' {/ ?. ]$ h( W/ L
- LCB_mark = nil- s8 i% @. i8 G! W- Y* Y& \
- ))
* f- d6 g7 t* i. p& A( K& _
- b% N: U' v$ T- procedure(LCB_Oops()
" L! p3 }/ }, ^9 H2 G% X6 H4 y - when(LCB_mark
/ A+ G2 r; D( ?- H& E - if(! axlDBTransactionOops(LCB_mark) then
/ ~* C; Y3 ~2 B4 G5 c6 V - axlUIWPrint(nil "-- Nothing Left To oops. --")* H( ~* ^. T! s A; W9 @( }
- else% E& p, X7 o, F( ~+ w
- axlUIWPrint(nil "-- Replacing Clines. --")
" t3 N$ ?5 D; x9 Z; n - )
& g* M2 p. r; y - )
2 f, k& R: U5 w V0 Z6 [% V - axlClearSelSet()/ B" a. G2 y" |/ [9 N' |
- )1 Y) d# c8 X/ t* E( }1 f5 ?8 T; {
- 2 b) y v- D8 m# i/ A$ E
- procedure(LCB_Cancel()
. i! ^0 w1 Z, @- | - axlUIWPrint(nil "** Cancelled Program. **")0 U$ X" Y+ X* @ O4 W* m7 X
- when( LCB_mark axlDBTransactionRollback(LCB_mark))
& e1 P2 F6 `4 k) a - ;LCB_mark = nil
# m5 m$ ^; x+ M3 V- d - LCBnotDone = nil( q. A4 _& F* w. w
- axlClearSelSet()$ b) ~1 M/ t" }0 _/ e
- axlCancelEnterFun()
% y6 c" s* |, F# m- V - )3 g' H3 h& c z
- / H# |" F% l; G a9 i) m
+ C& E* ]! V+ o* k/ t- procedure(LCB_Done() u R4 i; V7 i: [ E
- when( LCB_mark axlDBTransactionCommit(LCB_mark)); G5 P! f2 P; l; I: j
- ;LCB_mark = nil
( T# n4 s% d1 q) C q8 u; ^, o/ X - LCBnotDone = nil
- d* j% c: t( p: Y7 M3 E - axlFinishEnterFun()) H+ R/ Q( k1 e" ]2 e% i
- )
7 j( s9 x3 z* y- x$ F. p0 T
复制代码 |
|