;;;: S& _) E7 f p G7 ?/ k
;;; Add an END to UNDO and return to initial state.
8 m+ `- n6 @$ s. b" K" \ T;;;
! s( L9 u! G8 H* L% N% x/ s0 s(defun ai_undo_pop()
# R5 X7 D0 Q6 g: p (ai_sysvar '("cmdecho" . 0))
" Y( E$ d1 m; O7 ^8 q4 ~ (cond ( h/ _) _6 J& ~" n# \1 W6 H1 R, u
((and (= 1 (logand undo_init 1)) ; enabled
& l* F) d1 j; n6 b8 {# |; q, H (/= 2 (logand undo_init 2)) ; not ONE (ie ALL is ON)
( _" W4 z! m: U0 l4 ?. B) E (/= 8 (logand undo_init 8)) ; no GROUP active
& v8 n* }5 S0 ] )# s9 Y+ b( N5 h
(command "_.undo" "_end")3 x, f# x4 U) O- z
)
$ J+ i; o e* A; Q (T) [* Z8 O6 N: B4 H7 X
) - ^& ?& f* n% g: K, r% g B
;; If it has been forced off, turn it back on.
8 _% [1 I9 G6 ]: ? (if (= 4 (logand undo_init 4))
% o" \2 I0 f: j1 k5 G" Y+ A6 I (command "_.undo" "_auto" "_on")
3 J; f( a) J" i )
5 _3 Q0 a+ G8 L, R* m (ai_sysvar NIL)6 \6 E5 ~5 Z/ J5 k4 W* U
)
" H3 o( k S- L3 O0 n- o8 V* ~
+ |, P) a4 A' a$ e5 |;;;=== Menu Functions ======================================
: y# H: n8 O: s# [# R9 D& b
% [3 _" a% `) ?; U$ L7 \(defun ai_rootmenus ()
8 g' J( C8 @: i* E+ @ (setq T_MENU 0)
! g v1 ]8 U, l" u' j$ g (menucmd "S=S")
% P G& b, z! P0 K4 l (menucmd "S=ACAD.S")+ v- L2 Z' k5 R6 @6 W3 C
(princ)& k9 ?$ Y# y6 W
)! e3 Y! V Y7 x* u% Y9 y
9 e( `" Z. A" s$ m7 H4 S9 ^+ X(defun c:ai_fms ( / fmsa fmsb)- z5 U, V8 o' y& h/ g1 l$ G- C
(setq m:err *error* *error* *merr*)
9 e) R* d& A/ y6 C4 q (ai_undo_push)1 O' |( F, K1 z6 G. s4 O
(if (getvar "TILEMODE") (setvar "TILEMODE" 0))' ~$ u4 p& B2 u( j4 G: F
(setq fmsa (vports) fmsb (nth 0 fmsa))
) ~( y0 C5 e0 |9 k9 {& c- g (if (member 1 fmsb); P7 v K* [4 u, ?/ i& D
(if (> (length fmsa) 1)1 I4 H! X& [( i1 E$ \
(command "_.mspace")
: N8 ` R$ B7 |; g3 P4 w (progn
# R2 e4 v. e3 B (ai_sysvar '("cmdecho" . 1))' F3 i: y& X+ ]) C8 B
(command "_.mview")
x. y& E! _7 N# M. q (while (eq 1 (logand 1 (getvar "CMDACTIVE")))
: [! I, ?# Q, w (command pause)9 ^9 q; z7 V6 M& h/ p
)
K1 f% A( {0 U% \ (ai_sysvar NIL)
8 @; F* N& T7 H" Y9 d (command "_.mspace")
! j6 G# O9 o, d% y# S )
! s' H# f! ?) t3 l2 J% @2 E. T )9 T0 K" j& @( U, z+ Z$ Q
)' s& a! B0 ?8 @- s5 ?
(ai_undo_pop)% J" z2 M' ~- w$ ?1 \4 y0 u( X& v
(setq *error* m:err m:err nil); O8 H& m5 K( t
(princ)
4 ?4 ~4 C) _* s1 j, p3 K. p)4 ^, ]6 n+ Y$ ^' |* X
1 c, M% s. f5 _(defun ai_onoff (var)
1 M; V& J( o9 }$ m (setvar var (abs (1- (getvar var))))" A: O& r8 }' R$ B E
(princ)
4 ~1 J& G( ^1 k0 R2 \8 C)) K, Z. W( A, Q8 I
. Y, a0 `! z$ I3 y# i8 z! I8 F
;;; go to paper space
e9 C( N( z2 V v) f(defun c:ai_pspace ()
' E$ j! ^! G4 b9 f9 i (ai_undo_push)
% L& C; {% y4 Q5 C$ U (if (/= 0 (getvar "tilemode"))
+ P: p% K7 \; Q l5 N (command "_.tilemode" 0)2 w9 ^' q/ p6 u
)
+ Q! _$ S4 U0 G! n (if (/= 1 (getvar "cvport"))
) N, [* E S( P5 m* f' M' p5 h; r (command "_.pspace")
4 [$ o: J; g; u3 o. ] )
4 h6 Q3 K! i2 ^% M3 [( |0 G8 t! n/ q8 Q: C (ai_undo_pop)! D$ G* s4 ^7 \9 t
(princ)
, @: Q& P& I& |7 f5 V$ x)& b: j9 F t! w0 L8 K. W
/ ?; n2 r1 ]+ l3 g" _. @;;; go to tilemode 1
2 x4 l1 z- q! v& S(defun c:ai_tilemode1 (), ?& L& F ]* l/ M
(ai_undo_push): v4 {9 G: @/ S
(if (/= 1 (getvar "tilemode"))
9 X+ U, c& r" K, Q (command "_.tilemode" 1)6 o8 j+ u9 U: z, P
)3 h) R8 P; S. y1 p% I/ w6 `
(ai_undo_pop) q6 s4 C8 w4 K; @! e( D
(princ)8 ^: `) C, C) `7 h
)& W: [1 {0 F7 e
7 F- I" r) h' g+ S" f& x" g
;;; Pop menu Draw/ Dim/ Align Text/ Centered' T1 P; t/ W# T6 |# p8 d w
;;; Toolbar Dimensions/ Align Text/ Centered7 ~* \9 r* W0 N! k& M
1 T. L3 |+ x+ k5 u7 I+ K& L
(defun ai_dim_cen (/ ai_sysvar ai_dim_ss)0 O0 d4 p( x- ^8 J4 M
(setq ai_sysvar (getvar "cmdecho"))* ^6 Y/ e5 h2 X9 i4 {0 l: t+ w
(setvar "cmdecho" 0)) v5 e5 e: V2 e" E) t, {
(cond( H6 x2 U* s4 A" \# z
((setq ai_dim_ss (ssget "_P" '((0 . "DIMENSION"))))* E# s( m f2 w8 }* D [
(command "_.dimoverride" "_dimjust" 0 "" ai_dim_ss ""
5 Q0 J1 B& L/ R2 B "_.dimtedit" ai_dim_ss "_h")
$ L6 U- S; C2 a/ r )
# C/ e( I5 T* B2 x (T nil)- o8 h3 r9 E- z, v. p& O2 g# q/ V
)
2 g5 v8 C* B% r9 }- P- o% d! L (setvar "cmdecho" ai_sysvar)" ^& d; ?; S. ]! c* I# v; q- s }
(princ)
4 V; |$ ^& S4 H( S* H: o( B' e9 o)( [/ q& Q; ?% B" v- v, K
: F$ ? u1 |( c" A& C4 @+ O;;; Shortcut menu for Dimension Text Above
P3 V9 V Y$ o c5 q3 E6 \" h- `7 ?: z* l n2 G2 R& h
(defun c:ai_dim_textabove (/ ss)
' H5 _) d" I I' o. w3 k$ j, P( f (ai_sysvar '("cmdecho" . 0))
0 f: f$ `* R6 {3 E: F (if (setq ss (ssget "_I"))
9 l7 A0 a9 ?. g, V8 z (command "_.dimoverride" "_dimtad" 3 "" ss "")5 @5 |, L' U5 O3 Y* r8 e. \" h
(if (setq ss (ssget))# s% P3 h0 H: w! M
(command "_.dimoverride" "_dimtad" 3 "" ss "") & {" m4 ` e, \4 H# T& @. `
)
. i7 w- e- ?3 _! |8 f+ f; e0 O8 O0 k )
: A! m) ?* ]/ b6 O% O+ a. ` (ai_sysvar NIL)
0 r3 L7 W( b& v( G8 D (princ)
& x2 e {- q& T: u8 N)+ m' o: V! N; r d
1 t1 z/ a g! J;;; Shortcut menu for Dimension Text Center
4 ?* h, \8 R) ?2 m3 G, V! B# b$ f4 T" v; v
(defun c:ai_dim_textcenter (/ ss)' ^+ t) G! j* E* K% a
(ai_sysvar '("cmdecho" . 0)); B& \, N3 d m
(if (setq ss (ssget "_I"))+ T0 E4 |7 w! M6 _! `' Z
(command "_.dimoverride" "_dimtad" 0 "" ss "")6 j; w6 q' T# C4 @. C; e8 ~
(if (setq ss (ssget))
4 ?; Y4 R. K# _7 p, {6 h, i (command "_.dimoverride" "_dimtad" 0 "" ss "")
* k+ V1 i4 q( A! x/ y )* Q: a# w) c1 ^2 u' U+ ?
)
+ c8 e1 U0 B; w9 e- G! r' O (ai_sysvar NIL)
9 i" n" x. C3 Y* ^8 \ (princ)
. w1 ^" i- o; Q)
9 l2 K3 X$ r" k% C+ ^ S
7 F. K$ E2 `: b5 V0 a; ^+ p6 k;;; Shortcut menu for Dimension Text Home $ P" `8 M) v, u$ c3 u
) t8 ~ Z' V+ J0 n/ c% W(defun c:ai_dim_texthome (/ ss)' @# [) j8 W9 n+ t0 A6 c
(ai_sysvar '("cmdecho" . 0))2 N3 t6 n, B6 B, U
(if (setq ss (ssget "_I"))* [. K2 B b7 P: j! s
(command "_.dimedit" "_h")/ ]& s& D" I3 K' L
(if (setq ss (ssget))9 Y. Y/ J# x" K$ l m3 i G
(command "_.dimedit" "_h" ss)' `; b2 H. K7 F; B( \
)
2 T# k4 o+ _; f9 u )
, M) G% I: i! l& j$ n (ai_sysvar NIL)+ @! ^+ I2 Z$ m1 q: _" B
(princ)# C3 O9 O- W8 _0 y. U6 B' G
)
" j- e, ~- _) Q, r# D. V0 V
9 x! F5 R2 q; p/ Y
; Y/ v L, @: I) i;;; Screen menu item for CIRCLE TaTaTan option.( ]2 m. j/ |0 n
;;; first, get points on entities
+ Q! Y5 i. `* c5 r0 E1 K% X(defun ai_circtanstart()) p" t# E- P$ e
(setq m:err *error* *error* *merr*)
5 F) H: M( [( g1 Z8 q9 P0 S (ai_sysvar
6 }3 `# L$ b$ J6 [! M+ x4 m (list '("cmdecho" . 0)
- l' n; U3 _# v* S: S2 H ;; make sure _tan pick for CIRCLE gets same entity8 W! _& i3 _" X8 y; r
(cons "aperture" (getvar "pickbox"))8 {; k% ~. b& S% t3 c1 l+ U
)
( p# B: S" }6 R* C5 I% f ) J0 K. U2 w0 p; I/ X: e) x
;; prompts are the same as CIRCLE/TTR command option* h+ {0 X4 h% o! |
(setq pt1 (ai_entsnap "\n输入切点定义: " nil))
! t" W, |# U( ^- }4 x (setq pt2 (ai_entsnap "\n输入第二个切点的定义: " nil))
+ T! R7 u, Z1 R/ Q: U4 X (setq pt3 (ai_entsnap "\n输入第三个切点的定义: " nil))
7 `6 j4 G0 A u" \)! c" t: s9 p6 H( f) @$ @# ^
;;; Command-line version# n+ W% o s" h' d3 R
(defun c:ai_circtan (/ pt1 pt2 pt3)
3 u8 P( d% c' A (ai_circtanstart)) v# o v/ x, N# z$ g% ]
4 [' `: R! x) L! S) K' @4 F7 l3 r! e
(ai_sysvar '("osmode" . 256))! {) p, d/ r+ @
(command "_.circle" "_3p" "_tan" pt1 "_tan" pt2 "_tan" pt3)
* k% L) [9 O. o
! Q1 o" ^& e: g0 s! z5 ~ (ai_sysvar nil)
: J/ M" r. ?" L# S5 _ (setq *error* m:err m:err nil)
, H# j/ Z6 K6 X' b5 ]- F5 C (princ)
! k+ C9 }" G; T! z% ~: a8 i)0 R9 Y* H' v" }3 B& C! q2 A
;;; Use this if CMDNAMES == CIRCLE
, c. M X. y7 P# V3 a1 V& j(defun ai_circtan (/ pt1 pt2 pt3)
/ w6 K# d* ~2 j/ V/ x k (ai_circtanstart)8 f& K- r8 x! I' w( n
+ u) {! k- z% c; h9 t3 O4 X
(ai_sysvar '("osmode" . 256))" j3 Z. B) L! m0 @
(command "_3p" pt1 pt2 pt3)% A' r1 n/ M$ t$ v: S: x& S8 s
3 ~) }* C* Q+ i
(ai_sysvar nil). A3 @! D; {" R+ t2 h# q
(setq *error* m:err m:err nil)
5 R- q& Q% M# ~ (princ)
: x' `/ a" M3 h& L)+ \6 ]& M$ ?/ k& h* W3 B
5 K5 Z" F. X* g/ w' l; T9 s, k% d! C2 |5 g6 r
0 y8 V9 {: p+ }% V% g;;;=== Make Object's Layer Current =============================
2 n' ?; K9 l( [5 x) b8 b6 k
* k# \7 n1 m# r8 y;; Makes the layer of the selected object current. If there is one
/ |- L' U/ g1 R$ F# y;; object in the pickfirst set, it's layer is made current without! n/ @' H) l* ~
;; prompting for an object. Else a prompt is issued.
+ E' K8 a% v% x( |5 j(defun c:ai_molc(/ old_error end_undo old_cmdecho set1 ent undo_control). v8 m. T8 _# X
9 O+ u4 Y. c+ P6 X6 C3 K6 N ;; Simple error handling.
9 Y/ K/ h6 ?5 ]3 ]9 {! s (defun molc_error (s)
4 P' @7 ]9 a& d1 f) B ;; Reset error handling.
3 m0 R; H- m! g8 u; X, I (if old_error (setq *error* old_error))
# _5 W0 h- f$ u+ w3 c& B! C ;; End undo if we started one.* a* [! b" ~4 T9 w) {' K) m
(if (eq end_undo 1) (command "_.undo" "_end"))
# l* P4 o' H9 Q% j. f% c ;; Reset command echo
( J, n2 O1 l8 S! z, x9 x (if old_cmdecho (setvar "cmdecho" old_cmdecho)); _+ s- T, B2 O( g! t6 V G
;; Silent exit.
* z1 R# N' V' ^" B9 G; t1 H (princ); \% V+ ] x9 B+ l# y# c N
)
: U1 m5 O5 d7 x$ y2 p3 R9 P
: G: g$ \/ f3 S9 i3 L1 C ;; Save current error function.+ L4 v6 ^; O! b. M7 z; P, d) z- l4 z) J
(setq old_error *error*)0 ]% B) M/ w8 |
1 Y9 L# J- A& m1 G8 X1 a
;; Set error handling to molc's error function.$ t5 t5 y+ x! U2 _; p: ]0 S
(setq *error* molc_error)! Q5 S6 F" j0 T0 Q8 I$ s K
& [5 H! `; c( X+ F, }0 ^% ] ;; Save cmdecho setting.6 ]$ ^- B7 p3 A0 n
(setq old_cmdecho (getvar "cmdecho"))
& Z+ H6 q% B1 v9 F ! x" p/ A" ^4 M: h! t0 i
;; Turn off cmdecho
" P$ C; R, D% x$ I! {/ u9 s. S- B (setvar "cmdecho" 0)% d& Z9 ~* c$ E' n7 z: J
" \# f7 b! E- I4 j1 g3 J
;; If Pickfirst is on and the selction set contains 7 W% ?9 ]7 l( `- C
;; one object, then use it, else prompt for one.
( G% A% E u+ ~# A2 h (if (and (eq 1 (logand 1 (getvar "pickfirst")))
% _8 X c. u1 z) p! H' d (setq set1 (ssget "_i"))- M4 u5 R) {' A8 ]8 H! o; m
(eq 1 (sslength set1))
( U' d( s' y& O ) ?# H7 F! b' x1 v
(progn
% b: u+ Z0 N; N: Q; p" A: c6 ?8 o% t (setq ent (entget (ssname set1 0))) / W0 o# A! N+ G/ [% y6 m
(sssetfirst nil nil)! z) \6 X& Y, w2 x: f) {
)
4 x! l, G3 u' F6 S- I (progn
! C# f1 _6 V, l (sssetfirst nil nil); e2 D$ v1 I4 t4 }
(setq ent (entget (car (entsel "\n选择将使其图层成为当前图层的对象: "))))+ N9 o: M y0 c6 V( C: j# P
)$ J% ]( b {% T9 j* c
)
& G' }) }$ B$ Y
( b+ ~! D. R/ x9 m+ x. M- e* g$ E ;; Get undo setting. I4 [9 U7 p6 y( e
(setq undo_control (getvar "undoctl"))% f! ^! {. T+ J0 C8 i% |# |- ^/ v
8 _5 p, Q" {' E
;; Initialize flag to to end undo.( U" {' W4 T% ]0 ~, w
(setq end_undo 0)+ W( e" `0 f$ I0 u
# ]; e' d$ f' V+ o: w+ B
;; Begin Undo group if need be.3 v8 \4 T$ ?( k
(if (and (= 1 (logand 1 undo_control)) ; undo on1 N' Q- S6 M& Q# ^7 N
(/= 2 (logand 2 undo_control)) ; not single undo
8 s9 j8 ?$ J7 O$ k( A% N& _2 R9 _ (/= 8 (logand 8 undo_control)) ; no active group3 O4 |, V" Z; g! b
)
- K- @# D) q7 b% [6 k (progn
* f: }& B# N# h5 h# g$ L4 @; G, A ;; Begin a new one6 A5 }; J _, r& v* p- e1 C; I
(command "_.undo" "_begin") O, G* `, n1 m' g# z
;; Set flag so that we know to end undo.
7 p( S; d* b3 C6 H/ X# l- f (setq end_undo 1)
/ l7 K% X9 \% F% k( e )3 s' B5 R/ K9 V2 z" m
)
) J% u6 I" I: E0 g
) r+ s7 | a9 n4 x) @3 J# ? ;; Make object's layer current.$ j' [; s: r! x S; ^6 V5 g
(setvar "clayer" (cdr (assoc '8 ent)))
4 ]0 m: F- }8 v5 `5 @0 w 1 [( X z; v. F# \1 ^
;; Print message
/ W+ p7 T& a5 W; F1 y! k (princ (strcat "\n" (getvar "clayer") " 现在是当前图层。")). ]! a0 w8 ~- |
* H6 Y* p6 b3 ?! S5 F% u5 f4 I& w0 r
;; Undo end, v; E5 ?0 g' c- h6 k* r
(if (eq 1 end_undo)0 i9 U& |6 r6 p3 ~0 e7 o5 G
(command "_.undo" "_end"); [; o- m+ I/ }3 t Z0 j/ Z3 ^
)5 N4 S$ Y5 d( H3 `* j
2 d; h% C8 x6 l7 x# D& {
;; Turn on cmdecho
( ]& o% F$ z9 X i, K7 } (setvar "cmdecho" old_cmdecho)
' l4 D* ?' P7 ]5 \6 D1 q 8 V r) n0 I7 \" h
;; Reset error function.
C) c6 j4 d% e* [1 \& v% h8 E" M) C (setq *error* old_error); d5 S3 Z0 h) n1 m3 k1 o& L
- l% _# u4 }( ^- l- z
;; Silent exit.
; _, w0 H3 |! V+ X1 ?6 t4 b. G (princ)& V0 O0 ^7 J, k( S4 e3 T+ K
), Y! G: P* G9 P5 Y
0 S7 o. g, m3 O+ t* c% [; {;;; Shortcut menu Deselect All item.
* |5 K6 A) c1 e' O* R- {8 Q6 K2 N5 A
) l3 I8 |" ]$ @: f! \(defun ai_deselect ()
3 T5 k" ?8 e0 j8 N (if (= (getvar "cmdecho") 0) ;start if
# }+ r% P+ m. ?+ s/ a+ X' s9 P0 [ (command "_.select" "_r" "_all" "")
+ ^9 u( [1 V: q( N0 \" M* M (progn ;start progn for cmdecho 1
* ]5 s0 f# f6 b' j7 R (setvar "cmdecho" 0)4 l' S0 S% K# r' r7 P' J- \
(command "_.select" "_r" "_all" "")2 L( k7 j5 |- H' M6 v
(setvar "cmdecho" 1)$ T6 ^% v9 j% s; f
) ;end progn for cmdecho 1
# k9 C4 e4 W) G" b1 o4 w ) ;end if
4 Q% ?6 Y0 ?3 Q; ?5 b (terpri)
) g8 g/ E) J3 X3 C. m (prompt "所有对象都已取消选择")
: @8 f+ J. |, p" t! N( e9 R (princ)
2 B0 @" h3 s7 B" R+ z% H; {)
( }& p5 o" w: a2 R* G* o" \
" q& J8 M* f; F, `0 v# F;;;
' P) k) \( } V- [6 Q: } F: z;;; Enable Draworder to be called from a menu
; v8 o1 Q2 n' t- {7 u, G1 L;;; Checks for Pickfirst selected objects
2 V( H- ]7 {( e8 @- w;;;. ~; N: h' g1 u7 W
. D ^+ W; o1 R* d$ d' s( e
(defun ai_draworder (option / ss )3 G0 d. a2 z" u0 a# g
7 p) h/ S$ C! p
(setq m:err *error* *error* *merr*)' g+ g; G6 Q; N' y; c/ }/ s
(ai_sysvar '("cmdecho" . 0))8 y: |7 N+ Q' H
# s2 G7 q; c5 L6 C7 Q (if (setq ss (ssget "_I"))
8 e7 L. S- y( i, n# O C (command "_.draworder" option)
5 ? j/ X/ ^ `4 V8 M9 c (if (setq ss (ssget))* b" Y! X! G6 b K& [, u. U
(command "_.draworder" ss "" option), s% X1 h$ P* w/ t9 M
)
* J9 o: ]9 Q- I9 I )
; j2 R' r2 r5 z9 E (ai_sysvar NIL)
1 S! ^ G! O5 m" f( B6 @ (setq *error* m:err m:err nil)* _: r$ G0 ]' g
2 R) Q% r' K/ ]+ A# |0 _, R
(princ)
2 \5 s9 W5 i( Q6 B k9 j) L- s/ W)
# j; j+ e8 t* k) K1 a. F0 a* `. @' B4 y2 c. c
(defun c:vlisp ()
# y( l, I8 P9 K% R, o (if (/= nil c:vlide) (c:vlide))9 E0 g* c# O; m! n& C( z: z7 Y: n
)
, P6 `) x& o" Q9 y1 A# Y- T, y6 R* j7 i" t5 y9 O
(princ "已加载。")
6 A: ?' b' P; w(princ) |