TA的每日心情 | 奋斗 2025-7-7 15:38 |
---|
签到天数: 83 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。
+ w9 Y% n# O3 M* M8 y- s6 P9 a/ H$ H8 A. `: H4 W$ V: I
- ;###############################################################################
1 C; z3 @7 L, x/ i9 n- n - ; #
2 Y% F f: k# e6 O/ X) M/ Z- a; I - ; Command: cline2shape #
8 n# V$ ~2 o8 r; M1 V: x7 r" \ - ; Skill File: cline2shape.il #
3 [* r$ [3 H5 ]/ J# G - ; How To Execute: Command> cline2shape #
+ S% w) K/ A, @ - ; #
9 [6 l; R p% ^' e) o$ q - ; DISCLAIMER: #
* d4 k6 `* B* _7 g0 V% L9 O! T2 k - ; The user of this command assumes all responsibility and does not #
/ `" c) C( S& e5 j8 j/ E, S - ; hold Cadence Design Systems nor the author of this code for any #
+ K4 i: H. G: }) m6 x r - ; unwarranted results or problems due to the use of this code. ## L5 q1 P4 J) G7 g# A
- ; #
: I' C0 H2 C) {* v - ; This is non-supported code and the user may modify it as needed. #; e+ ]( b% c* B7 D
- ; #
% b& h4 o; A$ `0 s - ;###############################################################################! r" m* E& w6 b
) b5 A# u" D! x! T/ \ S; E$ h- ; demostrates
& {4 x0 M* N# S6 s0 D - ; 1) style for an interactive command# H% o) Q& [+ q: o8 _& q% |9 U
- ; 2) use of the database tranasction APIs# U, m& T. G# X4 ?2 t
- ; 3) two styles of undo/redo support/ Q# q7 M; }1 C+ T. @9 P
- ; Added undo support" X# Y4 D9 o* Q& o" c" a. M0 G
8 S+ W1 Y- M+ b- C# h: b- ; Know Bug: Sometimes the program will not convert all cline segments but it * w# x) l) a' s9 ~
- ; will DELETE all segments. Use at your OWN discretion!
* v0 s \- C" ?3 \ - ; Select Cancel or Undo before exiting the command to restore 6 U5 e8 V T$ D/ I E
- ; to original Clines.
6 J) b0 S1 k! M) E6 n f$ P* f6 n
: Y5 \6 O) O1 z- Z, D5 O# A* @- 8 I( F8 L, { {% T
- 8 {- h- [9 W& t& m; v
+ o7 o% U+ G8 x2 |4 M, l1 Y- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
4 Z5 V* E- i+ M3 J ^" \ @) M - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)5 {6 \+ q) ]$ R
- axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"* a- ~% L1 S) M4 P2 ?& l C8 _
- ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t) \! M+ W* M2 G$ o' D/ t/ k% B
0 L! y" W3 b% P1 U% o- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2 c* `: S# G Q2 C
- ; This shows undo where all of the conversions that this user does while: a9 l% S8 Z: X5 t
- ; in the command a undone as a single operation.6 W+ j6 H2 H! _# Q! h
- ; To convert an existing command to support undo this method is
9 b1 U" |6 Z0 S- _& ~ - ; typically easier.; v1 x J0 p6 ~. J8 U0 v! x' P
- - @5 f, V9 Y' z V
- procedure(LCB_cline_to_shape()
- G% ^, |6 m8 r8 [+ n* z( f - let( (lclines layer polydbid )
3 y# {" c8 ?, J' _( _ - % L. f) E# _$ ~, L
- LCB_Setup()
9 l/ C6 o% z Z - & [3 G/ {+ e; A- d, ~& y v$ Z4 x) w
- ; cannot have a global transaction if we want undo to roll back each operation
$ n6 L; n; Y. A9 {8 T8 {$ } - LCB_mark = axlDBTransactionStart()
# x# J1 A+ q. o' Q5 w/ j0 E; E
, ? R2 u1 [9 O$ c" U3 R- LCBnotDone = t- @. `6 d8 l5 y! U
- while( LCBnotDone
6 Z) c& B/ N( D8 @6 X# U1 p2 H - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))! u: w2 S6 g2 N
- 9 c0 t# Z% `; P5 @3 G0 I
- foreach( clinedbid lclines
& P" ^3 {$ F d4 z( ] - layer = clinedbid->layer
; N$ a! u; ]% I+ o$ @ - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
4 B( c$ w1 o1 `4 U6 X8 E - - K1 ~- [6 O1 r* o g; g/ o
- axlDeleteObject(clinedbid)
* _- d- G( P1 X" ?8 A& J, ~
% k8 U: y* K# L) S+ v) d- unless( axlDBCreateShape(car(polydbid) t layer) 2 ^( T- D% T% J5 ^
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
* D: L( `% M3 N7 {2 `4 R - )5 x: d3 q& h* q& R7 j
- when( cadr(polydbid)
4 L8 l5 p6 J, U - axlDBCreateShape(cadr(polydbid) t layer)
( p+ \6 T7 U7 Y- \1 H- g - )
) q5 @$ h2 h' a' X% [0 c9 d# N - ); x! w! B1 d% N5 ^
7 F( y( x8 n* s1 n9 ~, r u- ; marks are only required if undo is using rolling back all database changes
5 [, N8 g* E) g: _/ S- j - ; when command is active. When undoing each conversion this is not needed
+ t4 L2 F! Z, y5 Y3 A& c3 t3 p - ; nor is Oops functional.5 S9 r% a- u8 ]+ A/ D
- when(LCB_mark axlDBTransactionMark(LCB_mark))* c* `( r6 R) \% e$ `6 Z7 s
- )
2 x Q) N. y1 K/ @ ?# m - ;LCB_Done() ; just in case$ F# q4 g/ `' C. O! _
- ))) ~! ?- N: d, E a# X
- # f0 Q9 @- M* h0 X8 B. u& g P
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1 ~3 M: G: b3 }6 L% [
- ; This shows undo where each conversion is supported as seperate undo operation, ~# a' t0 v# y9 G# x8 ]% x
- ; in the command a undone as a single operation.
! s; m' w1 y. H2 e4 K1 B2 [* K0 \9 P - ; To convert an existing command to support undo this method is# w% ^3 _. |) A: J9 Z8 N( ~
- ; typically easier.5 H+ `5 [2 k! e: e$ J' r
- $ k+ D- u% W5 U) b% O
- procedure(LCB_cline_to_shape2()2 f D- n' i# T) O: j3 t/ f0 _4 v( D U# {
- let( (lclines layer polydbid doMark )
+ W* Z: E2 d- ]6 R& B5 n
$ [- ?+ C! y& P% w7 [/ a- LCB_Setup()
) l; {* c2 R0 {3 }- Y: h1 g9 _3 h
0 L% a; G0 O8 y! W2 D4 H. h: b R- ; cannot have a global transaction if we want undo to roll back each operation
2 K! [4 G* b, f7 l" l9 i4 X - " e% a% e0 P2 I$ B2 _$ X/ f
- LCBnotDone = t
. N/ f: f- Y* K9 M$ g$ n8 m - doMark = 'undoMark( n) V( |8 S" c5 N
- ! h9 i; s" c* u% y
- while(LCBnotDone
- {0 r! M0 o+ F* b9 h - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))3 q( Q: T/ B% n4 ^& N0 B" X
- ! S: C- U& t# O" e0 m
- ; need to do a start/commit for each operation if we want undo to 7 I$ v, r; H3 m+ t5 `/ b8 K
- ; rollback each change. This mostly disables Oops7 O# ?7 u1 v- _* S# L
- ; don't want to start a transaction unless we have work to do or it will# h Z7 @ V& P. L4 F. i# {
- ; do a unneeded undoMark. . R" r6 `+ a% ^ B# P% I- g
- when(lclines
- |; n0 @* ^" J. f3 \* z. u+ L - LCB_mark = axlDBTransactionStart(doMark)
4 m7 W9 a8 i: D5 L7 K( s - )
Y) x4 M( t+ U - ) z0 w8 }$ K/ S" s3 y* |
- foreach( clinedbid lclines
$ ?8 _" I9 { [2 l1 |6 _ - layer = clinedbid->layer
! ^ P/ }( |. f* o - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
- `. B# |' d" M/ U/ `7 Y - / `( P2 m6 w1 f9 v
- axlDeleteObject(clinedbid), c, Y0 l* F' ?- u3 {' C: u" G0 C
- # q! q% l5 Y, O: m. U& T" E8 @+ b
- unless( axlDBCreateShape(car(polydbid) t layer) 8 P, b# K" Y" {9 w" ^: C
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")* t# C" R( A6 q7 P8 T) G
- )6 `: l0 I9 _1 T" G' M
- when( cadr(polydbid)
5 u! m3 N4 ]3 A, u7 r9 Q - axlDBCreateShape(cadr(polydbid) t layer)
+ z) g8 E2 k4 \' X - )
- _7 l; g$ b% z6 L) K1 Q - )5 a, @0 n% o+ B& K
& o( o. r& z. z) k9 b" X: {; Z- ; marks are only required if undo is using rolling back all database changes
4 x* S- W! y6 ]; P( ~! { - ; when command is active. When undoing each conversion this is not needed7 b# g- T% m8 g b
- ; nor is Oops functional.( u& I' @3 }4 k6 _* O
- when(LCB_mark axlDBTransactionCommit(LCB_mark))
/ f1 x& l0 U1 A9 j9 V - LCB_mark = nil8 ^+ @' @5 g! Y* s
- )
' t+ J7 t s+ O/ {$ C9 Z! _ - LCB_Done() ; just in case( f r, {/ g; J- X+ I ?
- ))
3 b" m, r5 E2 P o: j! r5 e) f/ ^ - 4 e2 N& W& g2 N: i$ m, n
( N+ K4 p' D- ~7 l: X: a- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 Q( o* p' X8 d: F+ S6 T7 ]3 x - ;; support APIs
4 o1 ?1 ]2 {7 F0 _+ B - 0 \/ p- y3 g g b8 U& m
- procedure(LCB_Setup()
- L- A' O9 v" I, j' e0 H - let( (popup)% Q0 p/ O" p8 y9 N+ L! e) w
- axlSetFindFilter(?enabled list("noall" "clines")
S! }0 A* Y! X) ]+ f - ?onButtons list("noall" "clines"))
8 `. g4 g! T2 L6 v
$ ^( R7 u$ D9 n3 D- popup = axlUIPopupDefine( nil (list4 U3 r- j- N* N1 `' \8 r" @
- (list "Done" 'LCB_Done)% m9 t! X. A Y$ D* f; G
- (list "Oop" 'LCB_Oops)2 ~& Q: L6 i( ?2 j5 L$ `; s
- (list "Cancel" 'LCB_Cancel): e' C$ J+ b7 R3 t6 q& M
- ))
9 r6 @9 A4 y5 R" D; D9 ?4 x) {
3 P5 z7 n9 J$ g7 q( r! E5 h- ; Snapping is not required by this command but this shows the ability1 O& f# ^+ Z9 o7 z" {) K/ f
- ; to add the snap sub-menu to the Right Mouse Popup menu8 u% t3 x6 K; x7 I
- axlSnapEnableAtRMB()6 r% ^3 C8 s3 b* t: b" n/ P1 \
0 L+ |7 w7 m: H+ O- axlUIPopupSet(popup)
5 `, M" q2 @5 B! |* b; w - LCB_mark = nil
4 Q, Q$ G- I2 C - ))7 M( A1 Z( x, M ]
- W5 w' d1 w/ D" T
- procedure(LCB_Oops()7 b" n* G: b+ f
- when(LCB_mark
4 v5 y9 j6 L; s- Y - if(! axlDBTransactionOops(LCB_mark) then0 a) d7 M, o) `3 g
- axlUIWPrint(nil "-- Nothing Left To oops. --")- @; N- _6 m. Q5 D2 G- S/ s B
- else
( d7 e7 W* J4 @: U - axlUIWPrint(nil "-- Replacing Clines. --")
& E8 s$ x2 {9 }5 @3 x J - )- @+ S, A) W$ J8 \0 y: J
- ). e! ~2 r$ z, C! x2 F, ?+ a& \
- axlClearSelSet()! z# n" s& |) L, G2 u; l
- )
( [5 C+ L9 E; I9 w. I8 T! _8 H3 p
3 e7 |3 g; [( y! V" M# `- procedure(LCB_Cancel()
0 D+ n9 t# ^, g - axlUIWPrint(nil "** Cancelled Program. **")2 b# t; y8 P& T- w
- when( LCB_mark axlDBTransactionRollback(LCB_mark)), D8 Z! b" A2 B
- ;LCB_mark = nil/ H# o( ]) \. z: e. s E4 z# n
- LCBnotDone = nil8 m+ C$ H$ J* i- W/ k% |5 q
- axlClearSelSet()
; R2 K" H) | _( p4 C( i+ V( ? - axlCancelEnterFun()" {& R( a S3 E( u5 F( @3 P
- )4 B7 w4 m; q; f. z2 H: Z- {% }
- * k! V K# q4 ^
- 6 i1 M. ]4 p! S- @4 \* p
- procedure(LCB_Done()
* u( O6 W- F- ~3 H - when( LCB_mark axlDBTransactionCommit(LCB_mark))
# j* P9 K' R& v- y. b - ;LCB_mark = nil% s9 h5 D: ? _+ `; H" g6 c
- LCBnotDone = nil9 W' e* F' N' B
- axlFinishEnterFun()
" S' s& C' N& O+ t0 N - )" }$ f- {) b* T2 @' s
复制代码 |
|