TA的每日心情 | 奋斗 2025-4-27 15:26 |
---|
签到天数: 81 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。/ @8 f/ @4 a- ]4 R# n
; o1 r& P, } A6 P7 x- ;###############################################################################+ O* |1 R. J+ n1 c/ X" `( `" h
- ; #6 G: O T( j) Y. {+ S
- ; Command: cline2shape #
& {. `4 z: g& C6 T0 e1 Z+ S# L8 c - ; Skill File: cline2shape.il #
$ f7 v( a0 E% @" b* A, @ Z - ; How To Execute: Command> cline2shape #
- M; G6 V# n, P; P2 x1 e - ; #
( \3 _. j% \( Y" _ - ; DISCLAIMER: #
/ p3 A9 k. H& T) T, t& `3 J - ; The user of this command assumes all responsibility and does not #
* l, d, a% b7 {- ?* P! r! Y - ; hold Cadence Design Systems nor the author of this code for any #
1 W }% @* N X2 n4 I- g# v: ] - ; unwarranted results or problems due to the use of this code. #
2 \( ?, [- h' |1 }0 c0 \$ m - ; #
" F9 ^! G4 r( {+ ~* W - ; This is non-supported code and the user may modify it as needed. #: p3 a# {$ }; ]0 d6 s
- ; #. O1 x6 Z2 a7 ^3 k4 j) W U
- ;###############################################################################
) g2 ^; L/ m$ x" a/ W
- m; m {8 ~! f, C- ; demostrates. I" H2 \; G6 g: f/ Z& ^6 j: \
- ; 1) style for an interactive command& _5 k9 H- m/ H+ E# j$ E5 {
- ; 2) use of the database tranasction APIs
- @* g& _7 y2 [2 z9 a1 S! k2 k - ; 3) two styles of undo/redo support$ w4 k- k+ m) b8 t
- ; Added undo support: w3 q* o( Z6 h! ~4 R
) l* V b, P7 k0 N- ; Know Bug: Sometimes the program will not convert all cline segments but it
' `, B: r- ~1 T m6 b$ M4 | - ; will DELETE all segments. Use at your OWN discretion!' b' D. Y- G0 \6 q* @$ T9 ~1 ]( P
- ; Select Cancel or Undo before exiting the command to restore * V# w0 }) a8 r |
- ; to original Clines.1 o/ F( d, O5 S {. u6 i
+ T* _, N- n/ l* s* _2 J
" X, _% {$ N/ z& ?, _# b
; j' I" E4 H& ?& c0 T# c8 B
. n+ A. S p$ v, ^0 g- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
( R" N' P! Z8 X! g- N% r% u5 {8 S - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)
8 O- Y c+ `% I; \. n - axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"
% w8 R, B+ Z# c7 w, }: S" y - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)
. e0 o, E1 z4 k( m+ r) ^" w9 d
' i' U% P0 p5 A9 s2 d/ M- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
! }0 F8 E0 c5 r - ; This shows undo where all of the conversions that this user does while/ j% w' R1 ? J! T& w" z
- ; in the command a undone as a single operation.
' z+ x3 y0 a ]; \7 i* g# F - ; To convert an existing command to support undo this method is, ~& ?- _* i$ Q! O, W' T
- ; typically easier.
; S6 D: h/ |9 `4 t% L) L+ }* P - / P0 h3 r }1 n5 j) ]
- procedure(LCB_cline_to_shape()
9 r# i$ H3 Q! z- z/ w - let( (lclines layer polydbid )
4 g" U- h b5 }. A5 m( C% z - ) f' s& s& j( k: B1 b' m
- LCB_Setup()
$ c& g9 X& B( s0 c6 }
+ c& k# x9 K( X# t( Q# T- ; cannot have a global transaction if we want undo to roll back each operation0 y# Q3 `- m X; S3 c0 n! ~
- LCB_mark = axlDBTransactionStart()
7 D; d; e; N F5 t1 b/ a$ t - % ~' X3 ^ y/ t8 V
- LCBnotDone = t
) R$ U( @$ ]+ M" F* s2 T8 Q - while( LCBnotDone
( T# v5 P7 Z- n) q3 f5 G - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
' ~. @3 u$ ~/ P+ Q8 ]3 i: y - 9 L4 n4 Y' \% f5 M8 ^/ m* h8 Z
- foreach( clinedbid lclines
5 P5 G! u% U7 T# O8 i1 T - layer = clinedbid->layer
1 D9 Z3 P' ^) S. Q/ t - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
: Z: q! m( Q; t3 j- y
, d9 K$ x4 ^0 V0 W2 V- axlDeleteObject(clinedbid)
4 @, |7 K4 [* k
7 Y/ O0 o& A8 V. q- unless( axlDBCreateShape(car(polydbid) t layer)
+ N1 f6 g I; h - axlUIWPrint(nil "ERROR: Failed to create Shape from Cline."): K" B2 D3 S0 p8 \! h* | y- f
- )4 P2 U% w2 I* ?5 }: q- d0 h
- when( cadr(polydbid) 6 a9 j1 a- o4 L( O/ d' U* _
- axlDBCreateShape(cadr(polydbid) t layer)
" d! P2 e9 i1 U( S0 z$ K - ). s6 m! R9 `& g( \) w
- )
. o, X5 P" x9 A: @# L+ Y - % w" P8 p% _! T) f3 h. V
- ; marks are only required if undo is using rolling back all database changes
" f z! W5 A. q5 k- I - ; when command is active. When undoing each conversion this is not needed: N2 m0 x& e. A# _5 R2 z2 s
- ; nor is Oops functional.
% v) C: {+ E4 G4 B - when(LCB_mark axlDBTransactionMark(LCB_mark))+ ?: v4 `; P7 s: t
- )
* N& R) K+ j } F) h! k9 H e" t# Z - ;LCB_Done() ; just in case
, {( B5 e" i- Z$ m4 z - ))- E' s* ]! W# y9 E2 ]( w( u6 C# S
- 2 B% a) ^/ {9 }7 C8 j6 L
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 {4 ]. @/ w; w5 O( \- g' `: x - ; This shows undo where each conversion is supported as seperate undo operation3 Q! A7 H! K6 h# X0 p* [
- ; in the command a undone as a single operation.
7 F% {+ H- X& P e6 L2 W: C - ; To convert an existing command to support undo this method is( d7 Y* C0 _% P
- ; typically easier.
1 w6 M% \ S" t# `4 A; t3 Y- u8 m
4 K+ C/ I6 {7 D' n9 r, @$ Y6 @- procedure(LCB_cline_to_shape2()
8 h1 J/ G- \( j" N6 N - let( (lclines layer polydbid doMark )3 O$ ?- g/ q8 h# Y
- 3 c* `7 F1 ?' t. f. i
- LCB_Setup()
, G7 y* T" N2 _
1 I) Y# |5 K& p& r( n- ; cannot have a global transaction if we want undo to roll back each operation& s7 O( a. R- s
' a) e3 B6 X! r9 i- LCBnotDone = t
- L1 N6 O& M( w. U* ] - doMark = 'undoMark% P, p4 z4 O @1 s
- 7 H1 p% ?# v5 r! \. I+ K* Q
- while(LCBnotDone
" c) D1 x% m1 p r5 s - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))* Q# N- I! @! { w
" k1 G9 \0 X+ }9 i& N4 G, e" _4 X- ; need to do a start/commit for each operation if we want undo to
$ w% A% R" R2 m6 g. } - ; rollback each change. This mostly disables Oops
( V& S. G" H7 I8 ]& k% T - ; don't want to start a transaction unless we have work to do or it will9 O! E0 k, L' ~( ^, B
- ; do a unneeded undoMark.
- J* [1 g5 O% \8 C1 J& ]' o8 d: ^! A - when(lclines
2 S1 ~3 u5 ^% ^' E6 }6 [+ J" Y. ` f5 P - LCB_mark = axlDBTransactionStart(doMark)
) D4 y8 z( @$ |9 J5 m - )7 W% V1 Q! I; }" L
& y7 s9 \% u. Q- foreach( clinedbid lclines
& r" S$ B' F6 P7 x! G: L/ d - layer = clinedbid->layer
0 p. \# M8 N8 S4 k0 C - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
; ?; v8 b4 C% h, i: T - 6 P( X3 Z+ s! w4 C' S4 I
- axlDeleteObject(clinedbid)) k5 x k3 Q R
- 0 F1 F: { l# ]
- unless( axlDBCreateShape(car(polydbid) t layer) f( {' E5 T! k8 x4 N
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
- h4 R- [+ o0 v3 g6 R - )
3 t+ c2 X: ^" W3 V! H8 Z% \ - when( cadr(polydbid)
' l* W9 i: i2 B% x$ t; j9 r - axlDBCreateShape(cadr(polydbid) t layer)
1 X7 s# Y4 x6 n# Q9 n H! }% d. Q - )4 ~4 ?: D6 \$ o% S# B( L( B" p
- )
! v4 E, z* K% P! ~4 N+ _& G$ R+ {; A - |! ^2 ^: X5 l" d
- ; marks are only required if undo is using rolling back all database changes2 C; X) O$ v x/ L" N. V" [( l
- ; when command is active. When undoing each conversion this is not needed
) n" c% C. }% X1 T8 }/ I6 v s# K" ^ - ; nor is Oops functional.
) O3 I6 ^2 }. V/ m( J - when(LCB_mark axlDBTransactionCommit(LCB_mark))* u2 J& G8 W: h! h
- LCB_mark = nil4 a5 w, p+ |$ d
- )
* I! k' E+ a& f9 g1 T - LCB_Done() ; just in case5 r; c) _0 X) [+ h1 R2 O
- )), v1 K3 I; X. j. q- V
- 9 L7 X1 s: x( T' J
# J- z, P. F0 m- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;/ p, h! x" ~" k; {2 O) [% G; @
- ;; support APIs; _1 _2 w! G" d: ]! B
% `) R; y( W( M+ X0 Z- procedure(LCB_Setup()
6 y0 [' n- I% A1 h - let( (popup)
, q5 M$ N" r, s5 y3 I7 L - axlSetFindFilter(?enabled list("noall" "clines")
; M0 z/ @7 J: Q9 o& R# L0 a L - ?onButtons list("noall" "clines"))' y* R* u! e; [) W
- 2 w2 [/ X% Z& B2 j/ _" X) j" A! S
- popup = axlUIPopupDefine( nil (list7 T9 o0 ]3 X) J2 L& x
- (list "Done" 'LCB_Done)
! z/ h0 H/ z) p$ e. _6 y - (list "Oop" 'LCB_Oops)
9 `' o* r8 M8 Q! C# J - (list "Cancel" 'LCB_Cancel)
9 L1 [* z+ V0 \ - ))
" s- A6 L0 u3 w) n1 p) z
! L3 h/ ^! N1 U- ; Snapping is not required by this command but this shows the ability- D% s- A2 ?2 P. R, p& [ V1 j
- ; to add the snap sub-menu to the Right Mouse Popup menu2 i, @0 m0 L9 x1 B# u
- axlSnapEnableAtRMB()
( {4 |: g; L7 v1 f. P - % X3 m6 g* Q# [
- axlUIPopupSet(popup)
" K8 ~/ h$ R3 {8 y+ q - LCB_mark = nil$ w" O" h4 \- }" P
- ))
F8 T" y* ~0 b. B5 e& d n9 i - ' v9 v* |# g' M+ E6 ^' J2 L4 p
- procedure(LCB_Oops()
9 V9 V& ^5 X4 |2 t: w/ D# z% m - when(LCB_mark
% b' a; d3 t! d% W - if(! axlDBTransactionOops(LCB_mark) then+ K' Z2 H6 k9 H4 d8 m9 ~
- axlUIWPrint(nil "-- Nothing Left To oops. --")& n0 O0 P4 g+ W) z( m1 @# ^
- else. Z0 Y! |6 C. b0 A3 F. d
- axlUIWPrint(nil "-- Replacing Clines. --")
3 W( O& C' h! m6 \7 r - )
: m1 P) s) Y& R9 x" D - )
' @7 h) Q, X: N0 o" _+ r8 n - axlClearSelSet()! x& S% |; L o. F f$ s: R6 i$ y
- )% R) J' h. n, i; c# `8 Q) n' x3 g& Y
- ) |$ F& d- q. c
- procedure(LCB_Cancel()
* y! p6 _7 p4 m) k) F - axlUIWPrint(nil "** Cancelled Program. **")
1 g* U0 H1 c6 R0 s - when( LCB_mark axlDBTransactionRollback(LCB_mark))
% R% S" ?$ X: W( c F; K! s# r5 X - ;LCB_mark = nil9 @& U6 h" w; s- q3 g
- LCBnotDone = nil
5 Z6 z! P7 @# F( ^, J - axlClearSelSet()- j+ e( o- A3 i& |
- axlCancelEnterFun()
) d. Z% |) m9 T( M' e7 @ Q. l" I - ): C9 x( y k# l9 e& b
9 h, Q( I- q- [3 F( j! `% |9 r
) r3 }8 U9 I8 L1 ^. f+ [ v- procedure(LCB_Done()
+ n1 R0 ^2 B- ^/ i$ S$ B - when( LCB_mark axlDBTransactionCommit(LCB_mark))
3 g1 a" g2 Q6 a% ~4 l- ~ - ;LCB_mark = nil$ P: @) o; z) b( r
- LCBnotDone = nil! W M; u- K7 p6 J4 f5 H/ U
- axlFinishEnterFun()
9 j6 d& v% b' Y4 Q5 F% ~$ W/ }5 G9 o - )
- i, W5 L5 b m. e u* k. N
复制代码 |
|