TA的每日心情 | 奋斗 2025-9-24 15:41 |
|---|
签到天数: 86 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。
! V" Q% h1 `6 m C- q8 F2 k; k0 Z* E3 N' e8 u
- ;###############################################################################
/ Z# E2 k: b9 q - ; #" ~1 }" g5 Y( _% X: g& _
- ; Command: cline2shape #
+ {9 o* s8 s+ o! y3 q& ^ i2 a - ; Skill File: cline2shape.il #8 p) \; I9 N1 V9 N, H" Z7 r
- ; How To Execute: Command> cline2shape #" ^! l) U' c2 p% V1 d7 \0 B
- ; #0 z4 `2 k* U: D( d9 k' L" z
- ; DISCLAIMER: #3 P/ c0 E1 R: x# d1 w
- ; The user of this command assumes all responsibility and does not #
2 T9 q* H- Q; N/ Q - ; hold Cadence Design Systems nor the author of this code for any #
% k, F, E6 M; i - ; unwarranted results or problems due to the use of this code. #) B7 v' j" c; t. T8 i
- ; #" Z8 W3 n |2 o {
- ; This is non-supported code and the user may modify it as needed. #
# I. P/ C" \. V P- r) y% } - ; #+ Q. |1 f0 X8 h$ f; C
- ;###############################################################################: j2 D/ N3 I5 w1 ~
& e' @& U a! f7 q& `1 f: `* [- ; demostrates
6 Z* q/ A8 {7 T - ; 1) style for an interactive command
3 {" D* n: e3 w* }3 w! O; F; [1 P0 W - ; 2) use of the database tranasction APIs$ F' g1 s% D2 S( i' J- \
- ; 3) two styles of undo/redo support
! _: W5 o, z2 J - ; Added undo support9 n; B( {$ ^( o9 f/ ?( k
- % K% v$ l# L/ Q- V* l
- ; Know Bug: Sometimes the program will not convert all cline segments but it ) x: K: H; P7 G# r( Y T: U
- ; will DELETE all segments. Use at your OWN discretion!( @. O0 m4 X* j/ B
- ; Select Cancel or Undo before exiting the command to restore
6 V8 d% s8 \/ K, a9 }2 [ - ; to original Clines.
8 S- y% y9 `" k3 R( l! j( g
) Y* x1 U9 i7 E- {- 0 v1 p% a9 ^7 y+ D" a4 I
- & \+ I- c F- S( M
+ L0 f! F1 _: [' {( U/ F9 S# S9 r- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"- [" o# I# f/ J) A( J
- ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)- f9 C( V) M9 b5 n
- axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"; A e7 }' z r( Y4 {
- ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)
2 T$ Q" u- O2 `( z6 v7 c, b - " F( ~' e4 Q, B6 V3 @0 A
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 U; V5 R" l8 M/ v# w& k4 B - ; This shows undo where all of the conversions that this user does while, v, @& F: o& N) M9 l
- ; in the command a undone as a single operation.. G) M8 a7 m. k3 ?3 O! L
- ; To convert an existing command to support undo this method is
4 A( ?5 J: i, R# o - ; typically easier.- p( H5 E- j$ {$ f
/ J, W |5 S) p" s3 G0 v! P- procedure(LCB_cline_to_shape()
/ y1 F D9 |7 g8 i- X - let( (lclines layer polydbid )
- Z* K8 {) d# |! }- K - 0 K. A/ A4 ~$ E W
- LCB_Setup(); L9 k$ I) L* U0 w
6 Q: ~5 |" s6 d7 Z2 H$ r9 C, m- ; cannot have a global transaction if we want undo to roll back each operation- m) y: A8 j" y" `! K3 Z+ {$ r
- LCB_mark = axlDBTransactionStart()
8 |9 T, e0 N- A2 j6 k
. D! M9 _7 V# Y$ J7 M% ]% Y- LCBnotDone = t
6 D: d8 g' y$ }% {0 c4 R - while( LCBnotDone) L' [( I- j& w' G# b. g+ ]
- lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
" V; [ O2 s) K% F9 g8 v% } - # u( F/ J! n9 n+ K# w3 G& G- H
- foreach( clinedbid lclines# g9 X M% \* N7 b
- layer = clinedbid->layer. F+ Y# p. |/ R
- polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
6 V5 D7 u/ }9 G0 [6 ]! R - $ P" h; Y* i0 `+ T: M$ C
- axlDeleteObject(clinedbid), _ |4 h+ V; Q+ n* F3 j; {
/ E' l& v* Q, u, c- unless( axlDBCreateShape(car(polydbid) t layer)
# R0 O# R* g, t& r: w8 T5 }& } - axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
5 d6 O+ y: S/ D! \5 K- O6 G, N - ): p* w, Z6 b1 y. F2 b# @
- when( cadr(polydbid) 2 _9 s; o8 T% F- s
- axlDBCreateShape(cadr(polydbid) t layer)
9 \$ R. F/ x6 X; z* U - )
! s+ S- A3 Y* n, E+ I: ^/ x - )
: K! u( K& L( K - 4 t$ J; R8 k. ~ b L1 R
- ; marks are only required if undo is using rolling back all database changes
2 k* E6 Z, n) r4 p1 `8 }- A - ; when command is active. When undoing each conversion this is not needed3 V+ N/ Z) |" T& @
- ; nor is Oops functional.
) Z, O0 j! w& F8 [: | - when(LCB_mark axlDBTransactionMark(LCB_mark))
' [4 ]( z( B' f4 ^+ i - )( ~% z: o6 a! m7 a9 y' a+ S
- ;LCB_Done() ; just in case8 d3 U$ t0 v3 b1 M% v( l' q, a9 b7 J
- ))2 b( K1 b6 D. R) \, n6 y2 g7 v) O
- 7 Y; o. ^) ?' s5 L8 A9 V
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;$ b& v0 A9 K' W
- ; This shows undo where each conversion is supported as seperate undo operation
# D+ Y. e+ T9 d, M8 ]: @: ^ - ; in the command a undone as a single operation.
* J+ P7 R5 B' \ - ; To convert an existing command to support undo this method is& Q' D: C& h# W+ L; I8 j
- ; typically easier.$ J: Y7 M' N2 t. | _* U5 X+ I
& b0 F9 V: a3 {2 a9 P7 ~8 D* {0 g- procedure(LCB_cline_to_shape2()8 ?4 H" F* i; r! D1 t; Z ]+ v
- let( (lclines layer polydbid doMark )# u- H) b5 T; Q) W2 R) _* ~
- , W8 Y8 ^; k1 z1 u- {' q/ W
- LCB_Setup(). [* x- A1 f9 r" F8 Q
- 1 O3 H; Z) q% m$ e) q7 X
- ; cannot have a global transaction if we want undo to roll back each operation
1 d( q6 d7 C e" |. G3 h1 @ - ) ]3 F+ z1 [' D1 U9 A
- LCBnotDone = t
1 z) Q4 ^% u% z! L4 U8 Y0 m - doMark = 'undoMark) y: D' Q: r8 |5 y0 p
4 ~/ c( P J$ M* I) d- while(LCBnotDone
7 P: U# \+ {* @" c+ s0 M/ f; g; j - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))- V- L! ?7 G. A3 O( z
+ K- b+ B( f2 _0 L7 Z- ; need to do a start/commit for each operation if we want undo to . G& |3 ]7 y2 f, ?) a
- ; rollback each change. This mostly disables Oops; f) G# @* s) `7 J6 [9 h
- ; don't want to start a transaction unless we have work to do or it will
& z! |9 ?# T2 F - ; do a unneeded undoMark. - a+ j4 y" w1 W: G T- a* |
- when(lclines ' R& Z6 L2 T# o# |
- LCB_mark = axlDBTransactionStart(doMark)
& x C( W7 T h+ J( M$ d - ), u' y1 n6 l: Y! w
' E' c+ f+ a* U- foreach( clinedbid lclines5 n: Y h& K5 _5 P9 o' k4 f! e! F2 X% y/ T
- layer = clinedbid->layer
# u' s2 v, J/ U - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")2 t; c# I! w: b5 e% |. n1 d
- + C- P# [. A; Q
- axlDeleteObject(clinedbid): r" Z, Q9 S1 N; N3 O T
- R9 V! p4 i4 j H' B$ k0 H6 y
- unless( axlDBCreateShape(car(polydbid) t layer) 1 z* c9 k5 u) M1 `
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")6 }) } J3 y4 A% f
- )
1 C( V. O3 B9 _ h - when( cadr(polydbid)
! ?( {& \: k$ Z, w W - axlDBCreateShape(cadr(polydbid) t layer)
2 |- V4 e! E1 m9 v3 h4 w - )" J% u- @% L+ J, D: ~! n l; X/ ~
- )+ I( I- Y- K: t! ] C6 F( i8 w
$ `; Y; ^$ l1 l- ; marks are only required if undo is using rolling back all database changes5 p2 [; ?6 ?6 e1 f
- ; when command is active. When undoing each conversion this is not needed
' N" S( T! b6 p% Q) h - ; nor is Oops functional.
# p x* [% p$ U8 p/ m - when(LCB_mark axlDBTransactionCommit(LCB_mark))' Z3 [; h( G4 o1 j! ~1 Z. K) G+ {& h
- LCB_mark = nil
! B8 X% ]5 Y# `4 a0 [ - )
. y% J& t' i z3 g- b - LCB_Done() ; just in case
5 E+ Q& B; T' |% f/ y - )); k: m/ r" X) S- I5 v
3 n4 n# \9 T$ C: X% b
! i$ @7 b2 H' W' G- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;- T n( D; `# u
- ;; support APIs9 n/ q; \7 |0 Y% h6 e! k6 k
+ L' |; K2 s8 ~5 ~. J1 x& t8 `- procedure(LCB_Setup(). B1 Y' o* ]7 w9 E8 p5 B
- let( (popup)
* N7 k$ j j C) E' y8 _$ C - axlSetFindFilter(?enabled list("noall" "clines")
& V5 I# o* g1 M* u0 W/ X - ?onButtons list("noall" "clines"))
" s) F2 a6 x2 [3 K: S! h
) t9 m1 q+ ?3 _- popup = axlUIPopupDefine( nil (list4 i. x0 V3 z# j: v- U# \
- (list "Done" 'LCB_Done)0 ?) @1 r) X1 j! W
- (list "Oop" 'LCB_Oops)
6 I; x/ [* W$ g - (list "Cancel" 'LCB_Cancel)
# M) |- W0 v* ^9 Q - ))2 v3 m4 d8 s9 A7 x* X
+ R. c- O; x; M* \3 w- ; Snapping is not required by this command but this shows the ability4 M. k% J* O2 b- w) V
- ; to add the snap sub-menu to the Right Mouse Popup menu
0 ^. ?6 i+ j# ]7 {: B$ c - axlSnapEnableAtRMB(): r# `) l5 i& _ M/ D
- % U4 F: {" G2 e$ `* G+ O
- axlUIPopupSet(popup)
: _6 _7 j! r j6 c& a - LCB_mark = nil
6 h: q( z+ {; j+ j. |' M; l; H+ E - ))
- A1 [) s$ R3 W' f6 v( G) T- L
+ M9 \# J5 N5 l% r' S- s- procedure(LCB_Oops()0 n8 E: ~( b3 T! |
- when(LCB_mark
- n: ]5 V, e4 B; K+ t1 A - if(! axlDBTransactionOops(LCB_mark) then
. e$ J" a- h3 `5 v _+ g - axlUIWPrint(nil "-- Nothing Left To oops. --"): z5 U: Q/ G0 X
- else# ` E- M" w( W
- axlUIWPrint(nil "-- Replacing Clines. --")3 n1 p2 h8 z9 i8 P
- )
T+ N. U' e( `* h! K - )/ `# e% W" a- V& g! K, k" N' O
- axlClearSelSet()
! R6 s' d3 f. h - )
) V0 {( M1 F2 M
) k+ s2 G; Z% H- procedure(LCB_Cancel()
4 p3 W8 T% F( {9 J, O: F - axlUIWPrint(nil "** Cancelled Program. **")) _4 u2 `" n8 c6 E, U# M% ^9 X
- when( LCB_mark axlDBTransactionRollback(LCB_mark))( Q0 r7 w; V, Q/ A* ?! T- W# Q9 A! ?
- ;LCB_mark = nil
3 L' P( z1 @% O( M% h" j - LCBnotDone = nil) Y F7 L& y. U5 |" p' f" D9 t( v
- axlClearSelSet()
! R* ^- ~, Q! \# d! q( C3 d" ? - axlCancelEnterFun()
7 b. V8 p" v( b& F, d - )2 e( h6 D& O' k( i0 N
- ) ]' N# ?% K5 J0 t8 m
- 1 t7 C" P* D, T- P) X' S
- procedure(LCB_Done()
; U; w$ X! w6 \1 `3 Z5 ~ - when( LCB_mark axlDBTransactionCommit(LCB_mark)). p G) I: H: \' e' C+ n. r6 ~9 }0 o
- ;LCB_mark = nil
* p' W3 w) f: T7 c, j - LCBnotDone = nil
4 A6 V$ U5 ~" ?. y" O - axlFinishEnterFun()# w1 ~9 ^+ Y6 B# I4 ]: x
- ), y( \9 r: ?. i" j( C
复制代码 |
|