TA的每日心情 | 慵懒 2025-8-25 15:23 |
|---|
签到天数: 85 天 [LV.6]常住居民II
|
推荐
发表于 2022-2-18 11:54
16.x及之前的版本需要把出现的两个“?undo t"删掉。
9 \9 S, H, P' J- I7 W, j6 e
2 ^; l/ r# x Y; t- ;###############################################################################
0 g; t" J/ |# ~9 ^ - ; #2 i. O5 u* ~9 K7 e! R
- ; Command: cline2shape #0 ^, v3 _: y! I; [/ |
- ; Skill File: cline2shape.il #
' A# x( B$ f" I$ H/ m - ; How To Execute: Command> cline2shape #
, a, s$ }) j. Z' U1 H) }1 w% l0 h - ; #
: i$ e5 U \, I4 s. _1 T! e3 t - ; DISCLAIMER: #
$ b2 s' K7 V, {" e! S) T - ; The user of this command assumes all responsibility and does not #
/ g8 Q ^/ F( p; c0 N - ; hold Cadence Design Systems nor the author of this code for any #" C) S# `7 n8 |
- ; unwarranted results or problems due to the use of this code. #0 y0 f8 u @" K6 h: x7 o+ o. C& Z j
- ; #: e/ [! Z4 e2 }7 L' ]) I
- ; This is non-supported code and the user may modify it as needed. #3 k- q, X: Q) X8 A; E d6 S0 e0 P
- ; #. K& e/ x+ A$ _8 u# X0 ^0 n
- ;###############################################################################, Y2 O$ R* h* z- Z: H! _
4 X* k+ d: I8 r! ^- ; demostrates6 [3 Q$ n6 N5 m7 o% x
- ; 1) style for an interactive command6 h s5 a$ `! V' |0 r3 v8 @# J
- ; 2) use of the database tranasction APIs
- t- s4 Y- V" X. E$ @ - ; 3) two styles of undo/redo support# y1 h" H$ N. W. i5 E) ~
- ; Added undo support3 R' ]. w' e9 h0 c; j
- , \4 u( h, C4 q0 ~* }3 j
- ; Know Bug: Sometimes the program will not convert all cline segments but it " |4 L5 Q& c9 i% n8 x
- ; will DELETE all segments. Use at your OWN discretion!: L0 L7 O7 b6 k+ H: T
- ; Select Cancel or Undo before exiting the command to restore 7 ]& Y D& m( T8 a* t1 p4 W
- ; to original Clines.
3 P1 s7 G( o! w5 d' h$ H8 I( k9 u) |
/ ?: c5 u$ V) e2 x1 k1 A( K- " L4 G) w: o2 U
* @% D2 D3 l3 F8 Y
/ F" p' q, b8 Y* I- axlCmdRegister("cline2shape" 'LCB_cline_to_shape ?cmdType "interactive"4 ^6 o/ g4 y- F, Y' Q* y# a
- ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)
% `8 K8 X# J. l3 P) D9 C - axlCmdRegister("cline2shape2" 'LCB_cline_to_shape2 ?cmdType "interactive"
1 q; n$ d1 T: t U6 _$ ^( j - ?doneCmd 'LCB_Done ?cancelCmd 'LCB_Cancel ?undo t)8 v' F) k* F4 q( w
7 ^8 j' W% T, _3 p7 |5 Y0 U- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 n: a" L1 {9 K/ ] - ; This shows undo where all of the conversions that this user does while
9 D# r$ q5 k4 X$ k - ; in the command a undone as a single operation.
$ T [ J+ f& E% Q* x' @$ ?2 ^ - ; To convert an existing command to support undo this method is2 G( J8 K# v# c1 {: d" d+ h7 t
- ; typically easier.$ X) i$ T: L: h, j1 d5 ]7 i+ P
) w* A9 r( B# A1 |6 v9 W- procedure(LCB_cline_to_shape()- t% O4 v$ ]% @! A
- let( (lclines layer polydbid )8 \& w2 n4 M6 `" {& `' N
- / K& M% H+ {/ B
- LCB_Setup()1 M" l+ p3 Y& ?, {! Q' Q& T
, P7 r* \. i( D" U) m7 v1 }8 u- ; cannot have a global transaction if we want undo to roll back each operation
" {" Q# K) {; A) i8 _2 r0 H - LCB_mark = axlDBTransactionStart()
1 |3 r1 D" L9 s$ D - + S) k1 i% v5 G! ]# h
- LCBnotDone = t
( ?- ~& R! H) } M9 F& r - while( LCBnotDone
3 K% w3 }. z' v, _3 H( r$ I5 Z, S C - lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))+ E2 q; T3 W# A- k' D6 M; P/ s
- + y& v/ w5 ^4 u: e
- foreach( clinedbid lclines
1 Y/ U& q' ~! X- n8 o W7 L5 W8 C; O - layer = clinedbid->layer# E, W' F/ C0 S |3 h4 }
- polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
2 ?% R! C& V+ k0 ?$ R
* _3 B7 v0 J$ b' n' N; _' r. ~- s- axlDeleteObject(clinedbid)
) u- R- c1 _; |! c' M# g# |
. n- o2 O: b3 [- unless( axlDBCreateShape(car(polydbid) t layer) b( Z4 o0 q" j' _5 V
- axlUIWPrint(nil "ERROR: Failed to create Shape from Cline."). m' X9 q8 Q1 \3 V. o3 f
- )
$ R- R- M" R7 B - when( cadr(polydbid) ! v& q; r& P. n; h0 |' X$ c! y; I
- axlDBCreateShape(cadr(polydbid) t layer) 7 Q) [2 p- ?+ J9 U. g0 n _: y" _
- )
9 @) i0 w* E2 H5 E! Y1 u' M - )
: l0 O( {# O7 M$ a6 D
1 Q$ A+ b. B; v. e7 ^) A3 s- ; marks are only required if undo is using rolling back all database changes
3 J3 w! L% m& k' F( N: O - ; when command is active. When undoing each conversion this is not needed5 O& h% X2 m2 f+ U# E* ?
- ; nor is Oops functional.) O* u8 u# r% E% N! G
- when(LCB_mark axlDBTransactionMark(LCB_mark))+ ^( t2 I8 f. ~& @! Q! Y0 }6 j
- )3 a z' q' _0 ]# y
- ;LCB_Done() ; just in case
; v7 B: N8 `0 l3 k6 ` - ))! ^7 s9 W& s- d- t% d& U# D
- 3 j; y) N+ R5 `" d6 Y) R" f
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;7 i# y7 x2 `# f" _% a$ r! q
- ; This shows undo where each conversion is supported as seperate undo operation
0 Y' |: w1 }( K - ; in the command a undone as a single operation." y( p2 r( R1 x* {% t3 G' ?
- ; To convert an existing command to support undo this method is
) R9 r& x7 c7 G) R - ; typically easier.! F% H$ v& {! E# S
- $ L) ]) s) ~" G8 v
- procedure(LCB_cline_to_shape2()
0 y3 l- d0 ], F% c3 q' t - let( (lclines layer polydbid doMark )
% U1 X3 b- u, @# R9 ~2 }* W
1 c' D5 ~: y @) j& d% e- LCB_Setup()
& y. B5 t( k) \$ j& c
* P0 D% N) {! L/ l$ v5 {- ; cannot have a global transaction if we want undo to roll back each operation
5 ~6 v$ g: M4 M* ]% W- ?
/ o1 E D) ?' O4 n4 t# x2 e- LCBnotDone = t E( p7 j* N x( p) X( a9 @+ y
- doMark = 'undoMark
, d) d9 Q* ~7 @0 F. P6 `9 [
+ T: q# v$ S5 U5 t- while(LCBnotDone4 H; e: }1 T' T0 n( v# S
- lclines = axlGetSelSet(axlSelect(?prompt "Select Clines to convert to a shape."))+ @2 o6 l) S1 D2 |/ y I" W
" T- z) Q- H" q5 r, T- ; need to do a start/commit for each operation if we want undo to / e# c9 u- b+ w2 N+ N% D. L! ^4 ~
- ; rollback each change. This mostly disables Oops
) \) o% a$ ]% D8 b# o7 R; B - ; don't want to start a transaction unless we have work to do or it will8 m- n. |1 Q- ]: c: f
- ; do a unneeded undoMark. " _8 c$ B3 b) J5 j5 C* L4 F3 a
- when(lclines ( z. h* Q% _5 J$ }# q1 U3 o& D
- LCB_mark = axlDBTransactionStart(doMark)5 L2 ?; H! V# w/ G% R
- )
2 ]0 {2 E8 t0 M( ?
# C5 u2 S4 V; w9 o- foreach( clinedbid lclines3 f) a* w4 X# {/ }9 E2 T7 i
- layer = clinedbid->layer" ^* w2 q5 ]$ Q2 |; v
- polydbid = axlPolyFromDB(clinedbid ?endCapType "ROUND")
) ~/ q/ w! W% y/ s" f
9 E. q% P0 ~! @8 a, `8 T- axlDeleteObject(clinedbid)2 `8 k) J+ B! Q+ y& q2 |0 ?' S
- . Y- q: C n( e, U5 }
- unless( axlDBCreateShape(car(polydbid) t layer)
, I% l0 {. m! ~7 ?( ] - axlUIWPrint(nil "ERROR: Failed to create Shape from Cline.")
. Y5 i. p0 E9 y7 d- r$ @# l! ? - )
6 |5 ]. [" w9 }1 R! N7 W - when( cadr(polydbid)
+ D* O! K/ J9 x7 a - axlDBCreateShape(cadr(polydbid) t layer)
0 L* M0 k$ c) [ - )
0 I. m+ l5 p2 \. W3 O' Z3 P! w - )
! k% ^- k T, ^7 }
8 B$ }2 y, `7 ~* V/ z' X- ; marks are only required if undo is using rolling back all database changes, \# @5 D& }/ K7 E* R
- ; when command is active. When undoing each conversion this is not needed
" s' w* t3 _, h0 g - ; nor is Oops functional.
( t; u. @3 O: g - when(LCB_mark axlDBTransactionCommit(LCB_mark))$ E$ {* ?# g" I6 B
- LCB_mark = nil
- S7 e& {: G0 C! I" O2 C. h; u6 | - )
# c) f8 F, [* l+ i# Y3 P5 t - LCB_Done() ; just in case- {. @1 M3 P! a: l
- ))
% B8 F8 B }2 _7 Z& l2 O
- `0 h7 [3 y$ M4 p) X, [$ u8 z
/ ], b; {% t/ N- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;: w5 Y3 A# g/ m, r1 t3 M
- ;; support APIs5 e' @+ K: D+ q8 x
- 5 [1 g: Z* H. M: o S' L7 e/ r% z" d/ t
- procedure(LCB_Setup()8 u( y t0 ~0 F, d& i( q
- let( (popup)4 X5 i3 } X; l
- axlSetFindFilter(?enabled list("noall" "clines")
# ?' g/ @8 u9 ^/ P1 I9 v M5 j - ?onButtons list("noall" "clines"))
% F$ n: B; F: q# I2 O - 9 f g2 Q9 C) H: }' _+ l$ [
- popup = axlUIPopupDefine( nil (list
- \6 r& S3 N: K+ p- c - (list "Done" 'LCB_Done)9 U5 w3 h/ b4 b
- (list "Oop" 'LCB_Oops)6 l( b( L9 l7 l6 N6 D
- (list "Cancel" 'LCB_Cancel)
. ~5 ~+ s e+ I' L9 y - ))% `! _% A3 }9 s
- ! m3 U$ S% @2 C& D; S
- ; Snapping is not required by this command but this shows the ability
3 e* Q& S/ y3 x: }& B; l' Z2 x+ M - ; to add the snap sub-menu to the Right Mouse Popup menu
0 B$ h6 Y$ G8 l5 e" c - axlSnapEnableAtRMB()
4 H% @$ _- A A F# y* F3 E9 R
1 c$ C) n" w& ~+ b+ U8 Z- axlUIPopupSet(popup)
) V% E" k8 t6 v$ c: o8 U - LCB_mark = nil- c4 n8 P1 D) u% T S7 U. |
- ))
& Y( X5 Y# r, G% `9 {3 F7 T3 o - ( t( ^4 Q5 u% x2 |8 O
- procedure(LCB_Oops()( W& ~& A( z! d. }# U' K7 e
- when(LCB_mark
) q4 V8 P# X# K. q9 H - if(! axlDBTransactionOops(LCB_mark) then6 a/ g& r' T" H- Z$ i
- axlUIWPrint(nil "-- Nothing Left To oops. --")$ @+ x$ D3 u/ b A; B& |
- else ^; O9 q, a6 ~
- axlUIWPrint(nil "-- Replacing Clines. --")
3 g( Q9 u7 k ~* b- Y6 v6 R0 v - )- }8 C( S# O1 l' U3 @
- )
; p2 K8 ~" ]# q2 f0 r Y - axlClearSelSet()$ }% R L6 X3 E
- )3 S6 t) R0 a/ c: c1 t& f
- V' b; I- R& k1 ?* z4 R- procedure(LCB_Cancel()
1 w; P# z; W) Z3 k. r - axlUIWPrint(nil "** Cancelled Program. **")# K# d8 V/ B; \7 J! A$ O
- when( LCB_mark axlDBTransactionRollback(LCB_mark))7 X& h- P, B+ c9 {- n1 ^
- ;LCB_mark = nil2 i8 d2 }) X1 Q" l( h( e7 \
- LCBnotDone = nil
- p4 B+ X a2 c - axlClearSelSet()5 d2 R8 h1 `) f! P' g7 s, W
- axlCancelEnterFun()
# Y' Z- h% X/ W) @/ e! {% N9 a( T - )+ C) Z* T, P& [6 j
7 ^: P2 A: P. ^0 O% I% r2 i( {- 2 ]4 e9 h. V+ h ?1 f5 b
- procedure(LCB_Done()
- \% k2 Z3 B% o7 n# [# ~- E - when( LCB_mark axlDBTransactionCommit(LCB_mark))
: }, ^* t4 T. V- T7 W4 F7 ] - ;LCB_mark = nil8 K' G x1 v6 d2 m& {! Y
- LCBnotDone = nil: r+ u2 F. O- M6 u
- axlFinishEnterFun()
) y* |. y4 e$ I( b, k, h! E+ s$ L - )
x3 v' X; ?9 \
复制代码 |
|