;;;
7 ]' N1 a- k# H0 O;;; Add an END to UNDO and return to initial state.' b7 C0 `) V* r z; A! R9 _
;;;
+ X5 F% d8 U8 s7 K5 b; q" L3 b(defun ai_undo_pop()
4 t5 l, J/ u# x7 ^& n, E (ai_sysvar '("cmdecho" . 0))9 T. r7 P) }5 u/ e0 }
(cond # B' ^5 v6 D \. i0 q8 N/ {
((and (= 1 (logand undo_init 1)) ; enabled# U7 {9 \% w1 [" Q4 z
(/= 2 (logand undo_init 2)) ; not ONE (ie ALL is ON)
1 S, b6 v* O g8 [ (/= 8 (logand undo_init 8)) ; no GROUP active& `* R! i$ V) w! k( Q( I
)
* }0 y0 f4 @- E9 r4 T (command "_.undo" "_end")$ S8 R; ~2 c* @, F
): E) y$ {5 ^8 |; K3 d8 n
(T)( W" E3 Z8 g; p6 x3 w; {
) ! x) {3 ^9 p5 f, f# i
;; If it has been forced off, turn it back on.; @# q2 q8 P! h5 Y# [4 z( }0 B- m& k: w% ^
(if (= 4 (logand undo_init 4))7 V" c/ ~- h+ N' N9 M; S
(command "_.undo" "_auto" "_on")
6 R3 n! ~* g- } ^% _ )
. i4 c7 U0 u( v! u$ m$ a (ai_sysvar NIL)
( L8 W/ Q5 c4 S) f7 N: M2 ]: X). r; Y' w9 t/ }! f; N
9 C( c! W0 h) Q6 a) z. b;;;=== Menu Functions ======================================4 @7 \! z+ N+ x4 N+ e, s2 _5 N. y
+ g2 J; g! ~# t) }: b/ B(defun ai_rootmenus ()' V9 n. w7 j3 J5 Z6 m& M3 S
(setq T_MENU 0)
7 p! h2 D t! [& { (menucmd "S=S")3 [2 V% ?( y/ R9 j( c$ ?
(menucmd "S=ACAD.S")- m: C% M& I! @1 e9 J
(princ)% V7 _2 a! q8 G7 o, T
)5 t1 u8 C, O. t$ D1 B
% d. I* f8 Q% M: Q D# x+ A
(defun c:ai_fms ( / fmsa fmsb)
5 r4 c4 H. Q2 z- c (setq m:err *error* *error* *merr*)2 H; h$ d" _8 L7 R
(ai_undo_push)
0 M! @2 w' M' C0 U5 z (if (getvar "TILEMODE") (setvar "TILEMODE" 0))
9 d5 i; g Q2 w4 g8 W3 M5 u (setq fmsa (vports) fmsb (nth 0 fmsa))0 |2 ?9 n- P& g
(if (member 1 fmsb): r9 I: H `/ z+ _* \3 R
(if (> (length fmsa) 1)9 j: Q! h; g! A9 W" ~
(command "_.mspace")3 [1 K) F$ A- L' c
(progn$ { @1 g- J) n3 E2 N
(ai_sysvar '("cmdecho" . 1))
- c- P6 P4 h1 `+ t" n (command "_.mview")
% i+ @' \4 z3 d- t! z (while (eq 1 (logand 1 (getvar "CMDACTIVE")))
' w' d8 [" X; t (command pause)3 a& u" M6 Q- T, J
)
/ c5 O2 ~# P5 _, H7 `$ ^3 T% l (ai_sysvar NIL)2 Y7 t2 g0 M* C) t0 K, \/ k
(command "_.mspace")9 p" U- a0 |8 v) D
). C5 Z9 ?7 X+ x3 X" S, Y9 r {
)* K# A% w" o# \5 j/ k1 o
). ?& E" X3 u5 J; w$ x0 i
(ai_undo_pop)
2 o) ?+ }: c$ @# g, I$ B$ K2 Y' X (setq *error* m:err m:err nil): |* g( I4 L8 `5 a- d# R0 X
(princ)
5 V1 _0 [' O9 e) H)
, W \# O. T3 \, ^1 ?- g3 G, `7 v, d& w% N
(defun ai_onoff (var)
# [+ H+ N; [+ z (setvar var (abs (1- (getvar var))))# b2 t) Z0 U7 n
(princ)
' D, W0 I, i. Q, ` h( H: H)) s( h6 w5 D! C! o' z
9 \' o( U# x$ e0 Z: Z;;; go to paper space4 E( Z" M$ P1 m" p+ i8 _; @/ q
(defun c:ai_pspace ()
$ h) }/ ]# H( u (ai_undo_push)+ P2 ?3 I% b0 l' i
(if (/= 0 (getvar "tilemode"))- Q; G9 c' Z! M t' R% J) Y! w
(command "_.tilemode" 0)
& `( ? | |( `: G% Q# v )
) X! a1 T2 q5 e8 ~+ S9 _. p (if (/= 1 (getvar "cvport"))
5 j1 @' C- O2 D( [- x3 | (command "_.pspace")
3 A3 a& B0 |+ ~9 S )
8 Z c9 E9 o4 v) r# h (ai_undo_pop)8 O! X$ v; t8 S3 E
(princ)( c) p8 T8 ]/ c0 `0 V6 D9 M
)# N, M% n, g3 U: Y- d2 [' H. S- y- }
9 L. A+ {% t5 g9 T4 c;;; go to tilemode 1% b% |& w Z" m+ B
(defun c:ai_tilemode1 ()+ u1 Q" q0 j& k
(ai_undo_push)
3 O; I8 V9 ], Y% d4 Q9 m& k2 C0 ^$ J (if (/= 1 (getvar "tilemode"))
9 h7 e; @, W: e M" E, \3 x (command "_.tilemode" 1)
% ?4 T: f- A9 {9 Y ): T5 x; c/ c6 m5 W: n
(ai_undo_pop)
* `, j4 t* A" }$ Z& W; x0 p (princ)% f: h7 V! B4 f8 {' o
)- s) v, M4 j$ N4 F
! Q5 i6 V: u% `;;; Pop menu Draw/ Dim/ Align Text/ Centered
1 }" k4 Y$ Z1 a;;; Toolbar Dimensions/ Align Text/ Centered Y+ C) k( l9 H* f) W9 o/ U3 q
3 g- O% J3 n/ k5 e1 Z* g$ q(defun ai_dim_cen (/ ai_sysvar ai_dim_ss)
R4 ^4 r! d# g: h; {8 k5 O (setq ai_sysvar (getvar "cmdecho"))) K7 r0 z7 R9 @' g( d7 s9 G6 d
(setvar "cmdecho" 0)4 l) s6 `; \: v4 y5 B
(cond+ L' T6 ~; f* u& P
((setq ai_dim_ss (ssget "_P" '((0 . "DIMENSION"))))
- Z7 z) v, O' V/ L: L' C (command "_.dimoverride" "_dimjust" 0 "" ai_dim_ss "" ' ^, S4 c t8 d4 y
"_.dimtedit" ai_dim_ss "_h")
* D2 K; ^* s5 T2 y: b5 ]9 ? ), y( X' B4 y7 `+ s% Z" w5 V
(T nil)
( j$ [9 \( p6 B2 } )
& J" x0 b2 W- x0 y. l! G (setvar "cmdecho" ai_sysvar)
& z* \# j- F2 R3 m! r1 v" ] (princ)/ v1 _ C' f4 f# R
)
+ w( W" Q4 g& @$ j1 q. P
* w: A# T. D! X: K, s( K2 _" f;;; Shortcut menu for Dimension Text Above ) H" X8 e5 k) a
) E1 J4 i. f- T6 A(defun c:ai_dim_textabove (/ ss)
, ]6 U; N' I/ K+ l (ai_sysvar '("cmdecho" . 0))$ Z+ q& ^6 o) n; g7 P, r
(if (setq ss (ssget "_I"))3 h* l$ @6 d$ Q, k
(command "_.dimoverride" "_dimtad" 3 "" ss "")) g. O6 h" x4 h
(if (setq ss (ssget))
6 g- o. i N6 K# P$ X- U8 r* x (command "_.dimoverride" "_dimtad" 3 "" ss "") 1 ?- e, G2 Z& x
)
, F5 Y( ^! a! a, K4 Q. i" z )$ O5 D. ^* E9 { ]7 y2 s1 ^- v( |
(ai_sysvar NIL)) o7 j4 v) Z. S. V ?. A7 K2 L! v
(princ)
9 T# E6 d% R( T& p; j4 b)
( Q' m- x. r; d4 {' h& M
( I/ F+ d3 r! `) \' b$ X% O;;; Shortcut menu for Dimension Text Center + ]. y/ h1 l2 {7 |
; Q8 P% `' q# c) s% h4 _- }- l& x(defun c:ai_dim_textcenter (/ ss)+ u" T% I/ t) j% {9 B/ I
(ai_sysvar '("cmdecho" . 0))
; p9 x/ K! \- W$ b4 a# U& N (if (setq ss (ssget "_I"))8 l6 d) q& z" q2 Z. B
(command "_.dimoverride" "_dimtad" 0 "" ss "")
7 o8 C* O- w+ s' c0 w (if (setq ss (ssget))1 i/ D+ J& a8 i2 I
(command "_.dimoverride" "_dimtad" 0 "" ss "") 0 L& \% T; `" u( k* v( j, q$ X: _
)
7 Q0 o% ~1 T1 i0 r- y3 L4 f )
6 Q7 k; m& ]! u/ h (ai_sysvar NIL)
2 ]7 {" D8 g8 ?) U7 h (princ)
% X% A# H" x" S' ~: T9 a)3 m: d5 H4 ]0 C8 k
. |* {, q2 G5 z
;;; Shortcut menu for Dimension Text Home
0 y( M# h+ |: n* w) C: O
$ b9 V% r8 s$ p& y6 ~# ](defun c:ai_dim_texthome (/ ss)
) N6 v" g. |, G# o- B8 A (ai_sysvar '("cmdecho" . 0))
& F; \: {' v8 H/ L (if (setq ss (ssget "_I"))
5 I! T/ l N4 Y' I4 \" V (command "_.dimedit" "_h")
' K* @; v6 ~: `# m, U# Y- Z (if (setq ss (ssget))% M2 W+ e7 V7 ^
(command "_.dimedit" "_h" ss)
9 ?( g, `" x: Y )8 I, ~3 {* A: I5 D+ h7 A
)
1 W% U! `$ _+ v3 }/ b/ J" c; t (ai_sysvar NIL)" I2 j2 z4 I/ n
(princ)
' D& ^4 c; A! _4 Q: V/ ~$ V0 x6 f# T), S X8 B5 Z& l S4 R6 V
9 h# ?( I9 a: f! z! ?: P9 r
& H! C5 W9 g( A- g/ {7 o& y;;; Screen menu item for CIRCLE TaTaTan option.
9 M/ ?. y, a' q4 Q; d- Y* j& K;;; first, get points on entities
* w( q) c: q% N/ z1 `: s" K6 ^(defun ai_circtanstart()" x1 h$ Q f0 [) v# B w& G8 C
(setq m:err *error* *error* *merr*)' C0 G; _4 C I+ x3 y" y
(ai_sysvar
) F! i# F- P8 F2 p. E% b+ h5 k (list '("cmdecho" . 0)
+ Q) D" |# p9 B8 N, e; U& H ;; make sure _tan pick for CIRCLE gets same entity2 B5 J$ u, W, B$ b5 [" ~
(cons "aperture" (getvar "pickbox"))/ a& O9 m5 B" c0 E; E( \
)
$ E, D; S' ]: G7 b$ o- j )
& t) N1 u" R, r9 ?0 W ;; prompts are the same as CIRCLE/TTR command option
4 U5 A$ ]( \3 c! H9 ~ (setq pt1 (ai_entsnap "\n输入切点定义: " nil))" Z; }$ D3 B2 ^, y/ B
(setq pt2 (ai_entsnap "\n输入第二个切点的定义: " nil))
9 K- G( C" P# K. K (setq pt3 (ai_entsnap "\n输入第三个切点的定义: " nil))
$ K$ q5 R. V3 `1 n)
' E! `# q- D4 ~( p) h;;; Command-line version
% P4 ?. R" [. ~+ t, X7 e( V(defun c:ai_circtan (/ pt1 pt2 pt3)3 j/ T! R/ {" F |$ E) g5 D |* W
(ai_circtanstart)
4 ~4 j' T) A4 H1 E% G1 `$ ^0 _7 f
- Y/ ]! c% e8 R; e' D. L% A (ai_sysvar '("osmode" . 256))5 m {. m3 \! a) I
(command "_.circle" "_3p" "_tan" pt1 "_tan" pt2 "_tan" pt3)9 V8 |- C" p2 }9 ]- s4 l
2 z2 r$ c1 L1 @1 H6 j4 Z' A! I (ai_sysvar nil)( ^) L& D7 i( Y& T3 P! o" @
(setq *error* m:err m:err nil)8 _' V/ H' d" F1 l
(princ)
2 Y( W% {! _, c8 y/ I4 c: Z% Z2 b)* y8 {# X; u0 I& D. L$ n
;;; Use this if CMDNAMES == CIRCLE Y3 R |& \+ b0 O( c* u
(defun ai_circtan (/ pt1 pt2 pt3)% g5 p) Y: R4 f5 E9 i
(ai_circtanstart)
0 z1 ~( w. T( j/ F2 h
# ], L8 J5 k+ X- W) L (ai_sysvar '("osmode" . 256))
! m$ E$ j& ?7 g) r (command "_3p" pt1 pt2 pt3)( `+ Z5 }8 ?7 Z7 S! a+ F
~- P- N' F8 ]3 W; I n3 H (ai_sysvar nil)( I' F' N$ a6 x' y: u. U
(setq *error* m:err m:err nil)
& z0 s' ]$ G7 t+ t# l3 J (princ)! I1 W) r$ L+ P, F- |; k
)
) m. B( @$ V' l- y# t ~! o# E% ]% u7 M# k* s9 z0 d
* q9 O0 d4 N) {+ }5 A
* Q! X" `* {2 V+ _! A1 U;;;=== Make Object's Layer Current =============================& T, q' G4 {+ K7 r
/ F& D0 S; a0 I) j0 a3 ? L( k;; Makes the layer of the selected object current. If there is one7 X" o+ u1 \+ _) M3 G
;; object in the pickfirst set, it's layer is made current without
* i/ p. U4 }& T' D9 M# j' n;; prompting for an object. Else a prompt is issued.
" p/ j6 W. q: ?, | e3 W( X(defun c:ai_molc(/ old_error end_undo old_cmdecho set1 ent undo_control): s1 m3 J$ _- B9 W, P' z4 Z
6 U4 j$ b- \2 @+ u
;; Simple error handling.: s% P0 k. [* v9 h9 j
(defun molc_error (s)
* c7 `3 ^) I7 E3 E" {5 Y ;; Reset error handling.) l, F& ?% T( E3 p5 \+ j8 h6 m8 R0 Q
(if old_error (setq *error* old_error))
: W. B/ Y1 A) `' |( Q! ], J ;; End undo if we started one.
" u3 [ L+ ^2 {* G3 G! l' p) W (if (eq end_undo 1) (command "_.undo" "_end"))
/ ?0 t2 e3 J: C0 E. @ ;; Reset command echo
( O6 D) V* x' Z, |- |% R" e: l r/ l+ _ J (if old_cmdecho (setvar "cmdecho" old_cmdecho))
1 p8 r0 y, [/ `8 Y2 C- p0 ? ;; Silent exit.
3 m" d5 {1 T1 X (princ)
, Q) t1 V7 Q: Z )
3 {2 P: O; l6 C; p6 ]/ x' l A 6 @* e& E% _6 v# _% a
;; Save current error function.2 Z+ t3 t0 o- |5 S1 W- n
(setq old_error *error*)
& b3 [# R f% } 7 n9 ?/ k, e' e' Y2 g1 N2 w$ L8 u
;; Set error handling to molc's error function.
! @: Z$ g) @3 A3 H0 C# c (setq *error* molc_error)
9 ], L5 A3 g% ?1 A* O7 _
% U1 j. [' x% X; H0 ` ;; Save cmdecho setting.
$ z5 B/ I* B) e: o `0 ~ (setq old_cmdecho (getvar "cmdecho"))+ Z0 L& s' b H% G
6 X. d* j+ e }$ g7 O
;; Turn off cmdecho
- L2 |8 t; b# `3 ]; z# a (setvar "cmdecho" 0)6 x; _5 K- B4 I" k h1 H" t; P
7 v8 G% e) Y `& e ]# I- }9 u+ I ;; If Pickfirst is on and the selction set contains / E' }7 ^2 U/ e( ?0 Q" N
;; one object, then use it, else prompt for one.
% |3 D2 u5 M7 i0 u0 b; b( Q9 Y (if (and (eq 1 (logand 1 (getvar "pickfirst")))9 s/ |+ o% K, ?3 l5 o+ H
(setq set1 (ssget "_i"))0 R2 D" o) G5 g6 ^5 ^3 u' {
(eq 1 (sslength set1))
A: P a5 i& T5 g, G4 W7 F( C' @ )
: @, t4 H* O( N9 _( R (progn " M& s+ y: w; [- W
(setq ent (entget (ssname set1 0)))
& ~7 [+ b) i. Q% M# G4 L2 J (sssetfirst nil nil)5 Q0 q" O7 m. x u& w1 p% X) j
)
! r+ l1 W+ w4 X0 T- f4 l- l+ f+ H2 Q (progn : X" l# D+ H8 ~' ~: N5 K5 G5 Z# N
(sssetfirst nil nil)
7 X) `- R. s9 O! d2 U8 y (setq ent (entget (car (entsel "\n选择将使其图层成为当前图层的对象: "))))" p0 H* z, ?% ?4 v
)
- x$ F9 l: [2 c1 i- c9 R1 W9 P6 k6 f: | )
0 D2 Q8 h9 s6 t2 [/ \1 F
5 D7 t4 I3 H% v7 _+ J$ U ;; Get undo setting.
: c6 ^. R, U/ g3 F$ ~5 l7 I, @+ b (setq undo_control (getvar "undoctl"))
% @, i) K0 M: o# H+ O, \7 ]0 z ; M' G- Y: w3 ?& J5 v
;; Initialize flag to to end undo.
: Z! Z/ S4 }! i+ U% t (setq end_undo 0)
- |+ V/ K, r' O! I
^- X& E w8 S4 y& s- U ;; Begin Undo group if need be.
& k7 {4 A1 m( M c- n+ s9 \# V _ (if (and (= 1 (logand 1 undo_control)) ; undo on
5 p7 U4 j& i1 T6 j; v0 Y9 Q (/= 2 (logand 2 undo_control)) ; not single undo
$ r' i6 s6 H) L (/= 8 (logand 8 undo_control)) ; no active group p4 l4 T V( c5 ]' L
)
* ~ y* i: X6 U# S (progn
/ }9 X$ K1 K0 ^" {, y7 O y. T ;; Begin a new one9 A- s% k$ V/ a; d0 k4 F
(command "_.undo" "_begin")
1 r# u# D3 P. G5 z, A( } ;; Set flag so that we know to end undo.
# v4 j" _$ L3 O% m9 u: F (setq end_undo 1)
9 z. s8 Q: A4 F) R; H1 x. `" E )& y) n" M7 T( j7 b6 f/ `
)
# H* C, c# W7 `$ y
9 P* z& m% q, z& u* V: _( [- Z/ R2 Y5 ?/ f ;; Make object's layer current.
8 {$ Z4 s+ ?- |# L7 A& ~ (setvar "clayer" (cdr (assoc '8 ent))); { R8 w% `# V
: I! O) v Q0 a- o$ g) x3 ^$ z3 V
;; Print message& Q- w# M( H5 x2 P* |
(princ (strcat "\n" (getvar "clayer") " 现在是当前图层。"))3 u% s2 F& m1 k# P5 Q. C
. y# k# Q w" _. m- n1 g* }
;; Undo end6 O; U8 ~$ r! Q7 q, K
(if (eq 1 end_undo)3 i, n% ^5 U" _' _3 L: I
(command "_.undo" "_end"). M2 {, g; Y$ `& B9 ]; k4 v
)- d. K/ W! \2 n& S* G
- ?& ~( \ i; A8 }8 X ;; Turn on cmdecho
P2 ?& L6 s, D/ K (setvar "cmdecho" old_cmdecho)
- [8 I$ {2 R# Q4 r* n2 V5 i
) u) T* t; ~. d* M+ A9 U4 | ;; Reset error function.
F! K* r2 ^) g: K( r8 |8 ?+ R k; k (setq *error* old_error)
`9 N ^- E, Q/ K) J7 n" b& L8 ? 8 ?8 d% x9 X5 O( {# i, z5 g
;; Silent exit.
9 F; R6 f3 I+ ^5 l (princ)
9 j3 |3 E- u, o5 n7 _)
! K# m& f* o+ n+ D5 z2 j- f6 o. {; D! ^& F- J9 G% o7 @/ k, d- D
;;; Shortcut menu Deselect All item.
, E; `9 O- y: s2 R; [- v' c6 |0 t% ?5 U. H
(defun ai_deselect ()
* R; g' Y. S, i6 I (if (= (getvar "cmdecho") 0) ;start if* S4 l7 h4 k1 L) x
(command "_.select" "_r" "_all" "")
$ H/ O' g6 [$ L0 B4 @5 L1 _ (progn ;start progn for cmdecho 1& E8 A3 ?- X6 Z4 _2 j
(setvar "cmdecho" 0)
h" x* U* q6 W3 b" r (command "_.select" "_r" "_all" "")
/ h# o$ ?7 i6 e3 ^ (setvar "cmdecho" 1)
0 c9 P u' r( e$ \' I, z+ c ) ;end progn for cmdecho 16 Z: e+ Z7 [" u9 X5 D
) ;end if
; w6 N& y0 v3 \: \4 v (terpri)* t% a2 C8 F& K" n" |
(prompt "所有对象都已取消选择")
6 r* m% k$ V* P% ]8 K (princ); |7 [7 R5 R, [8 Y8 W3 C
)$ k- R- O9 W8 Q0 c* B
9 k8 Q- d, i- l4 ^: |;;;; I+ \8 c6 B3 b' r( J* Q" @
;;; Enable Draworder to be called from a menu
2 ?5 B A' v6 w9 S8 z;;; Checks for Pickfirst selected objects' i. f( P* Q* b9 Q7 C4 D9 O/ |
;;;0 a1 s8 S7 w6 E8 I2 \% U" l3 T) r
- z# n) S3 H2 z6 F1 W(defun ai_draworder (option / ss )9 I: q& m4 S0 X9 C- {0 b
" v9 T, X7 `- u2 _
(setq m:err *error* *error* *merr*)+ R6 G; v; l7 f6 M4 J" Q
(ai_sysvar '("cmdecho" . 0))
' ^$ d1 m& [. [3 D5 k1 ~( x: |* l1 i! H X' U7 n
(if (setq ss (ssget "_I"))
8 L D8 @0 L8 ~, W (command "_.draworder" option)
X& Z m+ U' i. [& ` (if (setq ss (ssget))
4 J) ^4 ^7 R# G2 S% b (command "_.draworder" ss "" option)# F7 ^1 D; V: h8 Y6 @$ f4 d& R
)' T9 K6 _+ G! I- F$ z
)
) H" H! {$ K( _ (ai_sysvar NIL)- L8 f; k; [$ H/ T, z n2 d
(setq *error* m:err m:err nil)
& c* J9 ~( E4 }" a6 V# `* _- V6 j, F4 i: d4 O- C |
(princ)3 K7 i' S0 [9 w$ r
)
' K0 { e/ C3 X) I- d2 }4 c
8 ]8 J& M0 I* L3 z! ?5 }& \(defun c:vlisp ()
4 K- T) ^' \% r4 f( z (if (/= nil c:vlide) (c:vlide))
+ F" l1 `: q3 z6 e)' ~( ~/ {; B5 t4 k% M
) R5 d% t2 S+ y* Q! G/ v1 W
(princ "已加载。")
; Q- @+ P$ [! T(princ) |