TA的每日心情 | 奋斗 2025-9-24 15:41 |
|---|
签到天数: 86 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。6 Q0 _ W% Z9 \" X D& ?& A; r9 S
1 e; |% U/ J0 q" S" e# S6 `
- ;###############################################################################* ~( V/ n \' Y
- ; #
& ]7 d" E/ J0 b9 T `! C - ; Command: cline2shape #; }/ o0 v' _! s
- ; Skill File: cline2shape.il #. W, }3 N; ^4 n# v2 z, y' A
- ; How To Execute: Command> cline2shape #/ t) v" g, w& J+ j
- ; ## }# \. m! L. v0 C, e8 I0 I% z3 r% }' A
- ; DISCLAIMER: #
- z+ n. F; y/ D2 p3 s0 K3 w - ; The user of this command assumes all responsibility and does not #
M9 e% z0 P2 k% _! ~ - ; hold Cadence Design Systems nor the author of this code for any #! n2 y' i9 s6 X" t; {
- ; unwarranted results or problems due to the use of this code. #+ A$ Y1 b5 \$ P1 P0 Q- N
- ; #2 m( W# M2 H& ]1 _
- ; This is non-supported code and the user may modify it as needed. #) e: m. i: k% d" \
- ; #' W+ ~. s; U5 a6 f/ \% m9 T
- ;###############################################################################) f, ~9 x4 L' _, ?) d
- * [8 ^, T- e& p$ V6 j6 O
- ; demostrates9 V4 @/ n( Y3 H) e ] Y# ]
- ; 1) style for an interactive command
" m9 Y* G; U# x7 k5 I - ; 2) use of the database tranasction APIs2 E/ O8 T* T% L9 S
- ; 3) two styles of undo/redo support9 s8 p i1 }2 b; N2 L# G4 I
- ; Added undo support5 s; S' V* k' D$ |% l. l
' m/ F3 g1 }. U0 }- ; Know Bug: Sometimes the program will not convert all cline segments but it 2 w9 K% J/ Q \! x
- ; will DELETE all segments. Use at your OWN discretion!
: Y5 s6 t4 r8 K/ z. ?3 B! M - ; Select Cancel or Undo before exiting the command to restore
+ N2 P7 r f7 d% v' \ - ; to original Clines.
0 U8 |. N6 X* Z3 L - L ]2 j) C, d* N) B
- % r: Q1 c2 V ^' P. {
- $ W5 c+ v; m5 C2 D
) z8 \, n, u) { K- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
) l$ g5 r; w5 x# [/ ` - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t) U7 z! F; F* f! m' w: D; w. d
- axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"
5 _; D: e* {4 e4 N - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)5 D* z0 R8 U# h6 [. I
- 4 M# e' @6 [/ ^ a, Z
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 Y7 h5 p: i; I2 ]6 z, q - ; This shows undo where all of the conversions that this user does while: P; Q) N; d9 F0 N
- ; in the command a undone as a single operation.
: I, m* n5 C' D9 H - ; To convert an existing command to support undo this method is7 Z) J0 R* {" ]% G0 C
- ; typically easier.
O+ p. Y$ R5 K- E6 H) e' R, v
H2 a& O7 a. Z, V" R o- procedure(LCB_cline_to_shape()
- w* l5 K1 o. p2 i1 b+ b, h$ E - let( (lclines layer polydbid )
5 M& R4 ^% G1 h5 v! [7 _ - 1 h; J! G7 D; G: {: k
- LCB_Setup()
, I) L) K E$ D( s0 F
0 [: Q: C7 [, z: C E5 E& Z' \- ; cannot have a global transaction if we want undo to roll back each operation6 O* a$ a4 h# E! V; d
- LCB_mark = axlDBTransactionStart()! N5 R& m ]2 {$ y
- ) b3 W4 s" U! {
- LCBnotDone = t! ]. q5 [0 _: h& S7 k! K
- while( LCBnotDone& c x- q( I) [
- lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))- p4 ?9 p& ~& e
- ) V4 [( c' i I. c
- foreach( clinedbid lclines5 j* _2 {5 j4 }' r$ X/ i; M# F7 M
- layer = clinedbid->layer
" x! I3 M$ p5 _4 V - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
+ F& v( |8 R! b# ?% K, n9 F9 K8 e7 r - 2 L- Q# J! \# N3 h1 ]6 S
- axlDeleteObject(clinedbid)3 g( I9 X9 B8 h9 A1 l" ? j3 |
% s5 B9 U3 m, M" U* t0 D- unless( axlDBCreateShape(car(polydbid) t layer) 9 O7 B& n# J' x# f
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline."): D& f# d, O* k5 T( L
- )8 V# z( s9 b/ K+ b
- when( cadr(polydbid) . B* O9 g7 y; n/ {3 F2 Z" h
- axlDBCreateShape(cadr(polydbid) t layer) $ ^, H: Q4 X3 r* a: ^8 g8 \) P4 a1 e+ p
- ), q! W( H! y0 S& {
- )& R0 x4 ~# A. H! I. j4 \0 p& Z! h
- # k2 C! m) c* |% D4 q0 m4 K |! ~
- ; marks are only required if undo is using rolling back all database changes
( @% B7 t% Q; Y( R - ; when command is active. When undoing each conversion this is not needed
% W- O: ?" B9 C* k2 D5 w/ ~1 u - ; nor is Oops functional.9 f% U7 U6 ?- h: E9 M! {
- when(LCB_mark axlDBTransactionMark(LCB_mark))1 z+ e, a' ]0 A7 i
- )% ~. u7 x/ a3 f0 {2 u
- ;LCB_Done() ; just in case' D# _( V+ o: L) `
- ))( R) B% b# Q; H$ n' ]% K
- t) p) b. o9 b/ N
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
: [/ `$ K( `" ?( a! ~ - ; This shows undo where each conversion is supported as seperate undo operation! i# p/ t. U2 F: x
- ; in the command a undone as a single operation.
* o: T8 {2 f9 a7 l+ y# J- F, w: ? - ; To convert an existing command to support undo this method is2 Y5 y7 f( h" b3 S; c
- ; typically easier.( {. w6 y/ l3 l/ o& M- s* F
- + t9 l+ n' A4 p7 c S' g9 R+ o
- procedure(LCB_cline_to_shape2()' w" B2 C& d. a1 W5 f
- let( (lclines layer polydbid doMark )
" n y' j. S. v8 R! e& o, E, L - # ]+ q! `$ Z- ]! W3 K, a
- LCB_Setup()
# r. F. X4 {5 d. ^% T* f- i6 K
/ y, i/ I/ r3 r- ; cannot have a global transaction if we want undo to roll back each operation
3 i4 L |7 k' r. B2 H- a. O - 2 f: D. M6 Z$ E. H. V" V
- LCBnotDone = t
5 Y% B' b1 n! Z! `2 E. B, y y - doMark = 'undoMark. ?, y0 i$ @& |0 W! d
- 1 M6 P% x7 w. I5 w
- while(LCBnotDone& _, [0 k7 {) i. m
- lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))3 W1 d+ {+ `& @! i
6 O8 h" v* M: y( }& W6 L. F- ; need to do a start/commit for each operation if we want undo to : a! \" {* O. @% o9 t
- ; rollback each change. This mostly disables Oops
6 @: e4 f3 @9 I3 d) U1 [- _# k# ~ - ; don't want to start a transaction unless we have work to do or it will
% R3 L; i9 H5 ^ - ; do a unneeded undoMark. - m1 v9 @% g" K M3 k
- when(lclines : N, C# E5 ^3 \5 }5 o! Q. E
- LCB_mark = axlDBTransactionStart(doMark)
, s% F& b$ b9 a5 ~3 o - )
4 x" _4 o2 j) S% v - 0 {+ M& X8 |; O4 {" s' x
- foreach( clinedbid lclines- [6 p' v; n* N1 @( e8 c
- layer = clinedbid->layer
! X8 F" }0 ], g; ~% T3 S. S - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
3 _! t# s, }* ^5 ^) z! O( v
: Y# [5 P. U" t- axlDeleteObject(clinedbid)
4 p5 J* T1 J3 `7 O' U; z& G Q! e - 0 i f# r1 t: E/ f) z
- unless( axlDBCreateShape(car(polydbid) t layer) 2 Y, \- Y9 c! l# ~0 P5 S
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline."): E' }* y' c6 [+ u
- )
' E; @* n$ W/ n# C - when( cadr(polydbid) - E: ]* ~6 A5 f Q$ X- \5 t. l
- axlDBCreateShape(cadr(polydbid) t layer)
2 }' W% b9 ^, i: U8 M2 S - )- h/ I2 A) h% ]% y- D& \9 P
- ) Y& i, K' v# s+ k" R& Y
- % C0 X. j4 L; B& X+ q$ q$ s
- ; marks are only required if undo is using rolling back all database changes. ^: T% ? o& b
- ; when command is active. When undoing each conversion this is not needed. u3 N+ z$ h& W7 J# P( l) ~! g' M1 s
- ; nor is Oops functional./ A% w6 |3 K, s1 q, S- W& p6 o
- when(LCB_mark axlDBTransactionCommit(LCB_mark))
* z8 [% I. z/ |" Y7 F' i2 o2 | - LCB_mark = nil, K6 j0 b; w3 M+ ]
- )
" c0 }9 ^4 A, }" f1 F; A9 k - LCB_Done() ; just in case. w* k. `2 p- p( H1 G3 @2 d
- ))
4 a. F. L2 R4 ]" {+ z0 ^
6 D# m7 E- p. a w% A- W8 ~4 {
6 Y$ {% \5 p8 h5 o: V- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;" e' d) l. Y: V v
- ;; support APIs5 s0 I( e( {* ^- B
- - R: b/ |$ v/ l6 m* d; p$ O+ y! }& e
- procedure(LCB_Setup()
1 @$ _- s+ k, @6 ^2 ?" x6 Y0 M: V; D - let( (popup)
" `: f, d" v4 f - axlSetFindFilter(?enabled list("noall" "clines")
]' `' M0 O+ O - ?onButtons list("noall" "clines")) E- x2 w; S( b# I# N2 w
- . A: O7 _+ ?# ?6 v, L) ]" s3 ]
- popup = axlUIPopupDefine( nil (list
& R7 f! v4 j1 c. F! ^ - (list "Done" 'LCB_Done)
0 b( f# j1 V9 G7 m5 S8 ?9 G - (list "Oop" 'LCB_Oops)& B' J$ O% ^1 [. n/ C6 D: d
- (list "Cancel" 'LCB_Cancel)- s% |; w( ~8 i e
- ))* R5 _8 L" L8 I4 x, Z# g" q5 }
- - ]3 @7 {" f% t; y i
- ; Snapping is not required by this command but this shows the ability5 ?. z4 R$ V& U9 g* l
- ; to add the snap sub-menu to the Right Mouse Popup menu
8 Y. s( L" O" {' e' D. ]1 b - axlSnapEnableAtRMB()
( ?. W1 q, @2 k& n0 d3 J - 2 z% o8 B' \& W* o+ F
- axlUIPopupSet(popup)
4 }0 O e# x8 n; c - LCB_mark = nil
* l5 k5 O7 b& o# }* N$ r7 N. w# U - )) I2 o$ n) W8 B4 G! l! p
- 1 D1 |) n* p+ K
- procedure(LCB_Oops()
9 _7 |% K; C0 q. Q* K; @/ E1 L$ D - when(LCB_mark
' }0 ^: f& n/ |7 j - if(! axlDBTransactionOops(LCB_mark) then0 u& C7 `' e! e- u; J
- axlUIWPrint(nil "-- Nothing Left To oops. --")
3 n7 g2 E: L+ c6 o+ ?- l - else0 t) R4 e. W/ o. e3 _
- axlUIWPrint(nil "-- Replacing Clines. --") y; q) f) L: {+ e5 i a2 D& V
- )6 }7 [# S; L- o+ S* i
- )2 ?! F) L# T5 |+ I0 ^" j& z
- axlClearSelSet() d( \# E' A! M/ v: x2 ~' A$ j! n
- )" ?. C% q4 X [1 s# d. N% H
- ) h& N1 S+ H! q; y) ]( T% @4 G" u* l$ f
- procedure(LCB_Cancel()2 {( a- }( c' `; p) z7 @6 U* Z+ }
- axlUIWPrint(nil "** Cancelled Program. **") q+ r4 _1 _( a" b8 [4 t- s8 Z* f
- when( LCB_mark axlDBTransactionRollback(LCB_mark))( t& K& y0 r6 e* B
- ;LCB_mark = nil" Y% p( ]: Y4 S3 k6 B( u
- LCBnotDone = nil
) p, j- q2 F6 b3 s. y - axlClearSelSet()5 Y" h& I: n3 ~; q' e$ t5 k
- axlCancelEnterFun()
$ M" f7 b' Q* i" V: ] - )! X+ x! {& K5 S% D, a1 z( s
- 4 s, z) a% [" U; z) v
- " S6 _* X; v& N8 X
- procedure(LCB_Done(); b. A% t- L, O `& \/ W% t: @2 L
- when( LCB_mark axlDBTransactionCommit(LCB_mark)), u- `' [' i3 i$ F+ x
- ;LCB_mark = nil
9 ?4 z- V& R% r& v - LCBnotDone = nil
- O+ [7 T& u0 G+ [: h: z% w - axlFinishEnterFun()0 N* H& R M1 ^: i2 [1 d
- )) x6 E0 p) n. L; c) {7 e7 G
复制代码 |
|