TA的每日心情 | 奋斗 2025-9-24 15:41 |
---|
签到天数: 86 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。; B3 y+ j' h1 A
5 z4 E. _ @; T3 E* m# F- ;###############################################################################; ^3 e; P7 k; d
- ; #$ S% S w8 l: O) j9 @
- ; Command: cline2shape #7 {/ k, G% c8 C
- ; Skill File: cline2shape.il #
" s- ^* p, c% c/ P8 j) X - ; How To Execute: Command> cline2shape #
5 \/ X9 l1 I* z# z( Z# G4 _ - ; #! z# c7 z% @4 g2 r2 i- V. c
- ; DISCLAIMER: #- E" U5 y0 B4 F# f
- ; The user of this command assumes all responsibility and does not #
* e; y' y; l' |+ B% |: C5 M - ; hold Cadence Design Systems nor the author of this code for any #
; K c3 J7 z9 g9 r+ }7 o - ; unwarranted results or problems due to the use of this code. #
' K! `5 T7 ~1 N' `2 ~! J7 s1 r4 A - ; #8 q/ Q3 ?5 R. P1 ~3 X6 q) }
- ; This is non-supported code and the user may modify it as needed. #. B- K5 ]5 p0 o/ }
- ; # q" t0 P7 I9 |
- ;###############################################################################2 F3 ^" ^0 v( ]) N' n8 P
9 m9 Z8 f6 u9 \: H- c- ; demostrates. ?# W# V) g* j$ D9 r
- ; 1) style for an interactive command
' Y- K7 v1 l$ I4 T- X' d - ; 2) use of the database tranasction APIs/ i9 q. |( O0 y& \
- ; 3) two styles of undo/redo support4 {, m4 U0 s6 l, k- X" O8 P$ C4 `+ C' p! y
- ; Added undo support9 s8 ?6 t: ~5 J' Q
: X- M, t3 ^- a- ; Know Bug: Sometimes the program will not convert all cline segments but it
$ R8 [6 U) {* T. P& } - ; will DELETE all segments. Use at your OWN discretion!
5 i7 k5 C: _8 X) R - ; Select Cancel or Undo before exiting the command to restore % k4 L& Y3 e4 d( x, k+ S7 Z& x
- ; to original Clines.
; u" B8 G2 z- @( @
! C' V" S% D4 f' U, Y- 9 B( z) @/ c" d' M; d4 {6 E' q
9 E6 r" u! b. Q( s0 V. h- o- 1 z7 Z3 K! s3 L& }1 F8 W, w; ~
- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"
6 {0 y t# |5 F- X2 \ - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)8 H# R$ ^* ?4 ?6 J) i( C
- axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"$ ]# C! R* e; T+ L7 c' E- R$ V
- ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)# K8 _3 Z4 }3 l; m& K
3 s% V/ P2 Q3 c: f- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$ O s$ O5 J7 S - ; This shows undo where all of the conversions that this user does while
* a6 Q/ ^* [7 y1 e. V* ~# h - ; in the command a undone as a single operation.
9 E. m0 x _1 H! f) U8 s* F/ T - ; To convert an existing command to support undo this method is- }+ b2 Q1 _$ b! R+ [* J' [
- ; typically easier.9 W- n) G5 I. w2 u
- 0 B0 P! a W$ T3 V ]0 n1 U% N+ d, R
- procedure(LCB_cline_to_shape(); w) |. H5 W- `3 g0 h
- let( (lclines layer polydbid )( C( `5 d. Q8 `+ j8 I2 n
- z( D* w. T& |9 d9 _. ^* d3 k- LCB_Setup()
0 ?9 C2 n l0 L% |" B/ ` M
1 v7 M" u, A8 k& @- `1 p B- ; cannot have a global transaction if we want undo to roll back each operation7 ~: u7 d: i4 ^" j% o
- LCB_mark = axlDBTransactionStart()
; i6 |- m. u# q, E/ T6 g) v( |, [3 } - % L$ E; D, g+ l' m7 A- a1 t6 P" u
- LCBnotDone = t
- N2 \( P, `8 g& r- ? - while( LCBnotDone
. ?# Z/ D$ p! C - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
1 E' ^% B) {0 \ i - ' \! ~2 R3 `% J2 B' v3 y5 H
- foreach( clinedbid lclines6 E/ L* r4 s; N2 M3 F3 X
- layer = clinedbid->layer
# Z4 D0 e; ]2 N9 \" a% O& V/ m - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")5 L4 V# r- K0 J3 @
+ R: t; M/ v& r! z$ y- axlDeleteObject(clinedbid); q6 T6 O2 x5 Z. {' @% a# O& s, `9 c
& z: v1 |& C4 C( @& Q- unless( axlDBCreateShape(car(polydbid) t layer) % n5 U9 l6 g9 n
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")$ u, b% U; L7 A$ Z* ]. u- U
- )
% v2 |! r! M- E8 o, E - when( cadr(polydbid)
/ f) ^$ i7 x4 j2 N \ - axlDBCreateShape(cadr(polydbid) t layer)
" e/ I8 k. H; d' q+ ~8 F% N - )
1 g9 A. H: a8 [( x K: L - )' I5 r4 `" S) ~1 _2 Z
- & R8 C- G; v* R0 }; p! ^
- ; marks are only required if undo is using rolling back all database changes7 H1 |! ]. T: b. ]0 h5 S% a9 j
- ; when command is active. When undoing each conversion this is not needed L4 C/ y2 ]- m2 |, A/ b1 v
- ; nor is Oops functional.
* K0 t* h; p( ]2 d' T - when(LCB_mark axlDBTransactionMark(LCB_mark))) r& t5 K. }3 |/ z$ q" W) }: p5 t, t
- )
. N: x2 a) S& {" T - ;LCB_Done() ; just in case
/ x/ t* a. y/ U, @% m; L - ))
) i: u; _) E- c: B) P/ m& E% `
4 U' h: [1 \5 A( d. b: J- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 X w' w5 o& r/ P2 q - ; This shows undo where each conversion is supported as seperate undo operation. O0 I/ F' ?) s Y& x
- ; in the command a undone as a single operation.
) D E/ h& L& m ]/ ^ - ; To convert an existing command to support undo this method is
6 E; @) ^8 j5 s- i - ; typically easier.- P2 k* G. @& c2 L- C
- - R5 p( U6 X( K2 ?0 ], g) Z
- procedure(LCB_cline_to_shape2()
6 ^4 w; W/ f! ? - let( (lclines layer polydbid doMark )' t. X& x$ L, |7 z
, a5 ^& I, N' @( H: z$ i5 Z. W0 v5 ]- LCB_Setup()
5 U: H! ^8 H. T& G
9 u/ |/ D" @1 O+ s- ; cannot have a global transaction if we want undo to roll back each operation) D# a" |7 j- v/ e" K6 K7 Q: V
0 e0 z3 e3 x% s& D* b- LCBnotDone = t7 r0 w/ U9 t) |# i
- doMark = 'undoMark# I' J& L+ p' ?. s1 z6 i
- : Q+ {/ n! ]2 X: ]3 i9 g
- while(LCBnotDone
- ^# V8 o0 ?5 R) @5 e - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))
8 P7 j, }3 T1 i: U0 U: v - 4 {* X) v. k+ g# `+ _
- ; need to do a start/commit for each operation if we want undo to * U" s( a9 f5 @" G: N) F2 K
- ; rollback each change. This mostly disables Oops
9 _$ O. H" N# U# w* o$ u4 w6 D8 Q, f" C - ; don't want to start a transaction unless we have work to do or it will
- i4 l# d% `- l% B% C- X - ; do a unneeded undoMark.
9 F9 ?: h2 U' G/ u: O* y1 X - when(lclines 3 q, W6 W6 F8 ~. Q
- LCB_mark = axlDBTransactionStart(doMark); H, P4 w+ s9 f" g$ N7 w
- )
; }# l9 q0 u) D - # H* Y( y; ?6 u r& n! M7 S1 i
- foreach( clinedbid lclines0 G5 d( J4 o6 q0 Y, u. a
- layer = clinedbid->layer
- A! @ A" [5 Y* c f. d - polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
. o' R/ F% c$ R# f4 U% _ - . [3 W1 R! E9 V9 y/ Q% D
- axlDeleteObject(clinedbid)
( D: ~5 `) v& z/ F$ D- Z+ Q$ ^% t - ( C6 a0 }& K# Y1 L
- unless( axlDBCreateShape(car(polydbid) t layer) , W9 S2 K" o- a0 v$ b
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
$ o$ S5 \1 U- S- P3 Y7 Q7 { - )1 a+ E1 O! I% C2 K" O7 Z
- when( cadr(polydbid) % L6 l' D% I0 [9 g% N0 Y2 z
- axlDBCreateShape(cadr(polydbid) t layer) ' |7 S$ p t8 e" d. X
- )+ K3 W# W. O7 p. X/ k
- )8 c7 {* m2 N/ m) I
- 7 x3 O" K2 m4 D& u1 C
- ; marks are only required if undo is using rolling back all database changes) z# p" v! j$ a# e8 k
- ; when command is active. When undoing each conversion this is not needed% D+ N" Y( I" \) O8 |" {; l) v
- ; nor is Oops functional.
$ s6 @: Y- i0 _! [8 H6 E \% r6 Z - when(LCB_mark axlDBTransactionCommit(LCB_mark))
7 z9 X/ V2 y! \: f - LCB_mark = nil
0 X, b! `& M$ {' W - )
5 }. |! Q( }% I) @$ t+ {7 I) k - LCB_Done() ; just in case
4 m3 n* A/ I( g2 D, ~& ~4 k( ? - ))# j% h) J1 B, O1 h& E
, i, p6 r' A$ A. n& d
% L- s% v" ~' f# Z3 B" t- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 L! ^; P0 H9 Q$ T5 P" T* H - ;; support APIs- z& Z. V) y* q% @/ q
8 ^5 ^# ~4 W) ~) `( r( Q- procedure(LCB_Setup(). X# l3 E, K. o" N3 e, E
- let( (popup)
5 e+ z0 _; V+ E Q [ - axlSetFindFilter(?enabled list("noall" "clines")
( x. n# k7 c' o3 _ - ?onButtons list("noall" "clines")): E1 B. a. @% x( h: Y
& e! a4 }1 k: | N- popup = axlUIPopupDefine( nil (list9 f. f$ Q! F) p# }% n) A* b
- (list "Done" 'LCB_Done)
) e2 v9 R: G8 `% c# N - (list "Oop" 'LCB_Oops)6 `. Z( D4 K* v* A3 Y& |' y+ U
- (list "Cancel" 'LCB_Cancel)
0 T3 |/ Z& r0 Q7 A( w | - ))
1 S* Y }% a6 }6 q$ ~( L
. E6 r" V- \) A) Q, `2 t- ; Snapping is not required by this command but this shows the ability0 Z2 |4 S* |+ R3 ^& L) `) Q
- ; to add the snap sub-menu to the Right Mouse Popup menu: m; ^! R; N4 o$ Z
- axlSnapEnableAtRMB()
& C$ p) }. [3 }4 F/ m& i5 d - 2 O! H6 L0 N# ~/ C
- axlUIPopupSet(popup)
% h! [6 a7 X8 O: i3 p5 @ - LCB_mark = nil
. V1 F/ X" d4 i. m - ))
) y: E) r% b |! c: ? - 3 n6 Y* M" z Z% U8 n) K( t
- procedure(LCB_Oops()
( z7 S9 Z8 q2 F) d - when(LCB_mark/ R! c- O- g& g
- if(! axlDBTransactionOops(LCB_mark) then
; {' [8 u( V1 h2 z4 g; J1 g! ` - axlUIWPrint(nil "-- Nothing Left To oops. --")
3 M/ e8 K i4 W' G4 i - else
. M, e# A) J M4 Y' ] - axlUIWPrint(nil "-- Replacing Clines. --")( R9 i" W, e+ E+ p0 V
- )
; j2 B& |% A3 |* H - )
4 B) c. p" p5 Z! W - axlClearSelSet()1 [. p: G. N' P! ?4 w8 V, Y- m
- )
" d" X3 a1 u8 u& F
! v) h8 E F9 f$ Y- procedure(LCB_Cancel()7 w0 `3 d; q N+ s
- axlUIWPrint(nil "** Cancelled Program. **")' W4 a$ u& V& c d E: s" g
- when( LCB_mark axlDBTransactionRollback(LCB_mark))
+ g! t+ J$ A7 P) O - ;LCB_mark = nil- y4 q% p6 p9 z8 L
- LCBnotDone = nil3 k* Z5 P) Y( [
- axlClearSelSet()* V! h4 J# u/ ]8 [* W3 X' t# v; F
- axlCancelEnterFun()8 J1 ^& s4 T9 C0 w
- )! B! B6 N( ^; f0 M% p6 D& _2 s
- : @( @( G4 f. [, h/ H0 p) L; M
/ V' C% [% Q9 c) y! W- procedure(LCB_Done()! a2 c% J9 r! X8 O6 U- g. Z
- when( LCB_mark axlDBTransactionCommit(LCB_mark))
: w/ R @! l2 V" O - ;LCB_mark = nil
. u1 R: c8 @0 M( |6 e - LCBnotDone = nil, j4 w) [( k3 N* C* F, }5 N
- axlFinishEnterFun()7 @) i3 x; m. u* g$ e' B! q. M
- )& w" }& ~' f" g) I- K8 X4 p+ a
复制代码 |
|