Anda di halaman 1dari 181

KS.

NGUYN VN THIP

THIT K TRN MY VI TNH


COMPUTER AIDED DESIGN
--------------- CAD ------------------

Lp trnh ng dng trong


AutoCAD - AutoLISP

TRNG I HC GIAO THNG VN TI

TRUNG TM CNG NGH CAD/CAM

Lp trnh ng dng trong AutoCAD - AutoLISP

Autolisp
I.1. Gii thiu chung
AutoLISP l mt ng dng ca ngn ng LISP -c s dng trong mi
tr-ng AutoCAD. T "LISP" l vit tt ca cm t ting Anh LISt Processor (x l danh sch). LISP l ngn ng lp trnh thuc nhm AI - Artificial
Inteligence (tr tu nhn to) do MacCarthy son tho cui nhng nm 50.
Sau ny -c b sung thm v mang cc tn khc nhau nh- MacLISP, InterLISP, Common LISP v.v...
AutoLISP cng -c hng AutoDesk thay i theo cc s hiu pht
hnh ca AutoCAD. Vi AutoCAD R-14, Autodesk cho ra i Visual
LISP l phn mm son tho AutoLISP v DCL rt tin li cho ng-i lp
trnh. Phn mm ny c a CD ci t ring. n AutoCAD 2000, Visual
LISP -c ci t t ng theo AutoCAD.
V cn bn, nhng phin bn sau vn s dng -c cc ch-ng trnh
lp bng cc phin bn tr-c, ng-c li th khng -c nh-ng cng c mt s
bin h thng v lnh ca AutoCAD gia cc phin bn khng ging nhau
nn vic dng chung c th gp tr ngi. V vy yu cu i vi ng-i lp
trnh AutoLISP phi nm tht vng AutoCAD s dng AutoLISP mt cch
hp l.
AutoLISP l mt ngn ng lp trnh thng dch, ngha l dch n
dng no thc hin dng v cho kt qu, khng c trnh bin dch ring.
Mt tp hp cc cu lnh ca AutoLISP -c gi l hm LISP v tp (file)
cha cc hm gi l tp (file) LISP c phn m rng l .LSP.
Vi AutoLISP, ta c th d dng truy cp n d liu ca AutoCAD,
c th thay i , to mi, xo b cc i t-ng, thm cc thng tin vo bn
v.
I.2. Cc qui -c ca AutoLISP
I.2.1. Cch vit ch-ng trnh AutoLISP
C hai cch vit ch-ng trnh AutoLISP:
I.2.1.1. Vit trc tip:
Ti lnh Command: ca AutoCAD, ta c th g cc cu lnh theo c
php ca AutoLISP. Lnh ny -c thc hin ngay v cho kt qu trn mn
hnh ti vng dng lnh, nh-ng lnh khng -c l-u tr.
V d:
Command: (+ 156 44)
Kt qu php cng -c hin th ngay trn dng nhc: l 200.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

I.2.1.2. Vit thnh ch-ng trnh:


Dng mt ch-ng trnh son tho (dng m ASCII) bt k hoc Visual
LISP (AutoCAD R14, AutoCAD 2000), vit thnh ch-ng trnh nh- mt tp
tin ngun c phn m rng .LSP.
Tn tp tun th theo qui -c ca h iu hnh th-ng khng qu 8 k
t, gia cc k t khng c du cch.
Tp ch-ng trnh c tn l ACAD.LSP m -c t trong th- mc lm
vic ca AutoCAD s -c AutoCAD np mt cch t ng ngay t khi khi
ng.
I.2.2. Cc hm
AutoCAD nhn v x l cc lnh trong hm ca AutoLISP theo c php sau:
Tn hm do ng-i lp trnh nh ngha gm cc ch ci v con s
(tr cc k t c bit nh-: ? < > , . * & ^ % $ # @ ! ~ ' " | \ : [ ] { }
...), khng qu di, nn c tnh gi nh gn vi chc nng d qun
l.
Hm v cu lnh ca AutoLISP -c t trong cp ngoc n. Bt
u bng " ( " v kt thc bng " ) ", nu thiu du ngoc, AutoCAD
s bo li.
Hm -c vit t tri qua phi theo kiu Ba-lan, ngha l phn t u
tin ngay sau du m ngoc phi l tn hm (c sn hay do ng-i lp
trnh t nh ngha) hay ton t. Cc phn t ng sau l cc tham s
cn thit thc hin hm hay ton t .
Phn cch gia tn hm (hay ton t) vi cc tham s, gia cc tham
s vi nhau phi c t nht mt du cch (Space).
Mt cu lnh c th vit trn nhiu dng. Cc dng c th vit tht
vo tu theo cu trc on lnh cho d hiu.
Khng phn bit ch hoa v ch th-ng. Song c qui -c l tn hm
th-ng vit bng ch th-ng, tn cc lnh v cc bin h thng ca
AutoCAD vit bng ch hoa cho d dc v ch-ng trnh sng sa
hn.
Bt k mt hm no cng tr v mt gi tr no , nu khng c gi
tr tr v, tr s mc nh l nil.
Li ch thch trong ch-ng trnh AutoLISP -c ghi sau du " ; ".
Tt c nhng g t sau du " ; " trn mt dng ch c tc dng ghi
ch, khng -c AutoCAD thc hin.
V d:

Php ton
2.0*2.5 + 4.0
x= sin(alpha)

Vit trong AutoLISP

Kt qu

(+ (* 2.0 2.5) 4.0)


(setq x (sin alpha))

9.0
Tu thuc vo alpha.

Ch :
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

+ Cc hm do ng-i dng nh ngha tr-c khi triu gi phi -c nh


ngha.
+ Trong ti liu ny, i vi cc hm ca AutoLISP, cc tham s t trong
cp du ngoc vung [ ] l tu chn (c th c hoc khng).
+ Trong cc v d, tin cho vic gii thch, cc kt qu tr v ca cc
hm -c t sau k hiu -----> ngay trn dng lnh.

I.2.3. Cc bin nh
Cc bin trong AutoLISP hot ng t-ng t nh- cc bin nh ca cc
ngn ng lp trnh khc.
Tn bin gm cc ch ci v cc con s (tr cc k t c bit nh-: ?
< > , . * & ^ % $ # @ ! ~ ' " | \ : { } [ ] ...), nu ch s ng u, tip sau
phi l ch ci trnh nhm vi cc hng s. Tn bin khng nn qu
di.
Khng phn bit ch hoa v ch th-ng, tuy nhin trong ti liu ny,
cc gi tr ca bin nh -c vit bng ch in hoa.
V d mt bin c tn l rd, gi tr ca rd -c ghi l RD.
C hai loi bin nh : Bin chung v bin ring (bin cc b)
+ Bin chung l bin tn ti trong sut qu trnh lm vic ca AutoCAD. Mun bit gi tr tr v ca n, ch cn g !tn_bin trn
dng lnh s c kt qu hin ngay trn dng nhc ca AutoCAD.
+ Bin ring ch tn ti bn trong mt hm. Kt thc hm, bin ny
nhn gi tr nil.
Cc bin tr-c khi tham gia vo cc biu thc phi -c gn gi tr
hoc nh ngha, nu khng s b li.
I.3. cc Kiu d liu c bn
Cc kiu d liu -c dng trong AutoLISP bao gm:
I.3.1. Kiu danh sch (list)
y l kiu c tr-ng ca ngn ng LISP. N l nhm cc gi tr
ring l gm cc bin, cc hng s, cc hm,... cch nhau bng
khong trng nm trong cp du ngoc n.
V d:
(1.0 2.5 0.0)
(a 13.5 "ABC" -54).

To im trong AutoCAD cng l mt danh sch gm cc phn


t l s thc (X Y Z) hoc (X Y).
Dng thc c bit l danh sch Cp c chm (dotted pair)
-c s dng ph bin trong AutoLISP khi t chc v qun l d
liu. Cp ch c hai thnh phn, gia hai thnh phn l du chm (.).
V d:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(-1 . <Entity name: 60000014>); -1 m ch tn i t-ng.
(0 . "LINE")
; 0 m ch loi ca i t-ng.
(8 . "0")
; 8 m ch tn lp cha i t-ng.
(5 . "2D")
; 5 th t ca i t-ng.

K hiu hon tr ca AutoLISP:

"LIST".

I.3.2. Kiu s nguyn (Int)


Kiu nguyn l s nguyn thng th-ng trong ton hc. Trong AutoLISP gii hn ca s nguyn l t -32768 n +32767.
Cc php tnh trn s nguyn cho kt qu l mt s nguyn, nu l
php chia th-ng s l s nguyn, phn d- nu c s b ct b.
V d:
(/ 9 2) cho kt qu l 4.
K hiu hon tr ca AutoLISP:
"INT".
I.3.3. Kiu s thc (Real)
Kiu s thc trong AutoLISP c chnh xc gp i, s ch s c
ngha sau du phy thp phn l 14.
Cch vit mt s thc: 4.0 0.0 hoc 0.435 (nu vit 4. hoc
.435 l sai, cc s trn khng -c coi l s thc (Real).
K hiu hon tr ca AutoLISP:
"REAL".
I.3.4. Kiu chui k t (String)
Chui k t l tp hp cc k t bt k k c du cch t trong du
ngoc kp " ". Trong AutoLISP, chui di khng qu 132 k t.
V d: "String", "y l AutoLISP", ...
Mt s k t c bit dng trong chui km theo du \ c chc
nng ring s trnh by phn sau.
K hiu hon tr ca AutoLISP:
"STR".
I.3.5. Kiu k hiu (Symbol)
Cc Symbols dng m t cc k t (hay chui k t) dng
ASCII m cc k t hay chui cha ng mt thng tin no .
Tn ca cc Symbol l cc ch ci hoc s tr cc k t l du
ngoc n ( ), du chm . , du phy trn ', du chm phy ;, du
nhy kp ''.
V d: (set'dd 'hh) th gi tr ca dd l HH (Symbol).
K hiu hon tr ca AutoLISP:
"SYM".
Kiu ny dng c li khi mun to mng trong AutoLISP.

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

I.3.6. Kiu i t-ng (AutoCAD Entity)


Mi i t-ng -c v trong AutoCAD u -c qun l theo tn
(ENAME - Entity Name). Mi tn i t-ng s l-u tr ton b
thng tin v i t-ng .
K hiu hon tr ca AutoLISP:
"ENAME".
I.3.7. Kiu nhm i t-ng (AutoCAD selection set)
y l kiu c tr-ng cho tp hp cha cc ENAME ca cc i
t-ng b la chn.
Ta c th ly ENAME ca mt i t-ng trong tp hp cc i t-ng -c chn.
K hiu hon tr ca AutoLISP:
"PICKSET".
I.3.8. Kiu tp (File)
Tn cc tp tin -c to ra trn a c hoc ghi d liu.
K hiu hon tr ca AutoLISP:
"FILE".
I.3.9. Kiu hm chun ca AutoLISP
y l cc hm chun c ngay trong AutoLISP.
K hiu hon tr ca AutoLISP:
"SUBR".
I.3.10. Kiu hm ngoi
Cc hm -c to ra bng cc ngn ng khc (nh- C, C++, Visual
Basic,...) v thc hin -c trong AutoCAD.
K hiu hon tr ca AutoLISP:
"EXSUBR".
I.3.11. S PI v Nil
S PI trong ton hc -c k hiu trong AutoLISP l pi v nhn
gi tr khng i l 3.1415926. Pi tham gia vo cc biu thc ton
hc v l s o gc bng Radian.
Nil l mt k hiu ch ra rng bin hay hm khng c gi tr
hoc biu thc lgc nhn gi tr khng ng.
I.4. Hm do ng-i lp trnh nh ngha
Cc hm ny t-ng t nh- Hm (Function) trong ngn ng C v
C++, nh- Th tc (Procedure) trong PASCAL, hoc nh- Hm con
(Subroutine) trong FORTRAN.
C php:

(defun tn_hm(tham s /
;......... thn hm
)

bin_s_ring)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

hoc:
(defun tn_hm( )
;...... thn hm
)
gii thch:

defun:
T kha nh ngha hm ca AutoLISP.
Tn_ hm:
Do ng-i lp trnh t, theo qui -c chung (khng c du
cch, khng c ting Vit hoc cc k t c bit).
Cc tr-ng hp c bit ca tn hm:
1-Tn hm tr thnh mt lnh ca AutoCAD:
(defun C:TN_HM( .......)
;...... thn hm
)
Trong C:TN_HM l ch in hoa.
2- Hm -c thc hin ngay sau khi khi ng AutoCAD:
Hm ny phi nm trong tp ACAD.LSP t trong th- mc lm vic ca
AutoCAD, c c php sau:
(defun S::STARTUP()
;...... thn hm
)
Tham s:
+ L mt hoc nhiu bin hnh thc, cc bin ny chnh l bin chung
cho c ch-ng trnh, tham gia vo cc biu thc trong thn hm v -c
tn ti n khi thot khi AutoCAD.
+ Khi triu gi, cc bin hnh thc -c thay bng cc gi tr.
+ C th khng c tham s.
Bin_s_ring:
+ C mt hay nhiu bin s, phn cch bng du trng.
+ Cc bin s ny -c nhn gi tr hoc nh ngha v ch tn ti bn
trong hm, khi ra khi hm, gi tr cc bin ny cng b xo khi b nh.
Hm khng c c tham s ln bin ring, th cc bin s ca n mc
nhin l bin chung.
Thn hm:
L cc lnh x l ca AutoLISP.
Mt hm c th triu gi nhiu hm khc.
V d:
1- (defun factorial(x y)
;....... cc lnh x l vit y.
)

Hm ny c 2 tham s x v y.
Hm -c triu gi nh- sau:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(factorial

B)

A v B l hai gi tr hoc hai bin -c nhn gi tr.


2-

(defun fact(/ a b)
;........thn hm
)

Hm ny c 2 bin ring l a v b.
Hm -c triu gi nh- sau:
3-

(fact)
(defun
br1(a /
;.......
)

d e)

Hm c mt tham s v 3 bin ring.


Hm -c triu gi nh- sau:
(br1 5.0)

5.0 l gi tr ca a.
4-

(defun match()
;..........
)

Hm khng c tham s v bin ring.


Hm -c triu gi nh- sau:
(match)
5- Tn hm l mt lnh ca AutoCAD:
(defun C:TRUC()
; ...... cc lnh tnh ton v v mt ci trc t
y.
)

Khi ch-ng trnh AutoLISP cha hm trn -c gi vo AutoCAD th


"truc" l mt lnh ca AutoCAD, c th gi trn dng lnh:
Command: truc
Cc lnh ca hm truc() -c thc hin.
Ch :
1- Gi hm ny trong AutoLISP phi vit (C:TRUC)
2- Nu hm ny c tham s th khng th gi nh- ra lnh ca AutoCAD
-c, phi gi nh- AutoLISP vi tham s km theo.
V d: Hm (defun C:OBI(a b)
;..........
)
Khi gi trn dng lnh:
Command: (obi 5 13)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5. Cc hm chun ca Autolisp


I.5.1. Php gn
I.5.1.1. Hm (setq.......)
Chc nng:

Gn gi tr cho mt bin.
C php:

(setq bin1 gi_tr1 [bin2 gi_tr2] ..)


gii thch:

Gn gi_tr1 cho bin1, gn gi_tr2 cho bin2 ......


Mi bin nhn mt gi tr vit sau n.
Gi tr c th l d liu, mt bin khc hoc mt biu thc xc nh
tr-c .
xo mt bin s khi b nh, ta dng:
(setq bin Nil )
AutoCAD thc hin cc lnh ca AutoLISP m khng hin th cc
dng lnh thc hin trn mn hnh ta gn 0 cho bin h thng
CMDECHO bng lnh:
(setq cmdecho 0)
Cui ch-ng trnh nn c lnh:
(setq cmdecho 1)
tr li gi tr ngm nh cho bin CMDECHO.
V d:
(setq
(setq
(setq
(setq
(setq

x1 15.3)
---> x1 = 15.3
x1 38)
---> x1 = 38
x2 x1)
---> x2 = x1
x3 (+ x1 x2))---> x3 = x1+x2
m1 "Chc mng" k2 18.6)
---> m1 = "Chc mng",

k2 =18.6

I.5.1.2. Hm (set .......)


Chc nng:

Gn tn bin cho mt bin.


C php:

(set

'bin1

'bin2)

gii thch:

Gn tn bin2, cho bin1


Mi khi ly gi tr ca bin1 th thc cht l ly gi tr ca bin2.
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


V d:
(setq hh 15.0)
(set 'dd 'hh)
(eval dd)
;kt qu tr v

---->

15.0

I.5.1.3. Hm (setvar .......)


Chc nng:

Gn gi tr cho mt bin h thng.


Tn v chc nng ca cc bin h thng xem trong ph lc II.
C php:

(setvar varname value)


gii thch:

varname
value

chui k t l tn bin h thng.


gi tr cn gn.

V d:
(setvar "FILLETRAD" 20.50)

---->

20.5

I.5.2. Cc hm chuyn lnh t AutoLISP sang AutoCAD


I.5.2.1. Hm (Load.....)
Chc nng:

Triu gi mt ch-ng trnh ng dng vo AutoCAD.


C php:

(load

"tn_tp")

gii thch:

Tn_tp l tn tp tin c phn m rng .LSP (AutoLISP), .ARX ,


.ADS hoc .EXE (Ch-ng trnh ADS, ARX).
Nu ch-ng trnh t ngoi th- mc lm vic ca AutoCAD th phi ch
r -ng dn.
Hm ny c th vit trong tp AutoLISP hoc dng nh- mt lnh
ca AutoCAD:
+ Trn dng lnh:
Command: (load "tn_tp")

+ Trn Menu:
[Tools] [Load Application]

Hp thoi xut hin:

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

10

Lp trnh ng dng trong AutoCAD - AutoLISP

Nhn nt File chn tn tp tin cn gi vo, nhn OK kt thc lnh.


I.5.2.2. Hm (Command.....)
Chc nng:

Thc hin cc lnh ca AutoCAD.


C php:

(command "tn_lnh" [cc p ng li nhc]


["cc tu chn"] ...)
gii thch:

Tn_lnh:
Cc p ng li nhc v
"Cc tu chn":

L tn cc lnh ca AutoCAD.
Tun theo cc lnh ca AutoCAD.

v d:

V vng trn c tm ti im (30,30) bn knh 40:


(command "CIRCLE" '(30.0 30.0) 40.0)
Hoc d-i dng t-ng -ng:
(command "CIRCLE" "30.0,30.0" "40.0")
Ch :
1- Cp du ngoc "" hoc mt du trng (Space) trong hm (command.....) t-ng t nhn ENTER trn dng lnh ca AutoCAD.
V d: (command "LINE" pt1 pt2 "")
2-(command)
t-ng t Ctrl + C.
3- Tham s PAUSE hoc hai du "\\" -a vo hm (command.....) c tc
dng tm ngng ch-ng trnh, ch x l ca ng-i dng sau li tip tc.
V d: v vng trn c tm ti (5,5), sau khi xc nh tm, ch-ng trnh
dng li ch ng-i dng nhp bn knh sau v tip on thng.
(command "CIRCLE" "5.0,5.0" PAUSE "LINE" "3.0,4.0" "6.0,7.0" "")
(command "CIRCLE" "5.0,5.0" "\\" "LINE" "3.0,4.0" "6.0,7.0" "")

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

11

I.5.3. Cc hm nhp d liu t ng-i dng


Cc hm sau y s tm dng ch-ng trnh yu cu ng-i dng nhp
d liu vo (t bn phm hoc chut).
I.5.3.1. Hm (getpoint .....)
Chc nng:

Ch ng-i dng nhp to mt im.


Kt qu: LIST
C php:

(getpoint [point][prompt])
gii thch:

Point

Nu c, cho bng mt danh sch to im, l im th nht, cn


im ng-i dng nhp vo s l im th hai. Trn mn hnh xut
hin si dy ni im th nht vi im th hai. im th hai c th
cho bng ta t-ng i.
Prompt Nu c, l dng nhc hoc gii thch v d liu s nhp. Dng nhc
phi t trong ngoc kp " ".
+ Gp dng lnh ny, AutoCAD hin dng nhc prompt trn dng
lnh v i ng-i dng nhp ta mt im.
v d:
(setq pt1 (getpoint

"Cho tm -ng trn:"))

Kt qu trn dng nhc:


Cho tm -ng trn:
Hoc:
(setq
---->
(setq
---->

pt2 (getpoint '(1.5 2.0) "Where secon point?:"))


Where second point?:
pt2 (getpoint pt1 "Cho im th hai:"))
Cho im th hai:

I.5.3.2. Hm (getcorner ....)


Chc nng:

Ch ng-i dng nhp to mt im ging nh- getpoint. Tuy


nhin, getcorner i hi phi c 1 im c s v s v mt khung ch
nht nh- khi chn i t-ng bng Window ca AutoCAD.
Kt qu: LIST
C php:

(getcorner

point

[prompt])

gii thch:

Point
Prompt

Bt buc phi c, l danh sch (LIST) to im th nht, cn


im ng-i dng nhp vo s l im th hai.
Nu c, l dng nhc ging nh- trong getpoint.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

12

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.3.3. Hm (getdist ....)


Chc nng:

Ch ng-i dng nhp vo:


+ Mt s thc l mt khong cch.
+ Ta ca 1 hoc 2 im.
Nu nhp to im, AutoLISP hon tr khong cch gia hai im.
Kt qu: REAL
C php:

(getdist

[pt] [prompt])

gii thch:

Pt

Nu c, l danh sch (LIST) ta im, vic nhp s liu ging


nh- getpoint.
Nu c, l dng nhc hoc gii thch v d liu s nhp.

Prompt

V d:
(setq d1 (getdist "Cho bn knh:"))

Kt qu hin trn dng nhc:


Cho bn knh:
+ Nhp vo mt s thc, hoc:
+ Nhp to 1 im, dng nhc tip theo xut hin:
second point:
tip tc nhp ta im th hai ly khong cch gia
hai im va nhp.
+ C th dng dng nhc chung cho ng-i dng d hiu nh- sau:
(setq d1 (getdist "Nhp gi tr bn knh hoc cho to
im th nht:"))

+ C dng im u lm gc:
(setq p3 '(12.5 26))
(setq d3 (getdist p3 " Cho bn kinh:"))

hoc:
(setq d3 (getdist

'(3

5)

" Cho bn kinh:"))

Kt qu trn mn hnh hin si dy ni t im c to P3 hoc im


c ta (3,5) n im th hai gn vi con tr v hin trn dng nhc:
Cho bn knh:
Ng-i dng bt buc nhp ta im th hai.
Kt qu d3 nhn gi tr khong cch gia 2 im.
I.5.3.4. Hm (getangle ....)
Chc nng:

Ch ng-i dng nhp vo:


+ Mt s thc l s o bng ca gc hoc cung trn .
+ Ta ca 1 hoc 2 im.
Nu nhp to im, AutoLISP hon tr gi tr gc nghing gia on
thng ni hai im so vi ph-ng nm ngang.
Kt qu: REAL (s o tr v l Radian).
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

13

C php:

(getangle

[pt] [prompt])

gii thch:

Nu c, ging nh- getpoint.


Nu c, l dng nhc hoc gii thch v d liu s nhp.

Point
Prompt

V du:
(setq goc1 (getangle " Cho gc 1:")) hoc:
(setq goc2 (getangle '(3 5) " Cho gc 2:"))

I.5.3.5. Hm (getorient ....)


Chc nng:

Ging nh- getangle , nh-ng gi tr tr v ca getorient b cc


bin ANGDIR v ANGBASE chi phi.
+ C th phn bit gia getangle v getorient nh- sau:
getangle tr v tr s (s o ln) ca mt gc (gc t-ng i).
getorient
tr v v tr ca cnh th hai ca gc so vi h to
tuyt i (gc tuyt i).
Kt qu: REAL (s o tr v l Radian).
C php:

(getorient [pt] [prompt])


gii thch:

Nu c, ging nh- getpoint.


Nu c, l dng nhc hoc gii thch v d liu s nhp.

Point
Prompt

V d:
(setq goc1 (getorient " Cho gc 1:"))

Trn dng nhc xut hin:


Cho gc: ng-i dng nhp s tu , v d: 90
+ Nu ti lnh UNITS ta t ANGBASE = 0.0 (h-ng 3 gi) v ANGDIR = 0 (h-ng pht trin ng-c chiu kim ng h), kt qu tr v:
goc1 = 1.5708radian (pi/2) nh- getangle
+ Nu ANGBASE = 90.0 (h-ng 12 gi), ANGDIR = 1, kt qu tr v:
goc1 = 0.0radian.
I.5.3.6. Hm (getint ....)
Chc nng:

Ch ng-i dng nhp vo mt s nguyn.


Kt qu: INT
C php:

(getint [prompt] )
gii thch:

Prompt

Nu c, l dng nhc hoc gii thch v d liu s nhp.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

14

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.3.7. Hm (getreal ....)


Chc nng:

Ch ng-i dng nhp vo mt s thc .


Kt qu: REAL.
C php:

(getreal [prompt] )
gii thch:

Prompt

Nu c, l dng nhc hoc gii thch v d liu s nhp.

I.5.4. Hm (iniget ....)


Chc nng:

Kim sot cc kiu gi tr nhp vo t ng-i dng cho cc hm nhp s liu


h getxxx. Hm ny, nu dng phi t tr-c cc hm nhp s liu h
getxxx cn khng ch.
C php:

(initget

m_s

["chui_nh_dng"])

gii thch:

M_s
M s
0
1

2
4
8
32
64
128

Gi tr m_s kim sot cch nhp s liu vo. Gi tr m_s v


cc hm chu tc ng cho trong bng sau:
Chc nng kim sot
Hm chu tc ng
Bnh th-ng hon tr NIL nu g ton b cc hm getxxx (tr
ENTER m khng nhp g c.
getstr hon tr chui rng "")
Khng cho php ng-i dng g getint,getreal,
getdist,getangle,
ENTER khi ch-a nhp s liu.
getorient,getpoint,
getcorner,getkword
getint,getreal,
Khng cho php nhp s 0
getdist,getangle,
getorient
getint,getreal,
Khng cho php nhp s m
getdist
Cho php nhp ta im nm getpoint, getcorner
ngoi LIMITS ca bn v
S dng kiu nt t (thay cho getdist,getangle,
getorient,getpoint,
nt lin) khi hin ca s tm
getcorner
Khi nhp to hai im ly khong cch getdist
2 chiu, khng quan tm n ta Z
Kt qu l nhng g ng-i dng getint,getreal,
nhp vo (nu khng dng kiu getdist,getangle,
getorient,getpoint,
th tr v chui k t)
getcorner, getkword

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

15

Nu m s c gi tr l tng ca mt s gi tr trong bng th chc nng kim


sot s l tng cc chc nng.

Chui_nh_dng L mt chui k t dng lm t kho h tr cho cho cc


hm getxxx c cc tu chn khi nhp s liu.
+ Mi t kha cch nhau mt du trng.
+ Cc ch ci vit hoa lin nhau trong t kho s l du hiu ca t
kha. Khi nhp s liu, ng-i dng g theo cc ch ci vit hoa la chn.
+ Nu tt c cc ch ci trong t kho u vit hoa th cc t kho cch
nhau bng du phy( , ).
V d:
v d 1:
(iniget 1)
(setq l1 (getdist " Cho bn knh:

"))

Trn dng nhc xut hin:


Cho bn knh: Nu ng-i dng g ENTER m khng nhp g c s c dng
thng bo: Requires numeric distance or two points.
Cho bn knh:
i ng-i dng nhp mt s liu, ch-ng trnh mi tip tc thc hin.
v d 2:
(iniget 7)
(setq l1 (getdist " Cho khoang cach:

"))

Trn dng nhc xut hin:


Cho khong cch:
M s trong hm initget l 7 = 1+ 2 + 4 nh- vy d liu nhp vo s l:
1- Khng cho php ng-i dng g ENTER khi ch-a nhp s liu.
2- Khng cho php nhp s 0.
3- Khng cho php nhp s m.
Nu ng-i dng phm vo mt trong 3 iu trn, dng thng bo xut hin:
Value must be positive an nonzero
Cho khong cch:
i ng-i dng nhp mt s liu ng, ch-ng trnh mi tip tc thc hin.
v d 3:
(iniget 1 "DAi ROng " )
(setq l1 (getdist " DAi/ROng/<Cho -ng cho>:"))

Trn dng nhc xut hin:


DAi/ROng/<Cho -ng cho >: Ta c th nhp s thc hoc cc ch ci DA hoc RO.
I.5.4.1. Hm (getkword ....)
Chc nng:

Ch ng-i dng nhp vo mt k t hoc mt chui k t lin nhau, khng


c du trng.
Kt qu: STR.
C php:

(getkword [prompt])
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

16

Lp trnh ng dng trong AutoCAD - AutoLISP

gii thch:

+ Hm ny lun t sau hm initget, nu chui nhp vo khng trng vi


t kho trong hm initget tr-c , getkword yu cu nhp li.
+ Hm ny tin dng khi mun ng-i dng nhp vo cc la chn.
Prompt Dng nhc nn ch r cc t kho ng-i dng d nhp d liu.
V d:
(initget "LAyer LType Color")
(getkword " Nhp cc la chn: LAyer/LType/Color:")

Trn dng nhc xut hin:


Nhp cc la chn : LAyer/LType/Color:Ta ch nhp cc ch ci:
LA
kt qu tr v "layer"
LT
kt qu tr v "ltype"
C
kt qu tr v "color".
I.5.4.2. Hm (getstring ....)
Chc nng:

Ch ng-i dng nhp vo mt chui k t. Nu chui di hn 132 k t, hm ch ly 132 k t.


Kt qu: STR.
C php:

(getstring

[cr] [prompt])

gii thch:

Cr + Nu khng c hoc nhn gi tr Nil, khng -c nhp du trng, nu


g du trng t-ng -ng g ENTER kt thc nhp.
+ Nu c gi tr khc Nil, cho php nhp c du trng. Kt thc nhp
phi g ENTER.
Prompt
Dng nhc.
V d:
(setq s (gettring "Nhp tn")); ch nhp chui cc k t lin
nhau, khng c du cch.
(setq s (gettring T "Nhp h v tn"));cho php nhp c du cch.

I.5.4.3. Hm (getvar ....)


Chc nng:

Ly gi tr hin hnh ca bin h thng (xem Ph lc II - Bin h thng trong AutoCAD).


C php:

(getvar varname)
gii thch:

varname Tn bin h thng.


V d:
(getvar "FILLETRAD")

---->

0.25 (nu tr-c FILLETRAD nhn gi tr l


0.25.

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

17

I.5.5. Cc hm ton hc
I.5.5.1. Cc php tnh
Chc nng:

Thc hin cc php tnh s hc thng th-ng.


C php:

Cch vit chung cho cc php tnh nh- sau:


(php_ton tham_s1 [tham_s2] ... )
gii thch:

Php ton

l cc php tnh s hc thng th-ng:


Php cng:
+
Php tr:
Php nhn:
*
Php chia:
/
Php tng thm 1: 1+
Php gim i 1:
1Tham_s1 Trong cc php tnh tr v chia, tham_s1 l s b tr hoc b
chia.
Tham_s2 .... Trong cc php tnh tr v chia, tham_s2 .... l cc s tr
hoc s chia.
Trong cc php tng thm 1 v gim i 1 ch c mt tham s.
Ch :
Tham s c th l: hng s (nu l s m, du - vit lin vi hng s), bin
s hoc biu thc.
Kt qu ph thuc vo kiu ca cc tham s tham gia php tnh.
v d:
(+
(+
(((*
(/
(/
(1+
(1-

1 2.0)
1 -3 4)
6 3 1)
7.56)
2.0 3)
5 2)
5.0 2.0)
4)
4)

----> 3.0
----> 2
----> 2
----> -7.56
----> 6.0
----> 2
----> 2.5
----> 5
----> 3

I.5.5.2. Cc php so snh


Chc nng:

Thc hin cc php so snh trong cc biu thc lgc.


Kt qu: cho T (ng) hoc Nil (sai).
C php:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

18

Lp trnh ng dng trong AutoCAD - AutoLISP

Cch vit chung cho cc php tnh nh- sau:


(php_so_snh tham_s1 [tham_s2] ... )
gii thch:

Php so snh:

l cc php lgc sau:


Bng:
=
Khng bng (khc):
/=
Ln hn:
>
Ln hn hoc bng:
>=
Nh hn:
<
Nh hn hoc bng:
<=
Php V lgc:
and
Php Hoc lgc:
or
Php ph nh:
not
Tham_s1, Tham_s2 : l cc i t-ng so snh.
Ch :
Tham s c th l hng s, bin s hoc biu thc.
Ring i vi s thc, my tnh coi s 0 ch l xp x 0 nn khi dng du =
so snh vi 0 c th tr ra gi tr nil. Nn dng (equal ....) so snh.
v d:
(> 5 3)
(>= 8.3 8.0)
(< 6.5
3.0)
(/= "A" "T")
(and "A"
nil)
(or "A"
nil)
(not 1)

----> T
----> T
----> nil
----> T
----> nil
----> T
----> nil

I.5.5.3. Hm (eq ... )


Chc nng:

Thc hin so snh xem hai tham s c thc s bng nhau hay khng.
Kt qu: cho T (ng) hoc nil (sai).
C php:

(eq

tham_s1 tham_s2)

gii thch:

Kt qu ch ng khi tham_s1 ging ht tham_s2.


v d:
(eq
(eq
(eq

2 2)
----> T
2 2.0)
----> T
'( 2 3 4) '(2 3 4))
----> nil v y l hai danh
sch khc nhau.
(setq f '(2 3 4))
(eq f '(2 3 4))
----> nil

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(setq f '(5 6 7))
(setq f1 f)
(eq f f1)
(eq (+ 2 4) (* 2 3))

19

----> T
----> T

I.5.5.4. Hm (equal ... )


Chc nng:

Thc hin so snh xem hai tham s c bng nhau hay khng theo tiu
chun l chnh xc km theo.
Kt qu: cho T (ng) hoc Nil (sai).
C php:

(equal

tham_s1

tham_s2

[_chnh_xc])

gii thch:

Kt qu ch ng khi tham_s1 bng tham_s2 vi sai s l _chnh_xc (nu


c).
v d:
(equal 2 2)
(equal 2.0 2.1 0.1)
(equal 2.0 2.2 0.1)
(equal '( 2 3 4) '(2 3 4))
(setq f '(2 3 4))
(equal f '(2 3 4))
(setq f '(2 3 4))
(setq f1 f)
(equal f f1)
(equal (+ 2 4) (* 2 3))

---->T
---->T
---->nil
---->T
---->T

---->T
---->T

I.5.5.5. Hm (max ... )


Chc nng:

Tm gi tr ln nht trong mt dy cc tham s.


Kt qu: tr v gi tr ln nht.
C php:

(max
v d:
(setq
(setq
(setq
(setq
(setq

tham_s1 tham_s2 [tham_s3] ....)


d1 4)
d2 5.6)
g 7.4)
m1 (max d1 g d2))
n2 (max 2.3 1.2 6.4 5))

---> 7.4
---> 6.4

I.5.5.6. Hm (min ... )


Chc nng:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

20

Lp trnh ng dng trong AutoCAD - AutoLISP

Tm gi tr nh nht trong mt dy cc tham s.


Kt qu: tr v gi tr nh nht.
C php:

(min
v d:
(setq
(setq
(setq
(setq
(setq

tham_s1 tham_s2 [tham_s3] ....)


d1 4)
d2 5.6)
g 7.4)
m1 (min d1 g d2))
n2 (min 2.3 1.2 6.4 5))

---> 4
---> 1.2

I.5.5.7. Hm (gcd ... )


Chc nng:

Tm -c s chung ln nht ca cc tham s kiu s nguyn.


C php:

(gcd
v d:
(setq
(setq
(setq
(setq
(setq

int1 int2 [int3] ....)


d1 15)
d2 12)
g 24)
u1 (gcd d1 g d2))
u2 (gcd 18 10))

---> 3
---> 2

I.5.5.8. Hm (rem ... )


Chc nng:

Tm phn d- trong php chia hai tham s.


Kt qu: tr v s d-.
C php:

(rem

tham_s1 tham_s2 )

gii thch:

Tham_s1 l s b chia kiu nguyn (int) hoc thc (real).


Tham_s2 l s chia kiu nh- tham_s1
v d:
(setq
(setq
(setq
(setq
(setq

d1
d2
m1
m2
m3

15)
6)
(rem d1 d2))
(rem 15.6 4.0))
(rem 15.0 3.0))

---> 3
---> 3.6
---> 0.0

I.5.5.9. Cc hm i s:
C php:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

(sqrt

number)

21

;Ly cn bc 2 ca s thc number


( x)

(expt

c_s

s_m) ;Ly lu tha bc s_m ca s

thc c_s (ax)


(exp s_m);Ly lu tha bc s_m ca s e (ex)
(abs number);Ly gi tr tuyt i ca 1 s number | x|
(log number);Ly lgarit c s e ca 1 s number ln(x)
v d:
(setq d1 1.5)
(setq d2 6)
(setq m1 (sqrt d2))
(setq m2 (expt d2 d1))
(setq u1 (expt 4 1.6))
(setq u2 (exp 2.3))
(abs -56)
(log 2.0)

--->
--->
--->
--->
--->
--->

2.44949
14.69969
9.18959
9.97418
56
0.6931

I.5.5.10. Cc hm l-ng gic:


C php:

(sin angle)
;SIN(angle)
(cos angle)
;COS(angle)
(atan num1 [num2])
;ARCTANG(num1)
;hoc
ARCTANG(num1/num2)
gii thch:

Angle
L s o ca gc cho bng radian.
Num1, num2 l s thc.
Kt qu tr ra ca hm ATAN l gc c s o bng radian.
v d:
(setq
(setq
(setq
(setq
(setq

g1 1.5)
m1 (sin g1))
m2 (cos (/ pi 3.0)))
goc1 (atan 4))
goc2 (atan 1.0 8.0))

--->
--->
--->
--->

0.997495
0.5
1.32582 radian
0.124355 radian

I.5.5.11. Hm (polar ...)


Chc nng:

Ly ta ca mt im theo mt im c.
C php:

(polar

pt1

angle dist)

gii thch:

pt1

L im c dng lm gc ly im tip theo.


Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

22

Lp trnh ng dng trong AutoCAD - AutoLISP

angle

Gc nghing ca on ni im gc v im tip theo. Gc cho


bng radian, chiu tng ng-c chiu kim ng h.
L s thc ch khong cch gia im gc v im tip theo .

dist

v d:
(setq pt1 '(1.0 1.0))
(setq pt2 (polar pt1 (/ pi 5.0) 4.0))
---> im pt2 nm cch pt1 1 on di 4 n
v v on PT1PT2 nghing vi phng ngang
mt gc pi/5. Ta pt2 (4.23607 3.35114 0.0).
(setq pt3 (polar '(2.0 3.0 0.0) 0.785398 2.0)
---> tng t, ta pt3 (3.41421 4.4121 0.0).

I.5.5.12. Hm (angle ...)


Chc nng:

Tnh gc gia mt on thng vi trc OX.


Kt qu: tr v s o ca gc tnh bng radian.
C php:

(angle

pt1 pt2)

gii thch:

pt1, pt2

L 2 im.

v d:
(setq
(setq
(setq
(setq

pt1 '(1.5 3.0))


pt2 '(6.0 4.0))
goc1 (angle pt1 pt2))
goc2 (angle '(5 5) '(7 7)))

---> 0.218669
---> 0.785398

I.5.5.13. Hm (distance ...)


Chc nng:

Xc nh khong cch gia hai im.


Kt qu: tr v mt s thc (REAL).
C php:

(distance

pt1 pt2)

gii thch:

pt1, pt2

L 2 im cho tr-c.

v d:
(setq pt1 '(1.5 3.0))
(setq pt2 '(6.0 4.0))
(setq d1 (distance pt1 pt2))

---> 4.60977

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

23

I.5.5.14. Hm (inters ...)


Chc nng:

Tm giao im gia hai on thng.


Kt qu: tr v l to ca giao im.
C php:

(inters

pt1 pt2 pt3 pt4 [tham_s])

gii thch:

pt1, pt2
pt3, pt4
tham_s

L 2 im u mt ca on th nht.
L 2 im u mt ca on th hai.
+Nu khng cho hoc cho gi tr khc Nil, AutoCAD ch tm
giao im thc s nm trn hai on thng cho.
+ Nu cho bng Nil, AutoCAD s coi hai on thng l di v
tn v giao im c th nm ngoi hai on thng cho.

v d:
(setq
(setq
(setq
(setq
(setq
(setq

pt1
pt2
pt3
pt4
pg1
pg2

'(1.0 1.0))
'(6.0 6.0))
'(1.0 3.0))
'(6.0 3.0))
(inters pt1 pt2 pt3 pt4)) ---> (3.0 3.0)
(inters '(5 5) '(7 7) '(3 1) '(6 1) nil))
---> (1.0 1.0)

I.5.5.15. Hm (osnap ...)


Chc nng:

Bt vo cc im c bit.
Kt qu: tr v l to im cn tm.
C php:

(osnap

pt1 mode)

gii thch:

pt1
mode

L im nm trn i t-ng c cc im cn tm.


L chui k t ch tn vit tt ca cc im c bit, -c -a
vo d-i dng sau:
"non"
NONe
"end"
ENDpoint
"mid"
MIDpoint
"cen"
CENter
"nod"
NODe
"qua"
QUAdrant
"int"
INTersection
"ins"
INSertion
"per"
PERpendicular
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

24

Lp trnh ng dng trong AutoCAD - AutoLISP

"tan"
"nea"
"qui"
"app"

TANgent
NEArest
QUIck
APParent Intersection ; dng cho 3D

v d:
(setq pt1 '(0.0 1.0))
(setq pt2 '(6.0 6.0))
(setq pt3 '(1.0 3.0))
(setq pt4 '(6.0 3.0))
(setq pt5 '(7.0 1.0))
(command "line" pt1 pt2 "")
(command "pline" pt3 pt4 pt5"")
(command "circle" "3p" pt1 pt2 pt3)
(setq o1 (osnap pt1 "mid"))
---> (3.5 3.5 0.0)
(setq o2 (osnap pt2 "cen"))
---> (6.92857 -1.21429
0.0)

I.5.6. Cc hm to cu trc iu khin


I.5.6.1. Hm (if ....)
Chc nng:

Ra iu kin thc hin mt s lnh.


C php:

(if testexpr thenexpr [elseexpr])


gii thch:

testexpr
thenexpr
elseexpr

L biu thc kim tra iu kin.


Biu thc (lnh) -c thc hin nu testexpr nhn gi tr T.
Biu thc (lnh) -c thc hin nu testexpr nhn gi tr
nil. Nu khng c biu thc ny, hm khng thc hin g c v
tr v nil.

V d:
(if (= 1
(setq am
(setq am
)
(if (= 2
(setq am
)
(if (= 2
(setq am
)

3)
"YES!!")
"no.")
--->

"no."

--->

"YES!!"

--->

nil

(+ 1 1))
"YES!!")
(+ 3 4))
"YES!!")

I.5.6.2. Hm (cond ....)


Chc nng:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

25

Ra mt lot iu kin thc hin mt lot lnh km theo.


C php:

(cond (test1result1...)[(' T resultn)]...)


gii thch:

test1
L biu thc kim tra iu kin.
result1 Biu thc (lnh) -c thc hin nu test1 nhn gi tr T.
'T
Nu c, thc hin resultn khng ph thuc vo iu kin no c.
C th c nhiu (test1 result1 ...) trong mt (cond ).
V d:
(setq
(setq
(cond
((/=
)

g1 2)
g2 1)
((= g1 g2) (setq k1 4))
g2 g1) (setq m2 5))

I.5.6.3. Hm (progn ....)


Chc nng:

Tp hp cc biu thc li thnh mt biu thc v bt cc biu thc ny


thc hin theo mt iu khin chung m hm ny phi tun theo.
C php:

(progn

[expr]...)

gii thch:

expr

L biu thc.

V d:
(if (= a b)
(progn
(princ "\nA = B ")
(setq a (+ a 10) b (- b 10))
)
(progn
(princ "\A khong bang B")
(setq a b)
)
)

I.5.6.4. Hm (repeat ....)


Chc nng:

Thc hin cc biu thc (lnh) trong hm mt s ln lp nht nh.


C php:

(repeat

int [expr]...)

gii thch:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

26

Lp trnh ng dng trong AutoCAD - AutoLISP

int
expr

L s nguyn ch s ln lp.
Biu thc (lnh) cn thc hin.

V d:
(setq a 10
(repeat 4

b 100)
(setq a (+ a 10))
(setq b (+ b 100))

I.5.6.5. Hm (while ....)


Chc nng:

Thc hin cc biu thc (lnh) trong hm mt s ln lp c iu kin.


C php:

(while testexpr expr...)


gii thch:

L biu thc kim tra. Khi no testexpr nhn gi tr nil,


vng lp ngng thc hin.
Biu thc (lnh) cn thc hin.

testexpr
expr

V d:
(setq test 1)
(while (<= test 10)
(some-func test); Mt s biu thc hoc hm t ti y.
S l-ng khng hn ch.
(setq test (1+ test))
)

I.5.6.6. Hm (foreach ....)


Chc nng:

Ly cc gi tr ca cc thnh phn trong mt danh sch thc hin cc


biu thc tip theo.
C php:

(foreach name

lst

expr...)

gii thch:

name
lst
expr

Tn bin s nhn cc gi tr l cc thnh phn ca danh sch.


Danh sch
Biu thc (lnh) cn thc hin.

V d:
(foreach n '(a b c) (print n))

Kt qu: tr v n = c.
T-ng -ng vi:
(print a)
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

27

(print b)
(print c)

I.5.7. Cc hm x l danh sch.


I.5.7.1. Hm (quote ....) hoc '(...)
Chc nng:

Tr ra mt biu thc, kiu l kiu ca biu thc.


C php:

(quote

expr)

hoc

'(expr)

gii thch:

expr Biu thc.


Nu biu thc l s, c th to thnh danh sch im, nu l cc bin,
mc d -c gn gi tr bng s cng khng to -c danh sch
im.
V d:
(quote a)
(quote "cat")
(quote (a b))

---> A
; kiu SYM (k hiu)
---> "cat" ; kiu STR (chui)
---> (A B) ; kiu LIST (danh sch)

T-ng t:
'a
--->
'cat
--->
'(a b)
--->
(setq b '(1.5 "thit
(setq d 15.0)
(setq c '(3.0 17 d))

A
CAT
(A B)
k "))--->(1.5 "thit k ")

(setq pt1 '(1.0 2.0 0.0))


im pt1.

--->(3.0 17 D) ;khng phi


l ta im
--->(1.0 2.0 0.0) ;ta

I.5.7.2. Hm (list ....)


Chc nng:

To ra mt danh sch (list).


Kt qu: tr ra l mt danh sch (list).
C php:

(list

expr ...)

gii thch:

expr Biu thc, t nht phi c mt tham s.


Biu thc d l s hay bin cng u to -c danh sch im.
V d:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

28

Lp trnh ng dng trong AutoCAD - AutoLISP


(list
(list
(list
im.
(setq
(list

'a 'b 'c)


'a '(b c) 'd)
3.9 6.7)
x 1.0 y 3.4
x y z )

---> (A B C)
---> (A (B C) D)
---> (3.9
6.7);danh sch
z

0.0)
---> (1.0

3.4

0.0);danh sch im.

I.5.7.3. Hm (car ....)


Chc nng:

Hon tr thnh phn u tin ca danh sch (list).


Kt qu: tr ra l mt gi tr, kiu l kiu ca thnh phn .
C php:

(car list)
gii thch:

list

L mt danh sch.

V d:
(setq x 3.6 y 1.2)
(setq b '(1.5 "thiet ke "))
(setq c '(3.0 17.0))
(setq d (list c y))
(setq pt1 (car d)) (3.0 17.0)--->danh sch ta im.
(command "circle" pt1 2.0)
(setq m (list x y))
(setq e (* (car m) 2.0))
--->7.2

I.5.7.4. Cc hm t-ng t nh- (car ....)


Tn hm
C php
Chc nng
Hon tr danh sch khng c phn t u
cdr
(cdr list)
Hon tr thnh phn th hai ca danh sch
cadr
(cadr list)
caddr
(caddr list) Hon tr thnh phn th 3 ca danh sch
caar
(caar list)
T-ng -ng (car (car list))
cdar
(cdar list)
T-ng -ng (cdr (car list))
cadar
(cadar list) T-ng -ng (car (cdr (car list)) )
cddr
(cddr list)
T-ng -ng (cdr (cdr list))
Hon tr thnh phn cui cng ca danh sch
last
(last list)
Hon tr thnh phn th int ca danh sch, th
nth
(nth int
t bt u t 0, 1, 2 ....
list)
I.5.7.5. Hm (reverse ....)
Chc nng:

Hon tr danh sch ng-c vi danh sch (list) ban u.


C php:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

29

(reverse list)
gii thch:

list

L mt danh sch.

V d:
(reverse '((a) b c))
(setq x 3.6
y 1.2)
(setq m (list x y))
(setq e (reverse m))

---> (C B (A))

---> (1.2 3.6)

I.5.7.6. Hm (length ....)


Chc nng:

Hon tr s thnh phn (m s phn t) trong danh sch (list).


C php:

(length list)
gii thch:

list

L mt danh sch.

V d:
(length '(a b c d))
(length '(a b (c d)))
(length '())

--->
--->
--->

4
3
0

I.5.7.7. Hm (append ....)


Chc nng:

Gp cc danh sch thnh phn thnh mt danh sch (list) n.


C php:

(append list1 list 2 ...)


gii thch:

list1, list2 ...


V d:
(append
(append
(setq x
(setq c
(setq m
(setq g

L nhng danh sch thnh phn.


'(a b) '(c d))
---> (A B C D)
'((a)(b)) '((c)(d)))---> ((A)(B)(C)(D))
3.6 y 1.2)
'(3.0 17.0))
(list x y))
(append m c))
---> (3.6 1.2 3.0 17.0)

I.5.7.8. Hm (member ....)


Chc nng:

To mt danh sch mi t mt danh sch c theo mt thnh vin cho


tr-c.
C php:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

30

Lp trnh ng dng trong AutoCAD - AutoLISP

(member

expr list )

gii thch:

list
expr

L danh sch gc.


L mt trong cc thnh vin ca danh sch gc danh sch gc.
Danh sch mi -c to ra c cc thnh vin l cc thnh vin ca danh
sch gc bt u t thnh vin expr cho n thnh vin cui.
+ Nu expr khng phi l thnh vin ca list, hon tr Nil

V d:
(member 'c '(a b c d e))
(member 'q '(a b c d e))

--->
--->

(C D E)
nil

I.5.7.9. Hm (cons ....)


Chc nng:

To mt danh sch mi t mt danh sch c hoc to ra mt cp gi


tr, phn cch bng du chm ".".
C php:

(cons item1

item2)

gii thch:

item1
item2

L danh sch hoc gi tr.


L danh sch hoc gi tr.

Nu item2 l danh sch th danh sch mi -c to ra c thnh vin u l


item1 v cc thnh vin tip theo l cc thnh vin ca danh sch item2.
Nu item2 khng phi l danh sch, s to ra mt cp gi tr c chm (Dotted pair).
v d:
(cons
(cons
(cons
(cons

'a '(b c d))


'(a) '(b c d))
'a 2)
8 "TAM")

--->(A B C D)
--->((A) B C D)
--->(A . 2)
--->(8."TAM"); lp (layer) "TAM"

I.5.7.10. Hm (assoc ....)


Chc nng:

To mt danh sch mi t mt danh sch gc theo mt m cho tr-c.


C php:

(assoc item

alist)

gii thch:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

item
alist

31

L m kho.
L danh sch gc.

v d:
(setq al '((name box) (width 3) (size 4.7263)(depth 5)))
(assoc 'size al)
---> (SIZE 4.7263)
(assoc 'weight al)
---> nil

I.5.7.11. Hm (subst ....)


Chc nng:

Thay th cc thnh vin ca mt danh sch (list).


C php:

(subst

'newitem

'olditem

list)

gii thch:

newitem
olditem
list

L thnh vin mi.


L thnh vin c.
L danh sch gc.

v d:
(setq sample '(a b (c d) b))
(subst 'qq 'b sample)
(subst 'qq 'z sample)
(subst 'qq '(c d) sample)
(subst '(qq rr) '(c d) sample)
(subst '(qq rr) 'z sample)

--->
--->
--->
--->
--->

(A
(A
(A
(A
(A

QQ (C D) QQ)
B (C D) B)
B QQ B)
B (QQ RR) B)
B (C D) B)

I.5.7.12. Hm (lambda ....)


Chc nng:

To mt hm khuyt danh, ch dng mt ln, khng l-u li trong b


nh. Khng dng cc bin cc b hay bin chung.
T bn thn hm ny khng triu gi chnh mnh, phi thng qua cc hm
mapcar v hm apply.

Kt qu: tr v l gi tr ca biu thc sau cng.


C php:

(lambda(arguments)

expr...)

gii thch:

arguments Cc i s hnh thc, ging nh- i s ca cc hm khc.


expr
Biu thc x l cc i s trn. Tn v s l-ng cc tham s ti
y phi ng vi cc i s.
Khi triu gi, cc tham s thc l s hoc danh sch u -a vo d-i
dng danh sch.
V d:
(apply '(lambda (x y z)

; x, y, z i s hnh thc

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

32

Lp trnh ng dng trong AutoCAD - AutoLISP


(* x (- y z))

; biu thc

)
'(5 20 14)

; thay i s hnh thc bng


cc gi tr tht.
---> 30

)
(setq b '(lambda(x y)

(+ x y))); s dng nhiu ln


phi gn cho mt bin.
(setq c (apply b '(5.0 6.0)))
;gi hm bng hm apply
--> 11.0
(setq e (apply b '(1 2)))
;gi ln th hai
---> 3
(setq d (apply'(lambda(m g q) (* m g q))'(3.0 4.0 5.0)))
---> 60.0
(setq counter 0)
(mapcar '(lambda (x)
(setq counter (1+ counter))
(* x 5)
)
'(2 4 -6 10.2)
)

--->

(10 20 -30 51.0)

I.5.7.13. Hm (apply ....)


Chc nng:

Thc hin mt hm vi cc tham s -c -a vo d-i hnh thc mt


danh sch (list).
C php:

(apply

'function

list)

gii thch:

' function
list

Tn hm. Hm ny c th l hm c sn ca AutoLISP hoc hm


do ng-i dng nh ngha c tham s.
Danh sch cha cc tham s l cc gi tr tht ca cc i s
hnh thc ca hm.

S l-ng cc thnh vin ca list phi bng s cc i s hnh thc ca


hm.
V d:
(apply '+ '(1 2 3))
---> 6
(apply 'strcat
'("a" "b" "c"))
---> "abc"
(apply '(lambda(m g q) (* m g q)) '(3.0 4.0 5.0)))
---> 60.0
(defun nhan(x y)
(* (- x 1.0) (+ y 2.0))
)
(setq c (apply 'nhan '(5.0 6.0)))
---> 32.0
Nu dng hm khng tham s m gi bng APPLY:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

33

(defun nhan()
(* (- x 1.0) (+ y 2.0))
)
(setq c (apply 'nhan '(5.0 6.0)))
S bo li:

Error: incorrect number of arguments to a function - tham s


khng ng.
I.5.7.14. Hm (mapcar ....)
Chc nng:

Thc hin cc php ton vi cc thnh vin ca cc danh sch (lists).


Kt qu: tr ra mt danh sch mi, cc thnh vin l kt qu ca cc
php ton ni trn.
C php:

(mapcar

'function list1 .... listn)

gii thch:

' funtion

Tn hm. Hm ny l cc php ton trong AutoLISP hoc


hm lambda, khng dng cho hm do ng-i dng nh
ngha.
list1,...., listn Danh sch cha cc tham s l cc gi tr tht ca cc i s
hnh thc ca hm.
S l-ng cc thnh vin ca list phi bng s cc i s hnh thc ca
hm.
V d:
(setq a 10 b 20 c 30)
(mapcar '1+ (list a b c))
---> (11 21 31)

t-ng -ng:
(1+ a)
(1+ b)
(1+ c)
(mapcar

'(lambda (x)
(+ x 3)
)
'(10 20 30)

---> (13 23 33)

I.5.8. Cc hm nhp - xut d liu.


I.5.8.1. Hm (prompt.......)
Chc nng:

Xut mt chui k t ra mn hnh.


C php:

(prompt

msg )

gii thch:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

34

Lp trnh ng dng trong AutoCAD - AutoLISP

msg

Chui k t cn xut ra nh- mt dng thng bo.

V d:
(prompt "Cho so lieu: ")

Trn vng dng lnh xut hin:


Cho so lieu:
I.5.8.2. Hm (open.......)
Chc nng:

M mt tp tin d liu trn a.


C php:

(open filename mode)


gii thch:

Filename

Tn tp tin (file) cha d liu.

- Phn m rng ca tp tin l *.TXT hoc bt k do ng-i dng t.


- Nu tp tin ny khng nm trong th- mc lm vic ca AutoCAD phi
c -ng dn.
- Nu mun xut ra my in phi t filename l "PRN".

M ca tp tin. Trong AutoLISP mode nhn ba dng sau:


c ni dung ca tp tin ang c trn a.
Ghi vo tp tin, mi ln ghi li to mt tp tin mi.
Ghi tip vo tp tin ang tn ti hoc to tp tin mi ghi nu
ch-a c tp tin trn a.

mode
"r"
"w"
"a"
V d:

M tp tin c tn dulieu.dat nm trong th- mc lm vic ca


AutoCAD c:
(setq f (open "dulieu.dat" "r"))

M tp tin c tn dulieu.dat nm trong th- mc solieu ghi:


(setq fw (open "c:/solieu/dulieu.dat" "w"))

M tp tin c tn dulieu.dat nm trong th- mc solieu ghi


vo dng tip theo:
(setq fw (open "c:/solieu/dulieu.dat" "a"))

M my in xut d liu:
(setq in (open "PRN" "w"))

I.5.8.3. Hm (close.......)
Chc nng:

ng tp tin d liu ang m bng hm Open gii phng b nh cho


cc ch-ng trnh khc lm vic
C php:

(close filename )
gii thch:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

35

Filename - Tn tp tin (file) cha d liu va m bng Open.


V d:
(open "dulieu.dat" "r"); m file
;.... thc hin cc lnh khc ti y.
(close "dulieu.dat"); ng file.

hoc:
(setq f (open "dulieu.dat" "r"));
;.... thc hin cc lnh khc ti y.
(close f); ng file.

I.5.8.4. Hm (findfile.......)
Chc nng:

Tm mt tp tin trn a.
C php:

(findfile filename )
gii thch:

Filename
Tn tp tin (file).
Nu thy, AutoLISP s tr v tn tp tin km theo -ng dn.
V d:
(findfile "acad.exe")
---> C:\\ACADWIN\\ACAD.EXE.

I.5.8.5. Hm (read-line ....)


Chc nng:

c mt dng k t t bn phm hoc t tp tin (file).


C php:

(read-line [fp] )
gii thch:

fp

Tn tp tin (file) cha d liu va m bng Open.

- Nu c ghi fp , hm s c mt dng ca tp tin ny hon tr chui k t.


- Nu khng c fp, hm c mt chui k t -c g vo t bn phm.
- Mi ln gi hm (read-line ...) mt dng d liu tip theo -c c vo, khi
no khng cn d liu kt qu l nil.
V d:

Tp tin d liu test1.txt cha cc d liu d-i dng:


123456789
1.453.7542.435
(1.23 2.12 3.334)
'(3.546 123.56 0.0)
567 23.42 89

Trong AutoLISP ta c on ch-ng trnh:


Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

36

Lp trnh ng dng trong AutoCAD - AutoLISP


(setq f1 (open "c:/test1.txt" "r"))

; m tp tin d
liu c
(setq kt1 (read-line f1)); c 1 dng v gn chui cho
bin kt1
(setq kt2 (read-line f1))
(setq kt3 (read-line f1))
(setq kt4 (read-line f1))
(setq kt5 (read-line f1))
(setq kt6 (read-line f1))
(close f1)
; ng tp tin d liu

Kt qu hon tr cc gi tr ca cc bin s:
kt1
kt2
kt3
kt4
kt5
kt6

nhn
nhn
nhn
nhn
nhn
nhn

chui 123456789
chui 1.453.7542.435
chui (1.23 2.12 3.334)
chui '(3.546 123.56 0.0)
chui 567 23.42 89
gi tr nil.

I.5.8.6. Hm (read....)
Chc nng:

c chui k t v hon tr gi tr tham s -c ci hon ph hp


vi kiu d liu nhp vo.
C php:

(read str)
gii thch:

str

chui k t, hoc mt bin kiu chui.

V d:
(read
(read
(read
(read
(read
(read

"chuc mung")
"chuc")
"12.345")
"(a b c)")
"4")
"4 1.23")

---->
---->
---->
---->
---->
---->

chuc
chuc
12.345
(a b c)
4
4

;chui k t
;s thc
;danh sch
;s nguyn
;s nguyn

I.5.8.7. Hm (read-char ....)


Chc nng:

c mt k t t bn phm hoc t tp.


Kt qu: tr ra l s nguyn l m ASCII ca k t va c.
C php:

(read-char

[fr] )

gii thch:

fr

Tn tp tin cha d liu -c m bng open.


Nu khng c fr, my ch ng-i dng nhp vo t bn phm.

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

37

v d:
(read-char)

Trn vng dng lnh c du nhp nhy |, ch g vo mt k t


G vo ch A
---> 65.
I.5.8.8. Hm (write-char ....)
Chc nng:

Ghi mt k t ra vng dng lnh trn mn hnh hoc vo tp tin


(file).
Kt qu: tr ra l mt k t.
C php:

(write-char

n [fr] )

gii thch:

n
fr

S nguyn l m ASCII ca k t nh ghi vo.


L tn tp tin cha d liu -c m bng open.
Nu khng c fr, k t -c -a ra vng dng lnh ca AutoCAD.

v d:
(write-char 65)

Trn vng dng lnh xut hin ch A.


I.5.8.9. Hm (write-line ....)
Chc nng:

Ghi mt chui k t ra vng dng lnh trn mn hnh hoc vo tp.


Kt qu: tr ra l chui k t.
C php:

(write-char

str [fr] )

gii thch:

str
fr

Chui.
L tn tp tin cha d liu -c m bng open.
Nu khng c fr, k t -c -a ra vng dng lnh ca AutoCAD.

v d:
(write-line "Test" f)

--->

"Test".

I.5.8.10. Cc hm prin1 , princ , v print


Chc nng:

In kt qu ra vng dng lnh trn mn hnh hoc vo tp.


C php:

(prin1
(princ

expr [fr] )
expr [fr] )

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

38

Lp trnh ng dng trong AutoCAD - AutoLISP

(print

expr [fr] )

gii thch:

expr
fr

Biu thc.
L tn tp tin cha d liu -c m bng open.
Nu khng c fr, chui -c -a ra vng dng lnh ca AutoCAD.
S khc nhau gia cc hm:
+ Cc k t iu khin nh- "\n", "\r" ... khng c tc dng i vi
prin1
+ Print lun ghi kt qu xung dng mi v sau kt qu c mt du
trng.

v d:
(setq a 123 b '(a))
(prin1 'a)
;in ra
A v tr kt qu A
(prin1 a)
;in ra 123 v tr kt qu 123
(prin1 b)
;in ra (A) v tr kt qu (A)
(prin1 "Hello") ;in ra "Hello" v tr kt qu "Hello"
(prin1 "Hello" f);ghi chui "Hello" vo tp f.

V d v s khc nhau gia cc hm:


(setq fr (open "c:/tailieu/lsp/get.txt" "a"))
(setq c 15.0)
(prin1 "\n ket qua
" fr)
(prin1 c fr)
(princ "\n Ket qua
" fr)
(princ (* c 2.0) fr)
(print (+ c 5.0) fr)
(close fr)

Kt qu ghi vo tp get.txt nh- sau:


"\n ket qua
"15.0
Ket qua
30.0
20.0

I.5.9. Cc hm kim tra kiu d liu.


I.5.9.1. Hm (type ....)
Chc nng:

Xc nh kiu d liu.
C php:

(type

item )

gii thch:

item

L biu thc.

V d:
(setq a 123 r 3.45 s "Hello!" x '(a b c))
(setq f (open "name" "r"))
(type (+ 12.6 5))
---> REAL
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(type
(type
(type
(type
(type
(type
(type
(type

'a)
a)
f)
r)
s)
x)
+)
nil)

--->
--->
--->
--->
--->
--->
--->
--->

39

SYM
INT
FILE
REAL
STR
LIST
SUBR
nil.

I.5.9.2. Hm (boundp ....)


Chc nng:

Kim tra xem tham s c mang gi tr hay khng.


Nu tham s mang gi tr, tr ra T, ng-c li Nil.
C php:

(boundp

'sym )

gii thch:

sym

Tham s.

V d:
(setq a 2
b
nil)
(boundp 'a)
---> T
(boundp 'b)
---> nil
(setq fr (open "c:/tailieu/lsp/get.txt" "a"))
(setq c (* 15.0 2))
(setq m (boundp 'c))
---> T
(setq k (boundp 'y))
---> nil
(setq h (boundp 'fr))
---> T
(close fr)

I.5.9.3. Hm (null ....)


Chc nng:

Nu tham s l nil tr ra T, cn cc tr-ng hp khc l Nil.


C php:

(null

item )

gii thch:

itemr

Tham s.

V d:
(setq
(null
(null
(null
(null

a 123
a)
b)
c)
'())

b "string"

c nil)
---> nil
---> nil
---> T
---> T

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

40

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.9.4. Hm (atom ....)


Chc nng:

Nu tham s khng phi l danh sch (list) tr ra T, ng-c li l Nil.


C php:

(atom

item )

gii thch:

item

Tham s.

V d:
(setq
(setq
(atom
(atom
(atom

a '(x y z))
b 1.6)
a)
---> nil
b)
---> T
'(a b c)) ---> nil.

I.5.9.5. Hm (listp ....)


Chc nng:

Nu tham s l danh sch (list) tr ra T, cc kiu cn li Nil.


C php:

(listp

item )

gii thch:

item

Tham s.

V d:
(setq a '(x y z))
(setq b 1.6)
(listp a)
(listp b)
(listp '(a b c))

---> T
---> nil
---> T.

I.5.9.6. Hm (numberp ....)


Chc nng:

Nu tham s l s tr ra T, cn cc tr-ng hp khc l Nil.


C php:

(numberp

item )

gii thch:

item

Tham s.

V d:
(setq a
(numberp
(numberp
(numberp
(numberp
(numberp

123 b 'a)
4)
3.8348)
"Howdy")
a)
b)

--->
--->
--->
--->
--->

T
T
nil
T
nil

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(numberp

(eval b))

41

---> T

I.5.9.7. Hm (minusp ....)


Chc nng:

Nu tham s l s m tr ra T, cn cc tr-ng hp khc l Nil.


C php:

(minusp

number )

gii thch:

number

Tham s.

V d:
(setq a
(setq b
(minusp
(minusp
(minusp

5.0)
-1.6)
a)
b)
'(a b c))

---> nil
---> T
---> nil.

I.5.9.8. Hm (zerop ....)


Chc nng:

Nu tham s l s 0 tr ra T, cn cc tr-ng hp khc l Nil.


C php:

(zerop

number )

gii thch:

number

Tham s.

V d:
(zerop 0)
(zerop 0.0)
(zerop 0.0001

---> T
---> T
---> nil.

I.5.10. Cc hm chuyn i kiu d liu.


I.5.10.1. Hm (angtof ....)
Chc nng:

Chuyn i chui k t (cha cc ch s) thnh s thc dng cho gc v


tr v s o gc bng radian.
Kt qu: tr v REAL.
C php:

(angtof

str [mode] )

gii thch:

str
[mode]

L chui cha ch s.
L s nguyn xc nh dng n v nhp vo. Nu khng c, s
tun theo cc ci t ca lnh UNITS.
Mode nhn cc gi tr sau:
0
Dng thp phn ()
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

42

Lp trnh ng dng trong AutoCAD - AutoLISP

1
2
3
4

Dng /pht/giy
Dng Grads
Dng Radian
Dng Trc c (c km theo k hiu ch h-ng).

V d:
(setq g1 (angtof "180.0"))
(setq g2 (angtof "180.0" 0))
(setq g3 (angtof "180d30'" 1))

---> 3.14159 radian


---> 3.14159 radian
---> 3.15032 radian.

I.5.10.2. Hm (angtos ....)


Chc nng:

Chuyn i s o gc thnh chui k t (cha cc ch s).


Kt qu: tr v STR.
C php:

(angtos angle [mode [precision]])


gii thch:

S o gc cho bng radian.


L s nguyn xc nh dng n v xut ra. Nu khng c, s
tun theo cc ci t ca lnh UNITS.
Mode nhn cc gi tr sau:
0
Dng thp phn ()
1
Dng /pht/giy
2
Dng Grads
3
Dng Radian
4
Dng Trc c (c km theo k hiu ch h-ng).
[precision] chnh xc (s ch s sau du phy thp phn).
angle
[mode]

V d:
(angtos 0.785398 0 4)
(angtos -0.785398 0 4)
(angtos 0.56783 2 2)
(angtos 0.56783 1 2)

--->
--->
--->
--->

"45.0000"
"315.0000"
"36.15g"
"32d32'"

I.5.10.3. Hm (atof ....)


Chc nng:

Chuyn i chui k t (cha cc ch s) thnh s thc.


Kt qu: tr v REAL.
C php:

(atof str )
gii thch:

str

Chui k t (cha cc ch s).

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


V d:
(atof "97.1")
(atof "3")
(atof "3.9")

--->
--->
--->

43

97.1
3.0
3.9

I.5.10.4. Hm (atoi ....)


Chc nng:

Chuyn i chui k t (cha cc ch s) thnh s nguyn.


Kt qu: tr v INT.
C php:

(atoi str )
gii thch:

str

Chui k t (cha cc ch s).

V d:
(atoi "97")
(atoi "3")
(atoi "3.9")

--->
--->
--->

97
3
3

I.5.10.5. Hm (itoa ....)


Chc nng:

Chuyn i s nguyn thnh chui k t (cha cc ch s).


Kt qu: tr v STR.
C php:

(itoa int )
gii thch:

int

S nguyn. Nu cho cc gi tr khc kiu s bo li.

V d:
(itoa 33) ---> "33"
(itoa -17) ---> "-17"

I.5.10.6. Hm (rtos....)
Chc nng:

Chuyn i s thc thnh chui k t (cha cc ch s).


Kt qu: tr v STR.
C php:

(rtos number [mode [precision]])


gii thch:

number
[mode]
1

L mt s.
M iu khin dng xut ra ca chui, nhn cc gi tr sau:
Dng khoa hc (Scientific)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

44

Lp trnh ng dng trong AutoCAD - AutoLISP

2
3
4
5
[precision]

Dng thp phn (Decimal)


Dng k thut - Engineering(feet and decimal inches)
Dng kin trc - Architectural(feet and fractional inches)
Hu t (phn s) - Fractional.
chnh xc (s ch s thp phn sau du phy).

V d:
(setq
(setq
(setq
(setq
(setq

g1
g2
g3
g4
g5

(rtos
(rtos
(rtos
(rtos
(rtos

15.5
15.5
15.5
15.5
15.5

1
2
3
4
5

4))
4))
4))
4))
4))

--->
--->
--->
--->
--->

"1.5500E+01"
"15.5000"
"1'-3.5000""
"1'-3 1/2""
"15 1/2"

I.5.10.7. Hm (distof....)
Chc nng:

Chuyn i chui k t (cha cc ch s) c nh dng thnh s thc.


Kt qu: tr v REAL.
C php:

(distof str [mode])


gii thch:

str
[mode]
1
2
3
4
5

L chui k t (cha cc ch s).


M iu khin dng nhp vo ca s thc, nhn cc gi tr sau:
Dng khoa hc (Scientific)
Dng thp phn (Decimal)
Dng k thut - Engineering (feet and decimal inches)
Dng kin trc - Architectural (feet and fractional inches)
Hu t (phn s) - Fractional.

V d:
(distof "123.4" 2)
(distof "1.234e1" 1)
(distof "12'" 3)

---> 123.4
---> 12.34
---> 144.0

I.5.10.8. Hm (fix....)
Chc nng:

Chuyn i s thc thnh s nguyn, ct b phn thp phn.


Kt qu: tr v INT.
C php:

(fix number)
gii thch:

number

L s thc.

V d:
(fix 3)

--->

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


(fix 3.7)

--->

45

I.5.10.9. Hm (float....)
Chc nng:

Chuyn i mt s thnh s thc.


Kt qu: tr v REAL.
C php:

(float num)
gii thch:

num

L s nguyn hoc s thc.

V d:
(float 3)
(float 3.75)

--->
--->

3.0
3.75

I.5.11. Cc hm x l chui k t.
Trong AutoLISP, chui (string) l cc k t -c vit trong ngoc
kp " ".
Du \ km theo mt ch ci t trong chui c tc dng iu khin:
Cch vit
\\

\n

xung dng

\t
\e
\"

tab
ESC
"

ngha

V d
"c:\\tailieu\\test.lsp" ngha l:
c:\tailieu\test.lsp
Hin nay c th dng du / thay cho \\
"\n Nhap do dai: " thng bo Nhap
do dai: -c ghi trn mt dng mi

"Ten la \"Ban 1\" trong C"


ngha l:
Ten la "Ban 1" trong C.
Cm k t nnn l m h 8 ca k t ASCII
ENTER

\nnn
\r

I.5.11.1. Hm (strcat ....)


Chc nng:

Ni cc chui thnh phn thnh mt chui chung.


C php:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

46

Lp trnh ng dng trong AutoCAD - AutoLISP

(strcat

str1 str2

[str3] ... )

gii thch:

str1, str2, str3, ... l cc chui thnh phn cn ghp li.


Kt qu: tr v l mt chui gm tt c cc k t ca cc chui thnh
phn.
v d:
(strcat "a" "bout")
--->
(strcat "a" "b" "c") --->
(strcat "a" "" "c")
--->
(setq c1 "Ban ve")
(setq c2 "thiet ke")
(setq tc (strcat c1 c2 "so
--->
(setq n1 "Ban ve ")
(setq n2 "thiet ke ")
(setq tn (strcat n1 n2 "so

"about"
"abc"
"ac"

5"))
"Ban vethiet keso 5"

5"))
---> "Ban ve

thiet ke

so 5"

I.5.11.2. Hm (strcase ....)


Chc nng:

Chuyn chui ra ch in hoa hoc ra ch th-ng.


C php:

(strcase

string [which] ... )

gii thch:

string
L cc chui cn chuyn i.
which
Nu khng c, tt c chui bin thnh ch in hoa.
Nu l ch T , tt c chui tr thnh ch th-ng.
v d:
(strcase "Sample")
---> "SAMPLE"
(strcase "Sample" T) ---> "sample"
(setq a "Ban ve ")
(setq b "thiet ke ")
(setq c (strcat a b "so 5"))
(setq d (strcase c))
---> "BAN VE THIET KE SO 5"

I.5.11.3. Hm (strlen ....)


Chc nng:

m s k t ca chui.
C php:

(strlen

string )

gii thch:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

47

string
L cc chui cn m.
Kt qu: tr v s cc k t trong chui.
v d:
(strlen "abcd")
--->
(strlen "ab")
--->
(strlen "one" "two" "four")--->
(strlen)
--->
(strlen "")
--->
(setq str "BIG")
(setq bigstr (strcat "This is a
(strlen bigstr)
--->

4
2
10
0
0
" str " test."))
19

I.5.11.4. Hm (substr ....)


Chc nng:

Trch mt phn ca chui k t thnh mt chui khc.


C php:

(substr

string

start [length])

gii thch:

string
start
length

L cc chui cn trch.
V tr k t trong chui bt u trch ra.
di chui mi (s k t), nu khngch r di th chui
mi bt u t v tr start cho n ht.
Kt qu: tr v chui c k t bt u ti sart v c length k t.

v d:
(substr
(substr
(substr
(setq s

"abcde"
"abcde"
"abcde"
(substr

2)
---> "bcde"
2
1)
---> "b"
3
2)
---> "cd"
"day la chuoi ky tu" 4))
---> " la chuoi ky tu"

I.5.11.5. Hm (chr ....)


Chc nng:

Tr ra chui 1 k t c m ascii l i s.
C php:

(chr

int)

gii thch:

int

L s nguyn ch m ASCII ca mt k t.

V d:
(chr 65) --->
(chr 66) --->
(chr 97) --->

"A"
"B"
"a"

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

48

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.11.6. Hm (ascii ....)


Chc nng:

Tr ra s nguyn l m ascii ca mt k t.
C php:

(ascii

string)

gii thch:

string

L chui.

V d:
(ascii "A")
(ascii "a")
(ascii "BIG")

--->
--->
--->

65
97
66 ; m ASCII ca ch B.

I.5.12. Cc hm thao tc vi cc i t-ng (entity) ca


Autocad
Mi i t-ng to ra trong AutoCAD u -c gi l mt thc th
(Entity) v -c AutoCAD qun l d-i dng bng ghi (record). Trong
bn ghi ca tng i t-ng u c cc d liu r c tr-ng hnh hc, cc
bng s liu, cc dng vn bn, mi tr-ng v.v... Khi lm chc nng qun l,
AutoCAD cng xut, nhp d liu v c th hiu chnh chng. AutoLISP
cng c th thm nhp vo thc th, thao tc vi chng. Sau y l cc hm
ca AutoLISP thao tc vi thc th v tp hp cc thc th tr li cho dng
nhc "Select Object:" ca AutoCAD.
I.5.11. A- Cc hm thao tc vi cc i t-ng c lp

I.5.12.1. Hm (entlast)
Chc nng:

Chn i t-ng v cui cng trong bn v v tr v m ENAME ca n.


C php:

(entlast)
gii thch:

Hm ny khng c i s.
V d:

Gn thc th cui cng trong bn v cho bin e1, cn thao tc vi thc


th ta ch cn thao tc vi e1:
(setq e1 (entlast))

I.5.12.2. Hm (entnext)
Chc nng:
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

49

Chn i t-ng v u tin trong bn v hoc i t-ng tip sau mt i


t-ng khc v tr v ENAME ca n.
C php:

(entnext [ename])
gii thch:

ename

Nu khng c, hon tr thc th u tin trong bn v.


Nu c, hon tr tn thc th tip sau thc th c tn ename.

V d:
(setq e1 (entnext)
; Gn tn thc th u tin cho
e1.
(setq e2 (entnext e1))
;Gn tn thc th sau e1 cho
e2.

I.5.12.3. Hm (entsel)
Chc nng:

Ch ng-i dng chn i t-ng v tr v ENAME ca n.


C php:

(entsel

[prompt])

gii thch:

prompt Li nhc. Nu khng c, dng nhc s l Select object:


Khi gp lnh ny li nhc (prompt) hin trn dng lnh i ng-i
dng chn mt i t-ng trong bn v.
Nu c lnh gn ENAME ca i t-ng ny cho mt bin, bin -c
s dng nh- mt i t-ng trong cc lnh tip theo.
V d:

Thc hin trn dng lnh v on thng:


Command:
line
From point:
1,1
To point:
6,6
To point:
ENTER

Dng entsel:
Command:
(setq e (entsel "Please choose an object: "))
Please choose an object:
3,3 ; chn i t-ng ti im (3,3).
Kt qu tr ra mt list gm 2 thnh phn: tn i t-ng v to im

nhn chn trn i t-ng.


(<Entity name: 60000014> (3.0 3.0 0.0))

Thc hin trong AutoLISP:


(setq g1
(setq g2
(command
(command
(command

(entsel "chon doi tuong 1"))


(entsel "chon doi tuong 2"))
"extend" g1 "" g2 "")
"trim" g1 "" g2 "")
"rotate" g1 g2 "" '(1 1) 45)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

50

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.12.4. Hm (nentsel)
Chc nng:

Ch ng-i dng chn i t-ng, ENAME tr ra l ENAME ca i


t-ng "b nht" nm trong i t-ng ln.
+ Nu i t-ng khng phc tp nh- LINE, CIRCLE, ARC kt qu
ging ht Entsel.
+ Nu i t-ng c nhiu thnh phn th tr v thnh phn -c bm
chn.
C php:

(nentsel

[prompt])

gii thch:

prompt Li nhc. Nu khng c, dng nhc s l Select object:


V d:

V d ny ging ht entsel:
(setq g1
(setq g2
(command
(command
(command

(nentsel "chon doi tuong 1"))


(nentsel "chon doi tuong 2"))
"extend" g1 "" g2 "")
"trim" g1 "" g2 "")
"rotate" g1 g2 "" '(1 1) 45)

I.5.12.5. Hm (nentselp)
Chc nng:

Ch-ng trnh t ng "bt" (chn) i t-ng i qua mt im cho tr-c.


C php:

(nentselp

[prompt] [pt])

gii thch:

prompt Li nhc.
pt
im m i t-ng i qua.
Nu khng c, chc nng ging ht nensel.
Nu c, v c i t-ng i qua tr v ENAME ca i t-ng , nu
khng c i t-ng i qua tr v Nil, khng ch ng-i dng chn t bn
ngoi.
V d:
(setq pt1 '(1.5 3.0))
(setq pt2 '(6.0 4.0))
(command "arc" pt1 "e" pt2 "r" 8.0)
(setq dt1 (nentselp "chon" pt2))
(command "move" dt1 pt1 '(3.0 6.0))

I.5.12.6. Hm (entdel)
Chc nng:

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

51

Xo mt i t-ng ang tn tai trong bn v hoc khi phc li i


t-ng va b xo. (Ging nh- ERASE v OOPS trong AutoCAD)
C php:

(entdel

ename)

gii thch:

ename M tn i t-ng.
Hm ny ch dng cho cc thc th chnh, tn thc th tr v do cc hm
(entlast), (entnext).
V d:
(setq pt1 '(1.5 3.0))
(setq pt2 '(6.0 4.0))
(command "arc" pt1 "e" pt2 "r" 8.0)
(setq e1 (entnext))
; e1 nhn ENAME l
<Entity name: 25205a0>
(entdel e1)
;Xa e1
(entdel e1)
;Khi phc e1

Nu dng:
(setq dt1 (nentselp "chon" pt2))
(entdel dt1);

Lnh ny s bo li: Error: bad argument type


v dt1 nhn ename l (<Entity name: 2520590> (6.0 4.0 0.0)) km theo
c thuc tnh nn Entdel khng thc hin -c.
I.5.12.7. Hm (entget)
Chc nng:

Hon tr danh sch lit k cc thng tin v i t-ng c trong bn v -c gi.


C php:

(entget

ename [applist])

gii thch:

ename M tn i t-ng.
applist Nu c, l danh sch cc chui k t cha cc thng tin m
rng c lin quan s -c gi ra v hon tr.
V d:
(setq pt1 '(1.5 3.0))
(setq pt2 '(6.0 4.0))
(command "arc" pt1 "e" pt2 "r" 8.0)
(setq dt2 (entlast))
(setq dl1 (entget dt2))

Kt qu tr v l mt danh sch, trong danh sch ny cha danh sch


"Cp c du chm" (Dotted Pair) (xem kiu d liu "list").
((-1
(0 .
(5 .
(100

. <Entity name: 2540528>)


"ARC")
"4D")
. "AcDbEntity")

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

52

Lp trnh ng dng trong AutoCAD - AutoLISP


(67 . 0)
(8 . "0")
(100 . "AcDbCircle")
(10 2.08814 10.9784 0.0)
(40 . 8.0)
(210 0.0 0.0 1.0)
(100 . "AcDbArc")
(50 . 4.6388)
(51 . 5.22331))

ngha ca cc m s ng tr-c du chm chung cho tt c cc thc th:


M
Kiu
ngha
-1
Tn thc th (ENAME)
Chui (String)
0
Kiu thc th
Chui (String)
2
Tn khi hoc lin quan n khi
Chui (String)
6
Tn kiu nt v (Linetype)
Chui (String)
8
Tn lp cha thc th (Layer)
Chui (String)
10 - 37
To im
S thc (real)
38 - 39
Chiu dy, chiu cao
S thc (real)
40 - 59
H s t l, gc
S thc (real)
60 - 79
Mu, s m
S nguyn (Int)
C th cho tng kiu thc th cho trong Ph lc 1.
I.5.12.8. Hm (entmod)
Chc nng:

Cp nht li thng tin ca i t-ng b thay i bng cc hm khc


v v li ra i t-ng vi cc thng tin cp nht. Hm ny th-ng
dng km vi hm entget.
C php:

(entmod entlist)
gii thch:

entlist
entget.

L danh sch cha thng tin ca i t-ng ly t hm

V d:

Thay i bn knh vng trn c trong bn v:


(setq s (car (entsel "\nchon vong tron"))) ; chn i
t-ng l vng trn.
(setq ent (entget s));ly thng tin ca i t-ng.
;Yu cu ng-i dng cho bn knh mi:
(setq ptam (cdr (assoc 10 ent)) r (getdist ptam "\ncho
ban kinh moi"))
(setq ent (subst (cons 40 r) (assoc 40 ent) ent))
;
thay bn knh c bng bn knh mi

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

53

(entmod ent)
;cp nht d liu v thay i hnh
v vi bn knh mi.

I.5.12.9. Hm (entupd...)
Chc nng:

Cp nht li thng tin v v li i t-ng (regen).


C php:

(entupd ename)
gii thch:

ename

M tn i t-ng.

V d:
;Gn i t-ng v u tin cho e1
(setq e1 (entnext))
;Ly thng tin ca e1 gn cho ed
(setq ed (entget e1))
(setq ed
(subst '(10 3 9)
;Thay i ta im ca ed (e1)
(assoc 10 ed)
ed
)
)
;Di chuyn im c ta va thay i n v tr mi.
(entmod ed)
(entupd e1) ;V li i t-ng thay i.

I.5.12.10. Hm (entmake ...)


Chc nng:

To mt thc th mi bng cch xy dng mt danh sch cc c s d


liu ca n, khng cn qua cc lnh ca AutoCAD.
C php:

(entmake edata)
gii thch:

endata Danh sch cc c s d liu ca i t-ng cn to.


V d:

V vng trn:
(entmake
; kiu i t-ng "-ng trn"
'((0 . "CIRCLE")
(62 . 1)
; mu
;tm im (4.0,4.0) (khng c du chm)
(10 4.0 4.0 0.0)
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

54

Lp trnh ng dng trong AutoCAD - AutoLISP


(40 . 1.0)

;bn knh 1.0

)
)
I.5.11.B- Cc hm thao tc vi bng cc i t-ng

Bng cc thc th -c hiu vi ngha chung l tp hp cc thc th


trong mt khi ha chun ca AutoCAD. Cc thc th ny khng thy
hin hu trn bn v m nm trong bng cc d liu. Cc bng i t-ng
gm: LAYER, BLOCK, LTYPE, VIEW, STYLE, UCS, DIMSTYLE,
VPORT, APPID.
Mi bng i t-ng ni trn c ba d liu chnh:
+ Tn bng nh-: "LAYER"", "BLOCK" ...
+ Tn ca i t-ng trong bng nh-: lp "0", khi "NHA"
+ D liu ca i t-ng nh-: mu sc, -ng nt ...
Sau y l hai hm thao tc vi cc bng ny:
I.5.12.11. Hm (tblnext...)
Chc nng:

Tm bng i t-ng v tr ra d liu ca bng .


C php:

(tblnext tblname [rewind]))


gii thch:

tblnameChui k t cha tn bng.


rewind
Nu c gi tr khc nil, s tr v tn v cc d liu ca bng
cc i t-ng u tin m AutoCAD tm thy.
Nu khng c hoc nhn gi tr nil, s tr v tn v cc d liu
ca bng cc i t-ng tip theo m AutoCAD tm thy.
Kt qu: l Nil nu khng tm thy bng c tn trn.
V d:
(setq la (tblnext "layer" T))
(while la
(princ "\n")
(princ la)
(princ "\nTen lop:")
(princ (cdr (assoc 2 la)))
(setq la (tblnext "layer"))
)

Nu trong bn v ta c hai lp "0" v "LAYER1", kt qu tr v nhsau:


((0 . LAYER) (2 . 0) (70 . 0) (62 . 7) (6 . CONTINUOUS))
Ten lop: 0
((0 . LAYER) (2 . LAYER1) (70 . 0) (62 . 6) (6 . ACAD_ISO02W100))
Ten lop: LAYER1
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

55

I.5.12.12. Hm (tblsearch...)
Chc nng:

Tm thnh phn -c ch nh ca bng i t-ng v tr ra d liu ca


thnh phn .
C php:

(tblsearch table-name symbol [setnext])


gii thch:

tbl-name
Chui k t cha tn bng.
symbol
Tn thnh phn ca bng.
Nu tm thy, s tr v tn v cc d liu ca tn gi ny.
Nu khng tm thy tr v nil.
setnext
L la chn dng khi c mt lnh tblnext tip sau lnh ny.
Nu c gi tr khc nil, tblnext s tr v tn v cc d liu ca bng
cc i t-ng tip theo ca bng biu t-ng .
Nu khng c hoc nhn gi tr nil, tblnext s tr v nil.
V d:

1- Tm tn "STANDARD" ca bng "STYLE"


(tblsearch "style" "standard")

Kt qu tr ra nh- sau:
((0 . "STYLE")
Tn bng
(2 . "STANDARD") Tn thnh phn cn tm ca bng.
(70 . 0)
Flags
(40 . 0.0)
Fixed height (chiu cao ch)
(41 . 1.0)
Width factor (t l chiu rng : chiu cao ch)
(50 . 0.0)
Obliquing angle (gc nghing ca k t)
(71 . 0)
Generation flags
(3 . "txt")
Primary font file (phng ch)
(4 . "")
Bigfont file (tn tp tin cha phng ch)
)
2- Nu trong bn v c hai tn STYLE l "STANDARD" v "STYLE1", dng
cc lnh sau:
(setq tl (tblsearch "style" "standard" 1))
(setq t2 (tblnext "style"))

Kt qu l:
((0 . "STYLE") (2 . "STANDARD") (70 . 0) (40 . 0.0) (41 . 1.0) (50 .
0.0) (71 . 0) (42 . 0.2) (3 . "technic_.ttf") (4 . ""))
((0 . "STYLE") (2 . "STYLE1") (70 . 0) (40 . 0.0) (41 . 1.0) (50 . 0.0)
(71 . 0) (42 . 0.2) (3 . "txt.shx") (4 . ""))
I.5.11.C- Cc hm thao tc vi nhm cc i t-ng (PICKSET)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

56

Lp trnh ng dng trong AutoCAD - AutoLISP

Trong AutoCAD ng-i ta s dng ch vit tt "SS" (Selection


Set) gi tn nhm i t-ng (Object) hoc thc th (Entities) -c
chn p ng cu nhc "Select object:" ca AutoCAD. Kiu ca
nhm l PICKSET. C th coi nhm cc i t-ng l mt mng cc phn t,
mi phn t l tn mt i t-ng.
Cc hm sau y ca AutoLISP cho php chn nhm cc i t-ng v thao tc vi chng:
I.5.12.13. Hm (ssget...)
Chc nng:

Chn cc i t-ng c trong bn v v tr v nhm i t-ng


chn. Nu khng c i t-ng no -c chn tr v Nil.
C php:

(ssget [mode] [pt1 [pt2]][pt-list][filter-list])


gii thch:

mode Chui k t cha cc m iu khin vic la chn nh- sau:


"L" (Last) i t-ng v cui cng cn tn ti trong bn v -c chn.
"P"
(Previous) b i t-ng va -c chn tr-c .
"W" (Window)
cc i t-ng nm trong ca s -c chn.
"C" (Cross) cc i t-ng nm trong v vt qua ca s -c chn.
"X"
tt c cc i t-ng trong bn v -c chn.
"WP" (Wpolygon) cc i t-ng nm trong mt a gic cho tr-c -c
chn.
"CP" (Cpolygon) cc i t-ng ct ngang mt a gic cho tr-c -c
chn.
"F" (Fence)
cc i t-ng ct ngang hng ro cho tr-c -c chn.
"I" (Implied)
cc i t-ng -c chn tr-c khi ra lnh bng cch
nhn chut vo cc i t-ng v ti cc im c bit
ca i t-ng c cc vung nh mu xanh. Cc i
t-ng ny -c -a vo danh sch chn khi bin h
thng PICKFIRST nhn gi tr 1.
pt1 pt2 Hai im l hai nh i nhau ca mt ca s hnh ch nht dng
cho chn i t-ng bng Crossing v Window.
pt_list L cc im to thnh a gic hoc hng ro dng cho chn i
t-ng bng WPolygon, CPolygon v Fence.
filter-list
L danh sch cha cc tiu chun lc cho vic chn
nhm i t-ng.
Cc tiu chun lc c th s dng cc php ton lgc (cc php so snh
thng th-ng) kt hp vi cc nhm logc tr gip v m iu khin sau:
a- Cc php so snh:
Ngoi cc php so snh nu trong phn "Cc hm ton hc", cn c php
ton -c s dng trong b lc l:
*
cho gi tr tu .
<>
khng bng (khc).
Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP


b- Cc nhm lgc:
Bt u ca ton t
Biu thc bn trong
"<AND"
Mt hoc nhiu php ton
"<OR"
Mt hoc nhiu php ton
"<XOR"
Hai php ton
"<NOT"
Mt php ton
c- M iu khin:
-4
Ton t iu kin.
-3
Cc d liu m rng.
Cc m iu khin khc xem hm entget.

57

Kt thc ton t
"AND>"
"OR>"
"XOR>"
"NOT>"

V d:

1- Khng dng cc tham s:


(ssget)

Khi thc hin lnh ny, AutoCAD yu cu ng-i dng chn i


t-ng trc tip trn mn hnh. Dng nhc s l : Select object:
2- Dng cc m iu khin (mode):
(ssget "x") hoc
(ssget "l")

3- Dng pt1 v pt2 :


(ssget "w" '(0
0) '(3 3));cc i t-ng nm trong
ca s c hai nh l (0,0) v (3,3) -c chn.
(ssget "c" '(0 0) '(3 3)));cc i t-ng nm ct
ngang hoc nm trong ca s c hai nh l (0,0) v
(3,3) -c chn.

4- Dng pt_list :
(setq b '((2 2) (3 5) (5 8) (1 7)))
(ssget "wp" b);cc i t-ng nm trong a gic c cc
nh l (2,2), (3,5) (5,8) v (1,7) -c chn.
(ssget "cp" b);cc i t-ng nm ct ngang hoc nm
trong a gic c cc nh l (2,2), (3,5) (5,8) v (1,7)
-c chn.
(ssget "f" b);cc i t-ng nm ct ngang a tuyn c
cc nh l (2,2), (3,5) (5,8) v (1,7) -c chn.

5- Dng filter_list :
;cc i t-ng l -ng trn c bn knh ln hn hoc
bng 2.0 -c chn.
(ssget "x" '((0 . "CIRCLE")(-4 . ">=") (40 . 2.0)))
;cc cung trn nm trong ca s c cc nh l (2,2 v
(15,27) c bn knh nh hn 3 -c chn.
(ssget "w" '(2 2)'(15 27)
'((0 . "ARC")(-4. "<")(40 . 3.0)))
; cc -ng trn c to tm X, Y ln hn 0 cn Z bt
k s -c chn.
(ssget "X" '((0 . "CIRCLE")
(-4. ">,>,*")
(10 0.0 0.0 0.0)))
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

58

Lp trnh ng dng trong AutoCAD - AutoLISP


; nhng dng ch nm trn lp "text25" c chiu cao l
25 -c chn.
(ssget "X" '((-4. "<AND")
(0. "TEXT") (8. "TEXT25")
(40 . 25)
(-4. "AND>"))

I.5.12.14. Hm (ssadd...)
Chc nng:

Thm mt i t-ng vo tp i t-ng.


C php:

(ssadd

[ename] [ss])

gii thch:

ss

ename Chui k t cha m tn i t-ng cn thm vo.


Nu i ename ny c trong tp i t-ng, khng thm vo na.
Tn tp i t-ng.
+ Nu c hai tham s u khng c, s tr ra mt tp rng.
+ Nu ename khc Nil, tp i t-ng l Nil, hm s tr ra mt tp i
t-ng ch c mt phn t l ename cho.
+ Nu c hai u khc Nil, hm s tr ra tp i t-ng c thm phn t
ename va thm vo.

V d:
(setq en1 (entnext));ly i t-ng v u tin gn cho
en1.
(setq ss1 (ssadd)) ; to mt tp rng ss1.
(ssadd en1 ss1) ; thm i t-ng en1 vo ss1.

I.5.12.15. Hm (ssdel...)
Chc nng:

Loi b mt i t-ng ra khi tp i t-ng.


C php:

(ssdel

ename

ss)

gii thch:

ss

ename Chui k t cha m tn i t-ng cn loi b.


Nu i ename ny c trong tp i t-ng, th n b loi b, nu
khng c tr ra nguyn tp i t-ng.
Tn tp i t-ng c trong bn v.
V d:
(ssdel en1 ss1) ; loi en1 khi tp ss1.
(ssdel en2 ss1) ; loi en2 khi ss1.

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

59

I.5.12.16. Hm (sslength...)
Chc nng:

Tr ra s nguyn l s cc i t-ng c trong tp cc i t-ng.


C php:

(sslength ss)
gii thch

ss

Tn tp i t-ng c trong bn v.

V d:
(setq sset (ssget "L")) ;ly i t-ng v cui cng cn
tn ti trong bn v
(sslength sset)
;kt qu tr ra 1.

I.5.12.17. Hm (ssname...)
Chc nng:

Tr v ename ca mt i t-ng c trong tp cc i t-ng.


C php:

(ssname ss

index)

gii thch

ss
Tn tp i t-ng c trong bn v.
index S th t ca cc i t-ng trong tp cc i t-ng tnh t 0, 1, 2 ..
0 l i t-ng th nht
1 l i t-ng th 2 ....
V d:
(ssname ss1 0)
trong ss1

; tr ra ename ca i t-ng th nht

I.5.13. Cc hm x l mn hnh
I.5.13.1. Hm (redraw...)
Chc nng:

V li ca nhn (viewport) hin hnh hoc v li hnh trong ca nhn


.
C php:

(redraw [ename [mode]])


gii thch

ename
mode

Tn i t-ng c trong ca nhn.


M iu khin. M ny nhn cc gi tr sau:

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

60

Lp trnh ng dng trong AutoCAD - AutoLISP

1
2
3
4

Cho hin i t-ng (Show entity)


Cho n i t-ng (Hide entity (blank it out))
Cho nh du i t-ng (Highlight entity)
Khng nh du i t-ng (Unhighlight entity)
I.5.13.2. Hm (terpri)

Chc nng:

Xung dng mi ti vng dng lnh (command line) trn mn hnh .


C php:

(terpri)
gii thch

Hm ny khng -c dng trong cc tp tin xut - nhp d liu.


I.5.13.3. Hm (graphscr)
Chc nng:

Cho hin th mn hnh ha ca AutoCAD .


C php:

(graphscr)
gii thch

Hm ny c chc nng nh- phm F2 khi mn hnh ang hin th TEXT.


I.5.13.4. Hm (textscr )
Chc nng:

Cho hin th mn hnh vn bn ca AutoCAD .


C php:

(textscr)
gii thch

Hm ny c chc nng ng-c li ca hm graphscr.


Ht phn 1 - AutoLISP

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

61

mc lc
Phn 1

AutoLISP
Stt

Ni dung

Trang

I.1.
I.2.

Gii thiu chung .....................................................................1


Cc qui -c ca AutoLISP...................................................1

I.2.1.

Cch vit ch-ng trnh AutoLISP ......................................................1

I.2.1.1.
I.2.1.2.

Vit trc tip: ....................................................................................1


Vit thnh ch-ng trnh: ..................................................................2

I.2.2.
I.2.3.

Cc hm ........................................................................................................2
Cc bin nh ...............................................................................................3

I.3.

cc Kiu d liu c bn ......................................................3

I.3.1.
I.3.2.
I.3.3.
I.3.4.
I.3.5.
I.3.6.
I.3.7.
I.3.8.
I.3.9.
I.3.10.
I.3.11.

Kiu danh sch (list) ...............................................................................3


Kiu s nguyn (Int) .................................................................................4
Kiu s thc (Real)..................................................................................4
Kiu chui k t (String) .......................................................................4
Kiu k hiu (Symbol) ...............................................................................4
Kiu i t-ng (AutoCAD Entity) ........................................................5
Kiu nhm i t-ng (AutoCAD selection set) .............................5
Kiu tp (File) .............................................................................................5
Kiu hm chun ca AutoLISP ..............................................................5
Kiu hm ngoi ...........................................................................................5
S PI v Nil ...................................................................................................5

I.4.
I.5.

Hm do ng-i lp trnh nh ngha ..............................5


Cc hm chun ca Autolisp ..........................................8

I.5.1.

Php gn ......................................................................................................8

I.5.1.1.
I.5.1.2.
I.5.1.3.

Hm (setq.......) .................................................................................8
Hm (set .......) .................................................................................8
Hm (setvar .......) ............................................................................9

I.5.2.

Cc hm chuyn lnh t AutoLISP sang AutoCAD .......................9

I.5.2.1.
I.5.2.2.

Hm (Load.....) .................................................................................9
Hm (Command.....) ...................................................................... 10

I.5.3.

Cc hm nhp d liu t ng-i dng ..............................................11

I.5.3.1.
I.5.3.2.
I.5.3.3.
I.5.3.4.
I.5.3.5.
Stt

Hm (getpoint .....) ........................................................................ 11


Hm (getcorner ....) ....................................................................... 11
Hm (getdist ....) ............................................................................ 12
Hm (getangle ....) ......................................................................... 12
Hm (getorient ....) ........................................................................ 13
Trang
Ni dung

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

62

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.3.6.
I.5.3.7.

Hm (getint ....) ............................................................................. 13


Hm (getreal ....) ........................................................................... 14

I.5.4.

Hm (iniget ....)......................................................................................... 14

I.5.4.1.
I.5.4.2.
I.5.4.3.

Hm (getkword ....) ....................................................................... 15


Hm (getstring ....) ........................................................................ 16
Hm (getvar ....) ............................................................................ 16

I.5.5.

Cc hm ton hc ................................................................................. 17

I.5.5.1.
I.5.5.2.
I.5.5.3.
I.5.5.4.
I.5.5.5.
I.5.5.6.
I.5.5.7.
I.5.5.8.
I.5.5.9.
I.5.5.10.
I.5.5.11.
I.5.5.12.
I.5.5.13.
I.5.5.14.
I.5.5.15.

Cc php tnh ................................................................................. 17


Cc php so snh ............................................................................ 17
Hm (eq ... ) ................................................................................... 18
Hm (equal ... ) .............................................................................. 19
Hm (max ... ) ................................................................................ 19
Hm (min ... ) ................................................................................. 19
Hm (gcd ... ) ................................................................................. 20
Hm (rem ... ) ................................................................................. 20
Cc hm i s: .............................................................................. 20
Cc hm l-ng gic: .................................................................. 21
Hm (polar ...) ............................................................................ 21
Hm (angle ...) ........................................................................... 22
Hm (distance ...) ....................................................................... 22
Hm (inters ...) ........................................................................... 23
Hm (osnap ...) ........................................................................... 23

I.5.6.

Cc hm to cu trc iu khin .................................................... 24

I.5.6.1.
I.5.6.2.
I.5.6.3.
I.5.6.4.
I.5.6.5.
I.5.6.6.

Hm (if ....)..................................................................................... 24
Hm (cond ....) ............................................................................... 24
Hm (progn ....) .............................................................................. 25
Hm (repeat ....) ............................................................................. 25
Hm (while ....) .............................................................................. 26
Hm (foreach ....) ........................................................................... 26

I.5.7.

Cc hm x l danh sch. ................................................................... 27

I.5.7.1.
I.5.7.2.
I.5.7.3.
I.5.7.4.
I.5.7.5.
I.5.7.6.
I.5.7.7.
I.5.7.8.
I.5.7.9.
I.5.7.10.
I.5.7.11.
I.5.7.12.
I.5.7.13.
Stt

Hm (quote ....) hoc '(...) ............................................................. 27


Hm (list ....) .................................................................................. 27
Hm (car ....) .................................................................................. 28
Cc hm t-ng t nh- (car ....)....................................................... 28
Hm (reverse ....)........................................................................... 28
Hm (length ....) ............................................................................. 29
Hm (append ....)............................................................................ 29
Hm (member ....) .......................................................................... 29
Hm (cons ....) ................................................................................ 30
Hm (assoc ....) .......................................................................... 30
Hm (subst ....) ........................................................................... 31
Hm (lambda ....) ....................................................................... 31
Hm (apply ....) .......................................................................... 32
Trang
Ni dung

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.7.14.

63

Hm (mapcar ....) ....................................................................... 33

I.5.8.

Cc hm nhp - xut d liu. ..............................................................33

I.5.8.1.
I.5.8.2.
I.5.8.3.
I.5.8.4.
I.5.8.5.
I.5.8.6.
I.5.8.7.
I.5.8.8.
I.5.8.9.
I.5.8.10.

Hm (prompt.......) ......................................................................... 33
Hm (open.......) ............................................................................. 34
Hm (close.......) ............................................................................ 34
Hm (findfile.......)......................................................................... 35
Hm (read-line ....) ........................................................................ 35
Hm (read....)................................................................................. 36
Hm (read-char ....) ....................................................................... 36
Hm (write-char ....) ...................................................................... 37
Hm (write-line ....) ....................................................................... 37
Cc hm prin1 , princ , v print ................................................. 37

I.5.9.

Cc hm kim tra kiu d liu. ...........................................................38

I.5.9.1.
I.5.9.2.
I.5.9.3.
I.5.9.4.
I.5.9.5.
I.5.9.6.
I.5.9.7.
I.5.9.8.

Hm (type ....)................................................................................ 38
Hm (boundp ....) .......................................................................... 39
Hm (null ....) ................................................................................ 39
Hm (atom ....) .............................................................................. 40
Hm (listp ....)................................................................................ 40
Hm (numberp ....) ........................................................................ 40
Hm (minusp ....)........................................................................... 41
Hm (zerop ....) .............................................................................. 41

I.5.10.

Cc hm chuyn i kiu d liu. .....................................................41

I.5.10.1.
I.5.10.2.
I.5.10.3.
I.5.10.4.
I.5.10.5.
I.5.10.6.
I.5.10.7.
I.5.10.8.
I.5.10.9.
I.5.11.

Hm (angtof ....) ........................................................................ 41


Hm (angtos ....) ........................................................................ 42
Hm (atof ....) ............................................................................ 42
Hm (atoi ....) ............................................................................ 43
Hm (itoa ....) ............................................................................ 43
Hm (rtos....) ............................................................................. 43
Hm (distof....) .......................................................................... 44
Hm (fix....) ............................................................................... 44
Hm (float....) ............................................................................ 45
Cc hm x l chui k t. ..................................................................45

I.5.11.1.
I.5.11.2.
I.5.11.3.
I.5.11.4.
I.5.11.5.
I.5.11.6.
I.5.12.

Hm (strcat ....) .......................................................................... 45


Hm (strcase ....) ....................................................................... 46
Hm (strlen ....) ......................................................................... 46
Hm (substr ....) ......................................................................... 47
Hm (chr ....) ............................................................................. 47
Hm (ascii ....) ........................................................................... 48
Cc hm thao tc vi cc i t-ng (entity) ca Autocad ...48

I.5.12.1.
I.5.12.2.
I.5.12.3.
Stt
I.5.12.4.

Hm (entlast) ............................................................................. 48
Hm (entnext)............................................................................ 48
Hm (entsel) .............................................................................. 49
Trang
Ni dung
Hm (nentsel) ............................................................................ 50

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

64

Lp trnh ng dng trong AutoCAD - AutoLISP

I.5.12.5.
I.5.12.6.
I.5.12.7.
I.5.12.8.
I.5.12.9.
I.5.12.10.
I.5.12.11.
I.5.12.12.
I.5.12.13.
I.5.12.14.
I.5.12.15.
I.5.12.16.
I.5.12.17.
I.5.13.

I.5.13.1.
I.5.13.2.
I.5.13.3.
I.5.13.4.

Hm (nentselp) ........................................................................... 50
Hm (entdel) .............................................................................. 50
Hm (entget) .............................................................................. 51
Hm (entmod) ............................................................................ 52
Hm (entupd...) .......................................................................... 53
Hm (entmake ...) ...................................................................... 53
Hm (tblnext...) .......................................................................... 54
Hm (tblsearch...) ...................................................................... 55
Hm (ssget...) ............................................................................. 56
Hm (ssadd...) ............................................................................ 58
Hm (ssdel...) ............................................................................. 58
Hm (sslength...) ........................................................................ 59
Hm (ssname...) ......................................................................... 59
Cc hm x l mn hnh ....................................................................... 59

Hm (redraw...) .......................................................................... 59
Hm (terpri) ............................................................................... 60
Hm (graphscr) .......................................................................... 60
Hm (textscr ) ............................................................................ 60

Nguyn Vn Thip Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 117

ph lc 1
bng m cc c tnh ca i t-ng AutoCAD
Trong bng m (code) ny chng ti gii thiu cc m qun l mt i t-ng
-c dng trong cc lnh ENTMAKE, ENTGET v.v...
tin cho vic tra cu, nhng m no dng chung cho tt c cc i t-ng
chng ti ti mc m chung. Nhng m c cng gi tr nh-ng nhng i
t-ng khc nhau c ngha khc nhau nn chng ti t chng vo cc mc
theo i t-ng. Trong bng ny c ton b cc i t-ng c 2D v 3D ca
AutoCAD.
S rng buc ca m vi cc i t-ng c hai tr-ng hp:
1- Phi c (Not omitted) - bt buc phi c mt ca m trong
danh sch to nn i t-ng, nu thiu i t-ng
khng -c to ra.
2 - Tu (optional) - c th c mt, nu khng c mt th c
tnh -c ly theo mc nh, trong mc ngha c
t trong du ngoc (tu chn).
P1.1. M chung cho tt c cc i t-ng
M s
-1
0
5
6
8
38
39
48

Kiu gi tr
ENAME
STR
STR
STR
STR
REAL
REAL
REAL

62

INT

67

INT

ngha
Tn i t-ng
Kiu i t-ng nh- LINE, ARC..
M iu khin (handle) ca i t-ng.
Tn kiu nt v.
Tn lp cha i t-ng.
Gi tr ELEVATION.
Gi tr THICNESS.
T l -ng nt (Linetype scale)
(tu chn, mc nh: 1.0)
Mu ca i t-ng (tu chn, mc nh l
BYLAYER):
0
BYBLOCK
256 BYLAYER
Khng gian v i t-ng (tu chn, mc nh: 0)
Gi tr 0 i t-ng thuc MSPACE
Gi tr 1 i t-ng thuc PSPACE

P1.2. Mt 3D (3DFACE)
M s
Kiu gi tr
ngha
10
LIST
Ta im gc th nht ca mt (trong WCS).
11
LIST
Ta im gc th hai ca mt (trong WCS).
12
LIST
Ta im gc th ba ca mt (trong WCS).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

118 Lp trnh ng dng trong AutoCAD - Trnh n


13

LIST
Ta im gc th t- ca mt (trong WCS).
L-u : gia m s v to im khng c du chm (.)
V d:
((-1 . <Entity name: 2640520>) (0 . "3DFACE")
(5 . "4C") (100 . "AcDbEntity")
(67 . 0) (8 . "0") (100 . "AcDbFace") (10
6.09365 4.73754 0.0) (11 4.0 5.0 7.0)
(12 3.0 8.0 9.0) (13 2.0 1.0 0.0) (70 . 0))

70

INT

Che khut cc cnh (tu chn, ngm nh: 0)


0 = khng cnh no b khut.
1 = cnh th nht b khut.
2 = cnh th 2 b khut.
4 = cnh th 3 b khut.
8 = cnh th 4 b khut.

P1.3. M hnh th c (3Dsolid)


M s
Kiu gi tr
ngha
70
INT
S hiu hnh dng ca m hnh (hin hnh = 1)
1
STR
Cc dng ghi d liu c th ca m hnh, mi
khi vn bn < 255 k t
3
STR
Cc dng tip theo ca d liu (nu khi trn
qu 255 k t)
P1.4. Cung trn (ARC)
M s
Kiu gi tr
ngha
10
LIST
Ta tm im (trong OCS).
39
REAL
Chiu cao ca mt c bin dng l cung trn
theo trc Z (Thicness) (tu chn, ngm nh:
0.0)
40
REAL
Bn knh.
50
REAL
Gc xut pht ca cung (radian)
51
REAL
Gc kt thc ca cung (radian)
210
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)
P1.5. Khi vn bn c bin nh (ATTDEF)
M s
Kiu gi tr
ngha
1
STR
Gi tr ban u (mc nh) ca bin nh.
2
STR
Tn khi (tag string)
3
STR
Dng nhc nhp gi tr cho bin nh.
7
STR
Kiu ch (text style).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 119

10

LIST

11

LIST

39

REAL

40
50

REAL
REAL

51

REAL

70

INT

71

INT

72

INT

73
74

INT
INT

210

LIST

Ta im cn chnh th nht ca dng (trong


OCS).
Ta im cn chnh th hai ca dng (trong
OCS).
Chiu cao ca mt c bin dng l dng ch
theo trc Z (Thicness) (tu chn, ngm nh:
0.0)
Chiu cao ch.
Gc xoay ca dng ch (tu chn, ngm nh =
0.0)
Gc nghing ca k t (tu chn, ngm nh =
0.0)
M c hiu (Attribute flage)
1 = khng m ra.
2 = l mt hng.
4 = c xc nh li khi nhp gi tr mi.
8 = khi -c thit lp nh- c, khng
hin dng nhc khi chn vo bn v.
M khi sinh text (tu chn, ngm nh = 0,
xem mc text)
iu khin cn chnh dng ch (tu chn, ngm
nh = 0, xem mc text)
Chiu di dng (tu chn, ngm nh = 0)
Cn chnh theo chiu thng ng (tu chn,
ngm nh = 0, xem mc text)
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)

P1.6. -ng trn (CIRCLE)


M s
Kiu gi tr
ngha
10
LIST
Ta tm im (trong OCS).
39
REAL
Chiu cao ca mt c bin dng l -ng trn
theo trc Z (Thicness) (tu chn, ngm nh:
0.0)
40
REAL
Bn knh.
210
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

120 Lp trnh ng dng trong AutoCAD - Trnh n


P1.7. Kch th-c (DIMENSION)
P1.7.1. M chung cho nhm Kch th-c (DIMENSION)
M s
Kiu gi tr
ngha
1
STR
Gi tr ban u ca dng ch kch th-c (tu
chn, ngm nh l gi tr o -c). Nu khng
c (null - "" hai du nhy lin nhau) hoc cho
"<>", s l gi tr o -c. Nu cho " " (mt du
cch), gi tr kch th-c b trng khi hin trn
mn hnh (suppressed).
2
STR
Tn khi cha cc thnh vin ca kch th-c.
3
STR
Tn kiu kch th-c (dimension style).
10
LIST
Ta im im nh v -ng kch th-c
(trong WCS).
11
LIST
Ta im gia dng ch kch th-c (trong
OCS).
53
REAL
Gc xoay ca dng ch kch th-c so vi
ph-ng ngm nh.
51
REAL
Xc nh ph-ng ca ch ghi v -ng kch
th-c theo ph-ng thng ng, nm ngang hoc
b xoay ca kch th-c di.
70
INT
M nh dng ghi kch th-c:
0 = Rotate, horizontal hoc vertical.
1 = Aligned.
2 = Angular.
3 = Diameter.
4 = Radius.
5 = Angular 3 point.
6 = Ordinate.
32 = Chng t l mt khi khi tham chiu
64 = To , nu c t l gi tr X, nu
khng, gi tr l ca Y.
210
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)
P1.7.2. Dng ghi kch th-c Align, Linear v Rotate
M s
Kiu gi tr
ngha
12
LIST
To im bt u ca kch th-c ghi theo
dng Baseline v Continue (trong OCS).
13
LIST
Ta im o th nht (trong WCS).
14
LIST
Ta im o th hai (trong WCS).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 121

Hnh minh ho cc m ch th
cc im ca khi kch th-c
di.
P1.7.3. Dng ghi kch th-c Radial v Diameter
M s
Kiu gi tr
ngha
15
LIST
To im bt vo cung hoc -ng trn
ghi kch th-c (trong WCS).
40
REAL
di -ng dn ghi bn knh hoc -ng knh

P1.7.4. Dng ghi kch th-c gc Angular


M s
Kiu gi tr
ngha
13
LIST
To im u mt ca on thng l mt
cnh ca gc cn o (trong WCS).
14
LIST
To im u mt ca on thng l mt
cnh ca gc cn o (trong WCS).
15
LIST
To im u mt ca on thng th hai l
cnh khc ca gc cn o (trong WCS).
10
LIST
To im u mt ca on thng th hai l
cnh khc ca gc cn o (trong WCS).
16
LIST
Ta im nh v ca cung cha mi tn ni
hai cnh ca gc (trong OCS).

a) Gc gia hai on thng

b) Gc m cung trn

P1.7.5. Dng ghi kch th-c ta im Ordinate


M s Kiu gi tr
ngha
13
LIST
To im ly kch th-c (trong WCS).
14
LIST
To u mt ca on thng ko di t im
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

122 Lp trnh ng dng trong AutoCAD - Trnh n

15

LIST

10

LIST

cn o n ch ghi kch th-c (leader) (trong


WCS).
To im u mt ca on thng th hai l
cnh khc ca gc cn o.
Gc ta UCS.

P1.7.6. Dng ghi kch th-c Leader


M s Kiu gi tr
ngha
10
LIST
To cc nh ca -ng dn gy khc (mi
nh c mt danh sch bt u bng m s 10).
40
REAL
Chiu cao ch ghi ch.
41
REAL
Chiu rng ch ghi ch.
71
INT
M hiu hnh dng u mt
0 = khng c mi tn.
1 = c mi tn.
72
INT
M hiu hnh dng -ng ko
0 = gm cc on thng.
1 = l cc on -ng cong (spline).
73
INT
M hiu to kiu Leader
0 = km theo ch ghi kch th-c hoc ghi
ch.
1 = km theo ghi dung sai (Tolerance).
2 = km theo khi hnh v (Block).
74
INT
M hiu nh h-ng ca -ng neo
0 = -ng neo (hoc tip tuyn ca
leader dng -ng cong) ng-c h-ng
vi vect nm ngang.
1 = -ng neo (hoc tip tuyn ca leader
dng -ng cong) cng h-ng vect nm
ngang.
75

INT

M hiu -ng neo


0 = khng c -ng neo.
1 = c -ng neo.

76

INT

S nh gy khc ca -ng dn.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 123

77

INT

210
211
212

LIST
LIST
LIST

213

LIST

340

ENNAME

Mu ca -ng dn nu
DIMCLRD = BYBLOCK.
Vect php tuyn.
H-ng nm ngang ca -ng dn.
To im chn ca khi tham chiu cch nh
cui ca -ng dn.
To im t ca dng ch cch nh cui ca
-ng dn.
Tn khi ghi ch (khi ch gm nhiu dng
(mtext), dung sai (tolerance) hoc thc th
-c chn vo (insert entity)

P1.8. Hnh Elp (Ellipse)


M s Kiu gi tr
ngha
10
LIST
Tm im (trong WCS).
11
LIST
Ta u mt trc ln so vi tm im.
40
REAL
T l gia trc nh v trc ln.
41
REAL
Tham s u, nhn gi tr 0.0 i vi elp khp
kn.
42
REAL
Tham s cui, nhn gi tr 2 i vi elp khp
kn.
210
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)
i vi cc cung elp (khng khp kn) cc tham s -c tnh theo cng thc
sau:
p(u) = c + a*cos(u) + b*sin(u)
Trong
a = 1/2 trc ln
b = 1/2 trc nh
c l tm im ca Elp.
T cng thc tnh bng Vect trn c th chuyn thnh cng thc tnh theo X
v Y:
p(u) = (Cx+a*cos(u))*i + Cy+b*sin(u))*j
Trong
a = 1/2 trc ln
b = 1/2 trc nh
i, j cc vect n v ca trc X v trc Y.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

124 Lp trnh ng dng trong AutoCAD - Trnh n


P1.9. Mt ct (Hatch)
P1.9.1. M chung
M s
Kiu gi tr
ngha
2
STR
Tn bng mu t ca mt ct.
10
LIST
Ta im nng cao theo trc Z (Elevation
point), trong 3D X = 0, Y = 0, Z = cao
(trong OCS).
41
REAL
T l khong cch gia cc nt to nn mu t
(scale)
47
REAL
Kch th-c im nh (pixel size)
(tu chn).
52
REAL
Gc nghing ca mu t.
70
INT
M hiu t c (solid fill flag)
t c (solid) = 1
cc mu khc = 0
71
INT
M hiu thnh khi hay bung ra
(associative flag)
khi (associative) = 1
bung ra (non-associative) = 0
75
INT
M hiu kiu t (hatch style)
0 = Normal
1 = Outer
2 = Ignore
76
INT
M hiu dng mu t (pattern type)
0 = user-defined (t nh ngha)
1 = predefined (theo mu nh
ngha tr-c ca AutoCAD)
2 = custom (theo mu mi to)
77
INT
M hiu dng mu t p (pattern double
flag)
t p (double) = 1.
t n (not double) = 0.
91
INT
S -ng bao kn (mi vng din tch khp kn
cn t c mt -ng bao kn)
98
INT
S im chn (mi vng din tch khp kn cn
t c mt im chn)
10
LIST
Ta im chn (theo sau m 98)
210
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 125

P1.9.2. D liu ca -ng bao


M s
Kiu gi tr
ngha
92
INT
M hiu kiu -ng bao
0 = mc nh (default).
1 = m rng (external).
2 = a tuyn (polyline).
4 = derived
8 = textbox
16 = ngoi cng (outermost)
cc s khc = cc d liu ca -ng bao
kiu a tuyn.
93
INT
S cnh ca -ng bao
72
INT
M hiu kiu ca cc cnh
1 = on thng (line).
2 = cung trn (circilar arc).
3 = cung elp (ellipse arc).
4 = -ng cong trn (spline).
cc s khc = cc d liu ca cnh khng
phi l a tuyn (not a polyline)
97
INT
S i t-ng ca mt -ng bao.
330
ENTNAME
Tn cc i t-ng to thnh -ng bao.
i vi cc -ng bao ng nht mt kiu -ng c cc m ring.
P1.9.3. D liu ca -ng bao l Polyline
M s
Kiu gi tr
ngha
72
INT
C cho m hiu ch li.
73
INT
M hiu s khp kn (close) ca a tuyn.
42
REAL
li (bulge) (tu chn, mc nh = 0.0).
93
INT
S nh.
10
LIST
Ta nh (mi nh mt ta km theo sau
m s 10).
P1.9.4. D liu ca -ng bao c cnh l on thng (Line)
M s
Kiu gi tr
ngha
10
LIST
Ta im u (trong h ta OCS).
11
LIST
Ta im cui (trong h ta OCS).
P1.9.5. Bng m d liu ca -ng bao cnh l cung trn
(Arc)
M s
Kiu gi tr
ngha
10
LIST
Tm im (trong h ta OCS)
40
REAL
Bn knh.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

126 Lp trnh ng dng trong AutoCAD - Trnh n


50
51
73

REAL
REAL
INT

Gc u tin.
Gc cui cng.
M nh h-ng ng-c chiu kim ng h.

P1.9.6. D liu ca -ng bao cnh l Elp (Ellipse)


M s
Kiu gi tr
ngha
10
LIST
Tm im (trong h ta OCS).
11
LIST
im cui ca trc ln (trong h ta OCS).
40
REAL
di trc nh.
50
REAL
Gc u tin.
51
REAL
Gc cui cng.
73
INT
M nh h-ng ng-c chiu kim ng h.
P1.9.7. D liu ca -ng bao cnh l -ng cong bc cao
(Spline)
M s
Kiu gi tr
ngha
10
LIST
Tm im cc cung (trong h ta OCS).
40
REAL
Gi tr ca cc im nt (knot value).
42
REAL
Cn bng (weights)
(tu chn, mc nh = 1).
73
REAL
Hu t (Rational)
74
REAL
Chu k (Periodic)
94
INT
Bc ca -ng cong (Degree)
95
INT
S nt
96
INT
S im kim sot (control point).
P1.9.8. D liu ca mu t
M s
Kiu gi tr
ngha
43
REAL
Gi tr X ca im c s ca on thng to ra
mu t.
44
REAL
Gi tr Y ca im c s to ra mu t.
45
REAL
Gi tr offset theo ph-ng X ca on thng
to ra mu t.
46
REAL
Gi tr offset theo ph-ng Y ca on thng
to ra mu t.
49
REAL
di cc nt t
53
REAL
Gc nghing ca cc on thng to ra mu t.
79
INT
S on nt t tham gia vo mu t.
P1.10.
M s
10

nh (Image)
Kiu gi tr
ngha
LIST
Ta im chn (trong h OCS).

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 127

11

LIST

12

LIST

13
14
70

REAL
LIST
INT

71

INT

91
280

INT
INT

281
282

REAL
REAL

283
340

REAL
ENAME

P1.11.
M s
2
10
41
42
43
50
70
71
44
45
210

U - vect ca im gc trn ca nh (bt u t


im chn, trong h OCS)
V - vect ca im gc cnh tri ca nh (bt
u t im chn, trong h OCS)
C nh (tnh bng pixel)
To cc nh ca -ng bin xn nh.
M iu khin hin nh
1 = hin nh.
2 = hin nh khi khng cn chnh vi mn
hnh.
3 = c s dng -ng bin xn nh.
4
= bt
ch
trong
sut
(transparence ON).
Kiu -ng bao xn nh
1 = hnh ch nht (rectangular).
2 = a gic (polygonal).
S nh ca -ng bin xn nh.
Trng thi xn nh
0 = off.
1 = on.
sng (t 0 n 100, mc nh l 50).
t-ng phn nh sng (t 0 n 100, mc nh
l 50).
m (t 0 n 100, mc nh l 50).
Tn nh chn vo.

Cc i t-ng chn (Insert)


Kiu gi tr
ngha
ENAME
Tn khi.
LIST
Ta im chn (trong h OCS).
REAL
T l theo trc X (tu chn, mc nh = 1).
REAL
T l theo trc Y(tu chn, mc nh = 1).
REAL
T l theo trc Z (tu chn, mc nh = 1).
REAL
Gc xoay (tu chn, mc nh = 0).
INT
S hng (tu chn, mc nh = 1)
INT
S ct (tu chn, mc nh = 1)
REAL
Khong cch gia cc ct (tu chn, mc nh =
0)
REAL
Khong cch gia cc hng (tu chn, mc nh
= 0)
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

128 Lp trnh ng dng trong AutoCAD - Trnh n


P1.12.
M s
10
11
39
210

on thng (Line)
Kiu gi tr
ngha
LIST
Ta im u (trong h WCS).
LIST
To im cui (trong h WCS).
REAL
Chiu cao ca mt theo trc Z (thickness)
(tu chn, mc nh = 0).
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)

P1.13.
M s
10
11

Tia (Ray)
Kiu gi tr
LIST
LIST

P1.14.
M s
2
10
11
12

on thng i (Mline)
Kiu gi tr
ngha
STR
Chui ti a 32 k t tn ca kiu -ng i.
LIST
Ta im u (trong h WCS).
LIST
To cc nh (trong h WCS).
LIST
Vect nh h-ng ca on xut pht t nh
ny.
LIST
Vect nh h-ng ca on ni vung gc ti
nh ny.
REAL
Khong cch gia hai nt.
INT
Cn chnh
0 = top.
1 = zero.
2 = bottom.
INT
M ch s khp kn (close) hoc h (open)
1 = h (open).
3 = kn (close).
INT
S nh
INT
S thnh vin trong bin MLINESTYLE.
INT
S tham s cho mi on.
REAL
Tham s thnh phn (xem gii thch pha d-i).
INT
S tham s ca din tch t m.
REAL
Tham s din tch t m (xem gii thch pha
d-i).
LIST
H-ng ko dn thnh mt trong khng gian
(Extrusion direction) (tu chn, ngm

13
40
70

71

72
73
74
41
75
42
210

ngha
Ta im u (trong h WCS).
To im ngn ca vect ch ph-ng (trong
h WCS).

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 129

nh: theo chiu d-ng trc Z = 0,0,1)


M s 41:
Tham s l mt danh sch s thc. Trong danh sch c th cha s 0
hoc s khc 0.
Gi tr u tin l khong cch t nh ca on dc theo vect vung
gc n giao im ca -ng dn h-ng vi vect vung gc.
Gi tr th hai l khong cch dc theo -ng dn h-ng t im xc
nh gi tr th nht n im xut pht ca on tip theo.
Gi tr tip theo l khong cch t im xut pht ca mt on thng
n im gy khc u tin.
M s 41:
y cng l danh sch s thc, ging nh- m 41, n m t cc tham s
ca phn t m ca mt on ca Mline.
P1.15.
M s
1
3
7
10
11
40
41
42
43
50
71

72

Khi ch nhiu dng (Mtext)


Kiu gi tr
ngha
STR
Ni dung dng ch. Nu ni dung dng ch >
255 k t, cc k t sau k t th 250 s cho
xung m s 3.
STR
Ni dung tip theo ca dng ch.
STR
Tn kiu ch , lun l STANDARD nu khng
c cc tn khc.
LIST
Ta khi u (insert point).
LIST
Vect dn h-ng ca trc X (trong h WCS).
REAL
Chiu cao ca ch.
REAL
Chiu rng hnh ch nht cha khi ch.
REAL
Chiu di dng ch (th-ng nh hn hoc bng
gi tr cho ti m 41).
REAL
Chiu cao ca khi ch.
REAL
Gc nghing ca dng ch (tnh bng radian).
INT
Cn chnh
1 = nh tri (top left).
2 = nh tm (top center).
3 = nh phi (top right).
4 = gia tri (middle left).
5 = gia tm (middle center).
6 = gia phi (middle right).
7 = y tri (bottom left).
8 = y tm (bottom center).
9 = y phi (bottom right).
INT
H-ng v ch
1 = tri qua phi;
2 = phi qua tri .
3 = trn xung d-i; 4 = d-i ln trn.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

130 Lp trnh ng dng trong AutoCAD - Trnh n


210

P1.16.
M s
10
39
50
210

P1.17.
M s
39
40
41
70

71
72
73
74
75

LIST

H-ng ko dn thnh mt trong khng gian


(Extrusion direction) (tu chn, ngm
nh: theo chiu d-ng trc Z = 0,0,1)

im (Point)
Kiu gi tr
ngha
LIST
Ta im (trong h WCS).
REAL
Chiu cao ko dn theo trc Z (thickness).
REAL
Gc nghing so vi trc X theo UCS (tu chn,
mc nh = 0).
LIST
H-ng ko dn trong khng gian (Extrusion
direction) (tu chn, ngm nh: theo chiu
d-ng trc Z = 0,0,1)
a tuyn (Polyline)
Kiu gi tr
ngha
REAL
Chiu cao ko dn theo trc Z (thickness).
REAL
B rng im xut pht ca a tuyn (tu chn,
mc nh = 0).
REAL
B rng im cui ca a tuyn (tu chn, mc
nh = 0).
INT
M c hiu ch dng a tuyn
1 = a tuyn khp kn (hoc mt l-i a
gic khp kn theo cnh M).
2 = -ng a tuyn b lm thnh cong trn
bng Curve-fit.
4 = cc nh b v trn theo Curvespline.
8 = -ng a tuyn 3D.
16 = mt l-i a gic.
32 = mt l-i a gic khp kn theo cnh
N.
64 = mt a din.
INT
S nt l-i theo cnh M
(tu chn, mc nh = 0).
INT
S nt l-i theo cnh N
(tu chn, mc nh = 0).
INT
cong trn (smooth) ca mt theo cnh M
(tu chn, mc nh = 0).
INT
cong trn (smooth) ca mt theo cnh N
(tu chn, mc nh = 0).
INT
M c hiu ch dng trn nhn b mt ca a
din

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 131

210

P1.18.
M s
10
11
12
13
40
41
42
43
44
70

LIST

0 = khng -c lm trn.
5 = mt Quandratic B-spline.
6 = mt Cubic B-spline.
8 = mt Bezier.
H-ng ko dn trong khng gian (Extrusion
direction) (tu chn, ngm nh: theo chiu
d-ng trc Z = 0,0,1)

-ng cong bc cao (Spline)


Kiu gi tr
ngha
LIST
im kim sot (control point) gm im
un v giao im ca cc tip tuyn i qua im
un. Mi im mt m s 10 (trong h WCS).
LIST
To im nh v -ng cong (fit point)
(trong h WCS). Mi nh c mt m s 11.
LIST
Tip im u tin (c th b qua khng cn cho
vo) (trong h WCS).
LIST
Tip im cui (c th b qua khng cn cho
vo) (trong h WCS).
REAL
Gi tr ca nt.
REAL
Cn bng (weight)
REAL
Sai s cho php ca nt (mc nh = 0,0000001).
REAL
Sai s cho php ca im chn cho -ng cong i
qua khi v (control point, mc nh =
0,0000001).
REAL
Sai s cho php ca nh (fit point, mc
nh = 0,0000000001).
INT
M c hiu ch dng -ng cong
0 = -ng cong 3D.
1 = khp kn (closed).
2 = c chu k (periodic).
4 = hu t (rational).
8 = nm trong mt mt phng (planar)
16 = nh- mt on thng (linear), km theo
vi bit s 8 thnh 24.
v d:

71
72
73
74

REAL
INT
INT
INT

Nu -ng cong v ra nh- mt on thng


m 70 s tr ra l (70. 24)
Bc ca -ng cong nh (degree).
S nt.
S im kim sot (control point).
S im nh v (fit point).

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

132 Lp trnh ng dng trong AutoCAD - Trnh n


P1.19.
M s
10
11
12
13
39
210

a gic t c (Solid)
Kiu gi tr
ngha
LIST
nh th nht.
LIST
nh th hai.
LIST
nh th ba.
LIST
nh th t-.
REAL
Chiu cao ko dn theo trc Z (thickness).
LIST
H-ng ko dn trong khng gian (Extrusion
direction) (tu chn, ngm nh: theo chiu
d-ng trc Z = 0,0,1)

P1.20.
M s

Dng ch (Text)
Kiu
ngha
gi tr
STR
Ni dung dng ch.
STR
Tn kiu ch (text style), (tu chn, mc nh =
STANDARD).
LIST
im cn chnh th nht (trong h OCS).
LIST
im cn chnh th hai (trong h OCS).
REAL Chiu cao ch.
REAL T l gia chiu rng v chiu cao ch (width factor),
(tu chn, mc nh = 1.0).
REAL Gc nghing dng ch (text rotation), (tu chn,
mc nh = 0).
REAL Gc nghing ca k t (oblique angle), (tu chn,
mc nh = 0).
INT
M hiu h-ng k t (tu chn, mc nh = 0)
2 = ch ng-c phi sang tri (backward).
4 = ch ng-c trn xung d-i (upside down).
INT
M cn chnh theo ph-ng ngang (tu chn, mc nh =
0)
0 = canh tri (left).
1 = gia y dng (center).
2 = canh phi (right).
3 = nm trong hai im cho tr-c, chiu cao t
iu chnh (align), nu cn theo ph-ng ng = 0.
4 = gia khi dng (middle) nu cn theo
ph-ng ng = 0.
5 = nm trong hai im cho tr-c, chiu cao khng
thay i (fit) nu cn theo ph-ng ng = 0.
INT
M cn chnh theo ph-ng ng (tu chn, mc nh =
0)

1
7
10
11
40
41
50
51
71

72

73

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc1 133

0 = dc theo on thng c s (base line).


1 = canh theo y dng (bottom).
2 = canh gia khi dng (middle).
3 = canh theo nh dng (top).
210
LIST
H-ng ko dn trong khng gian (Extrusion
direction) (tu chn, ngm nh: theo chiu d-ng
trc Z = 0,0,1)
S kt hp gia m 72 v m 73 cho kt qu nh- sau:
M 72
3 (top)
2 (middle)
1 (bottom)
0 (baseline)

0
TLeft
MLeft
BLeft
Left

1
TCenter
MCenter
BCenter
Center

2
TRight
MRight
BRight
Right

M 73
3

Align

Middle

Fit

P1.21.
M s
10
11
12
13
39
210

on thng c b rng (Trace)


Kiu gi tr
ngha
LIST
Gc th nht (trong h OCS).
LIST
Gc th hai (trong h OCS).
LIST
Gc th ba (trong h OCS).
LIST
Gc th t- (trong h OCS).
REAL
Chiu cao ko dn theo trc Z (thickness).
LIST
H-ng ko dn trong khng gian (Extrusion
direction) (tu chn, ngm nh: theo chiu
d-ng trc Z = 0,0,1)

P1.22.
M s
10

nh ca a tuyn (Vertex)
Kiu gi tr
ngha
LIST
Ta nh (h OCS trong 2D, h WCS trong
3D).
REAL
B rng im xut pht ca on (tu chn,
mc nh = 0).
REAL
B rng im cui ca on (tu chn, mc
nh = 0).

40
41
P1.23.
M s
10
40
41

Ca nhn (Viewport)
Kiu gi tr
ngha
LIST
Ta tm im nhn (trong h WCS).
REAL
Chiu rng trong khng gian giy v
(paper space).
REAL
Chiu cao trong khng gian giy v
(paper space).

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

134 Lp trnh ng dng trong AutoCAD - Trnh n


(Ht ph lc I)

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 135

ph lc II
cc bin h thng ca autocad
Trong ph lc ny, chng ti lit k cc bin h thng ca AutoCAD
theo vn ABC. Nm -c ngha, cch s dng cc bin ny, chng ta khai
thc AutoCAD v lp trnh ng dng t kt qu m mn hn.
C hai kiu bin. Mt l bin ch c (Read-only), hai l bin c
th thay i sau mi ln t li.
C cc trng thi ca cc bin h thng:
- Khng -c l-u tr (Not saved) c ngha l n ch thay i trong
mt tr-ng hp do ng-i dng t, gi lnh ln tip theo n vn gi gi tr
mc nh.
- L-u tr cng bn v (Saved in: Drawing) khi m bn v l-u
v gi lnh, n cho gi tr t cui cng.
- L-u tr vo h thng, khi khi ng li AutoCAD v gi lnh, gi tr
ci t cui cng xut hin mc nh trn dng nhc.
A
1. ACADPREFIX
Cha -ng dn xc nh theo mi tr-ng lm vic ca AutoCAD. Bin ny
l-u tr -ng dn khi dng lnh Tools - Preferences - File - Support File
Search path.
Kiu gi tr: Chui (String), ch c (Read-only) , khng l-u tr (Not
saved)
Dng lnh:
Command: acadprefix
Kt qu l:
ACADPREFIX=
"C:\a14\SUPPORT;C:\a14\FONTS;C:\a14\bonus\cadtoo
ls;C:\a14\hel..."
(read only)
2. ACADVER
Cha tn phin bn ca AutoCAD.
Kiu gi tr: Chui (String), ch c (Read-only) , khng l-u tr (Not
saved)
Dng lnh: Command: acadver
Kt qu l:
ACADVER = "14.01h (Hardware Lock)" (read only)
3. ACISOUTVER
Cho s hiu phin bn ca ACIS ca cc tp tin ui .SAT khi dng lnh
ACISOUT.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

136

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kiu gi tr: S nguyn (Interger), l-u tr cng bn v (Save in:


Drawing)
Gi tr mc nh (Initial value): 16.
Dng lnh: Command: acisoutver
Dng nhc xut hin:
New value for ACISOUTVER <16>:
Gi tr c th cho l t 15 n 18, 20, 21, v 30.
4. AFLAGS
t m hiu cho lnh ATTDEF (xem ATTDEF).
Kiu gi tr: S nguyn (Interger), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 0.
Dng lnh: Command: aflags
Dng nhc xut hin:
New value for AFLAGS <0>:
Cho mt trong cc gi tr:
0 Khng t thuc tnh.
1 Thuc tnh khng xut hin trn mn hnh khi chn khi vo
bn v.
2 Thuc tnh nhn gi tr khng i
4 Thuc tnh -c thay i mi khi chn khi vo bn v.
8 Cho thuc tnh ngm nh khi chn khi.
5. ANGBASE
Chn gi tr t lm gc 0 cho h to hin hnh UCS (xem lnh
Units).
Kiu gi tr: S thc (Real), l-u tr cng bn v (saved in: Drawing)
Gi tr mc nh (Initial value): 0.000
Dng lnh: Command: angbase
Dng nhc xut hin:
New value for ANGBASE <0>:
6. ANGDIR
Chn h-ng pht trin ca gc tnh t gc 0 trong h to hin hnh UCS
(xem lnh Units).
Kiu gi tr: S nguyn (Integer), l-u tr cng bn v (saved in:
Drawing)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: angdir
Dng nhc xut hin:
New value for ANGDIR <0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 137

Cho cc gi tr sau:
0
Ng-c chiu kim ng h (Counterclockwise).
1
Cng chiu kim ng h (Clockwise).
7. APBOX
t trng thi ca bt im gn vi con tr (xem Autosnap).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: apbox
Dng nhc xut hin:
New value for APBOX <0>:
Cho cc gi tr sau:
0
vung bt im khng xut hin cng con tr.
1
vung bt im c xut hin cng con tr.
8. APERTURE
t kch th-c ca bt im gn vi con tr (xem Autosnap).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 10
Dng lnh: Command: aperture
Dng nhc xut hin:
Object
snap
target
height
(150
pixels)
<current>:
Cho gi tr t 1 n 50.
9. AREA
L-u tr din tch cui cng tnh -c bng cc lnh AREA, LIST, hoc
DBLIST
Kiu gi tr: S thc (Real), khng l-u tr (Not saved).
10. ATTDIA
nh ph-ng thc nhp thuc tnh ca khi bng hp thoi hay trn dng
lnh khi chn vo bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: attdia
Dng nhc xut hin:
New value for ATTDIA <0>:
Cho mt trong cc gi tr:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

138

Lp trnh ng dng trong AutoCAD - Ph lc 2

0
1

Nhp theo li nhc trn dng lnh.


Dng hp thoi.

11. ATTMODE
t trng thi ca thuc tnh ca khi (xem Attdef).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: attdia
Dng nhc xut hin:
New value for ATTMODE <0>:
Cho mt trong cc gi tr sau:
0
Tt c thuc tnh khng hin trn mn hnh khi chn
khi.
1
Gi li trng thi hin hoc khng hin ln mn hnh ca
tng thuc tnh.
2
Tt c cc thuc tnh u hin trn mn hnh khi chn
khi.
12. ATTREQ
Cho s dng gi tr mc nh ca thuc tnh khi khi chn.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: attreq
Dng nhc xut hin:
New value for ATTREQ <0>:
Cho mt trong cc gi tr sau:
0
Dng gi tr mc nh, khng cho nhp gi tr mi i
vi tt c cc thuc tnh.
1
Cho nhp gi tr mi ca thuc tnh.
13. AUDITCTL
t m cho hoc khng cho to tp tin ADT (xem lnh Audit).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: auditctl
Dng nhc xut hin:
New value for AUDITCTL <0>:
Cho mt trong cc gi tr sau:
0
Khng cho ghi vo tp tin ADT .
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 139

Cho ghi vo tp tin ADT.

14. AUNITS
t n v cho gc (xem lnh Units).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: aunits
Dng nhc xut hin:
New value for AUNITS <0>:
Cho mt trong cc gi tr sau:
0
Decimal degrees.
1
Degrees/minutes/seconds.
2
Gradians.
3
Radians.
4
Surveyor's units.
15. AUPREC
t s ch s sau du phy thp phn (xem lnhUnits).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: auprec
Dng nhc xut hin:
New value for AUPRECT <0>:
Cho cc gi tr t 0 n 8.
16. AUTOSNAP
t m iu khin ON hoc OFF cc gi tr marker, SnapTips v
magnet ca lnh AutoSnap (xem lnh AutoSnap).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 7
Dng lnh: Command: autosnap
Dng nhc xut hin:
New value for AUTOSNAP <0>:
Cho cc gi tr sau:
0
t OFF cho marker, SnapTip, v magnet
1
t ON cho marker
2
t ON cho SnapTip
4
t ON cho magnet
Nu tt c u nhn ON gi tr cn cho l 7.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

140

Lp trnh ng dng trong AutoCAD - Ph lc 2

B
17. BACKZ
Cha gi tr ca phn xn hnh ca ca nhn.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Dng lnh: Command: backz
Kt qu:
BACKZ = 0.0000 (read only)
18. BLIPMODE
Cho hin hoc khng hin du ly ta im trn mn hnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: blipmode
Dng nhc xut hin:
ON/OFF <OFF>:
Cho ON hoc OFF hoc cc s nguyn:
0
off (khng hin du to ).
1
on (c nh du to ).

C
19. CDATE
Hin th ngy thng v thi gian.
Kiu gi tr: S thc (Real), ch c (Read-only), khng l-u tr (Not
saved).
Dng lnh: Command: cdate
Kt qu:
Initializing...
Mon 1999/3/29 14:39:53.878

20. CECOLOR
t gi tr mu cho i t-ng mi (xem lnh Color).
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):"BYLAYER"
Dng lnh: Command: cecolor
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 141

New value for CECOLOR <"BYLAYER">:


Cho gi tr l tn mu hoc cc s ch th mu.
21. CELTSCALE
t t l khong cch cc on ca nt v c bit cho i t-ng sp v
(linetype scaling factor) (xem lnh Ltscale).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):1.00
Dng lnh: Command: celtscale
Dng nhc xut hin:
New scale factor <1.0000>:
Cho gi tr cn thit.
22. CELTYPE
t kiu nt cho cc i t-ng mi (xem lnh Linetype).
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):"BYLAYER"
Dng lnh: Command: celtype
Dng nhc xut hin:
New value for CELTYPE <"BYLAYER">:
Cho tn kiu nt cn t.
23. CHAMFERA
t khong cch ca on th nht cn vt gc (xem lnh Chamfer).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.500
Dng lnh: Command: chamfera
Dng nhc xut hin:
New value for CHAMFERA <0.5000>:
Cho gi tr tu .
24. CHAMFERb
t khong cch ca on th hai cn vt gc (xem lnh Chamfer).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.500
Dng lnh: Command: chamfera
Dng nhc xut hin:
New value for CHAMFERB <0.5000>:
Cho gi tr tu .

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

142

Lp trnh ng dng trong AutoCAD - Ph lc 2

25. CHAMFERC
t khong cch ca on ni hai im vt gc (xem lnh Chamfer).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):1.00
Dng lnh: Command: chamferc
Dng nhc xut hin:
New value for CHAMFERC <1.00>:
Cho gi tr tu .
26. CHAMFERD
t gc to bi on ni hai im vt gc vi i t-ng th nht (xem lnh
Chamfer).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.00
Dng lnh: Command: chamferd
Dng nhc xut hin:
New value for CHAMFERD <0.00>:
Cho gi tr tu .
27. CHAMMODE
t ph-ng php vt gc (xem lnh Chamfer).
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):0
Dng lnh: Command: chammode
Dng nhc xut hin:
New value for CHAMMODE <0>:
Cho mt trong cc gi tr sau:
0
Cho hai khong cch cn vt
1
Cho di on ni hoc gc to bi on vt v i t-ng th
nht.
28. CIRCLERAD
Cho gi tr mc nh bn knh -ng trn.
Kiu gi tr: S thc (Real), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):0.00
Dng lnh: Command: circerad
Dng nhc xut hin:
New value for CIRCLERAD <0.00>:
Cho gi tr tu .

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 143

29. CLAYER
t lp hin hnh.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):"0"
Dng lnh: Command: clayer
Dng nhc xut hin:
New value for CLAYER <"0">:
Cho tn lp cn t thnh lp hin hnh.
30. CMDACTIVE
Cha m ch loi no trong cc lnh sau y hot ng: lnh thng th-ng,
lnh xuyn thu (transparent), lnh p bn (script) hoc hp thoi.
Gi tr tr ra l tng ca cc s sau:
1
Lnh thng th-ng hot ng.
2
Lnh thng th-ng v lnh xuyn thu hot ng.
4
Lnh p bn.
8
Hp thoi hot ng.
16
Cc lnh ca AutoLISP.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: cmdactive
Kt qu:
CMDACTIVE = 1 (read only)
31. CMDDIA
Cho hin hp thoi hay khng trong lnh PLOT v cc lnh ca d liu m
rng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: cmddia
Dng nhc xut hin:
New value for CMDDIA <1>:
Cho mt trong cc gi tr sau:
0
Khng cho hin hp thoi.
1
Cho hin hp thoi.
32. CMDECHO
Cho hin hay khng cho hin cc dng thng bo khi thc hin cc lnh ca
AutoLISP.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

144

Lp trnh ng dng trong AutoCAD - Ph lc 2

Gi tr mc nh (Initial value): 1
Dng lnh: Command: cmdecho
Dng nhc xut hin:
New value for CMDECHO <1>:
Cho mt trong cc gi tr sau:
0
Khng cho hin thng bo
1
Cho hin thng bo.
33. CMDNAMES
Cho hin ln mn hnh tn ca lnh hin hnh hoc lnh xuyn thu
(transparent command).
Gii thch thm:Lnh transparent command chng ti tm dich l
xuyn thu v n c th c triu gi ngay c trong khi
mt lnh khc ang thc hin. Khi triu gi cc lnh ny
trong khi mt lnh khc ang lm vic c th dng c trn
menu hoc trren dng lnh bng cch thm du nhy n '
trc tn lnh.V d cc lnh 'ZOOM, 'PAN,'OSNAP... l
cc lnh xyn thu (transparent).

Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u tr


(Not saved).
Dng lnh: Command: cmdnames
Kt qu:
CMDNAMES = "SETVAR" (read only)
34. CMLJUST
Chn im t ko -ng khi v on thng nhiu nt (multiline).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: cmljust
Dng nhc xut hin:
New value for CMLJUST <1>:
Cho mt trong cc gi tr sau:
0
Top
im t ti -ng nm cao nht (tri qua phi).
1
Middle
im t ti khong gia cc -ng (t-ng -ng
vi tu chn Zero trong lnh Mline).
2
Bottom
im t ti -ng nm thp nht (tri qua phi).
35. CMLSCALE
nh khong cch gia hai nt ca Multiline.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):1.00
Dng lnh: Command: cmlscale
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 145

New value for CMLSCALE <1.00>:


Cho gi tr tu . Nu = 0 s l -ng n, < 0 hai -ng trn v d-i
(theo h-ng tri qua phi) s tro v tr.
36. CMLSTYLE
Chn kiu nt cho Multiline.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):"STANDARD"
Dng lnh: Command: cmlstyle
Dng nhc xut hin:
New value for CMLSTYLE <"STANDARD">:
Cho tn kiu nt cn chn.
37. COORDS
t cch hin ta con tr trn dng trng thi.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):1
Dng lnh: Command: coords
Dng nhc xut hin:
New value for COORDS <1>:
Cho mt trong cc gi tr sau:
0
1
2

Ch hin to ca im -c chn trn mn hnh.


Hin ta tuyt i ca con tr.
Hin to tuyt i ca con tr khi khng c lnh, hin to
t-ng i ca con tr khi ang thc hin lnh.

38. CURSORSIZE
nh kch th-c con tr ( di ca hai on vung gc to nn co tr mn
hnh)
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):5
Dng lnh: Command: cursorsize
Dng nhc xut hin:
New value for CURSORSIZE <5>:
Cho gi tr l s nguyn t 1 n 100.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

146

Lp trnh ng dng trong AutoCAD - Ph lc 2

39. CVPORT
Cho s hiu ca ca s trn mn hnh l ca s hot ng (trong tr-ng hp
c nhiu ca nhn trn mn hnh (xem lnh view - tiled viewports).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):2
Dng lnh: Command: cvport
Dng nhc xut hin:
New value for CVPORT <2>:
Cho gi tr l s nguyn, l s hiu ca ca s. Nu c nhiu ca s trn
mn hnh th khi cho s no th con tr chuyn v ca s t-ng ng, ca
s tr thnh ca s hot ng.

D
40. DATE
L-u tr ngy thng ca h thng (ging nh- CDATE).
Kiu gi tr: S thc (Real), ch c (Read-only), khng l-u tr (Not
saved).
Dng lnh: Command: cdate
Kt qu:
Initializing...
Mon 1999/3/29 14:39:53.878

41. DBMOD
Cho bit s hiu chnh ca bn v.
Gi tr tr ra l tng cc s sau:
1
D liu ca i t-ng (Object database) b thay i.
4
Bin s d liu (Database variable) b thay i.
8
Ca s (Window) b thay i.
16
Ca nhn (View) b thay i.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: dbmod
Kt qu:
DBMOD = 0 (read only)
42. DCTCUST
Cha -ng dn v tn tp tin t in kim tra li chnh t.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 147

Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved in:


Registry).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dctcust
Dng nhc xut hin:
New value for DCTCUST, or . for none
<"C:\a14\SUPPORT\sample.cus">:
43. DCTMAIN
Cha tn tp tin t in kim tra li chnh t ca ngn ng dng cho
AutoCAD.
Tn cc tp tin -c k hiu nh- sau:
K hiu
Ngn ng
enu
American English
ena
Australian English
ens
British English (ise)
enz
British English (ize)
ca
Catalan
cs
Czech
da
Danish
nl
Dutch (primary)
nls
Dutch (secondary)
fi
Finnish
fr
French (unaccented capitals)
fra
French (accented capitals)
de
German (Scharfes s)
ded
German (Dopple s)
it
Italian
no
Norwegian (Bokmal)
non
Norwegian (Nynorsk)
pt
Portuguese (Iberian)
ptb
Portuguese (Brazilian)
ru
Russian (infrequent io)
rui
Russian (frequent io)
es
Spanish (unaccented capitals)
esa
Spanish (accented capitals)
sv
Swedish
Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):nhiu nc khc nhau.
Dng lnh: Command: dctmain
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

148

Lp trnh ng dng trong AutoCAD - Ph lc 2

New value for DCTMAIN, or . for none <"enu">:


44. DELOBJ
iu khin vic gi li hay xo khi c s d liu ca bn v cc i t-ng
-c dng to ra cc i t-ng khc.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):1
Dng lnh: Command: delobj
Dng nhc xut hin:
New value for DELOBJ <1>:
Cho mt trong cc gi tr sau:
0
i t-ng -c gi li
1
i t-ng b xo.
45. DEMANDLOAD
Xc nh vic triu gi phn ch-ng trnh ng dng th ba nu trong bn v
c cha cc i t-ng do cc phn mm ny to ra.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):3
Dng lnh: Command: demandload
Dng nhc xut hin:
New value for DEMANDLOAD <3>:
Cho mt trong cc gi tr sau:
0
Khng i hi triu gi (off demand loading).
1
i triu gi trnh ng dng khi m bn v c cha i t-ng
ca phn mm . Ci t ny khng i triu gi ng dng khi
dng mt trong cc lnh ca n.
2
i triu gi trnh ng dng khi dng mt trong cc lnh ca n.
Ci t ny khng i triu gi ng dng khi m bn v c cha
i t-ng ca phn mm .
3
i triu gi trnh ng dng khi dng mt trong cc lnh ca n
hoc khi m bn v c cha i t-ng ca phn mm .
46. DIASTAT
Cha ph-ng thc thot ra khi hp thoi -c s dng gn nht.
Gi tri tr ra l:
0
Cancel
1
OK
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Dng lnh: Command: diastat
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 149

Kt qu:
DIASTAT = 1 (read only).
47. DIMALT
iu khin cho php ghi xen n v chuyn i trong ch kch th-c.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimalt
Dng nhc xut hin:
New value for DIMALT <off>:
Cho trng thi:
Off
Khng cho ghi n v chuyn i.
On
Cho ghi n v chuyn i.
48. DIMADEC
nh s ch s sau du phy thp phn ( chnh xc) ca ch kch th-c
gc.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):-1
Dng lnh: Command: dimadec
Dng nhc xut hin:
New value for DIMADEC <-1>:
Cho mt trong cc s sau:
-1
Ch kch th-c gc c chnh xc theo ci t ca lnh
Units.
0 8 Ch kch th-c gc c chnh xc theo gi tr DIMADEC.
49. DIMALTD
nh s ch s sau du phy thp phn sau trong n v chuyn i ca ch
kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):2
Dng lnh: Command: dimaltd
Dng nhc xut hin:
New value for DIMALTD <2>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

150

Lp trnh ng dng trong AutoCAD - Ph lc 2

Cho mt trong cc s t 0 n 8
50. DIMALTF
nh h s trong n v chuyn i ca ch kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value):25.4000
Dng lnh: Command: dimaltf
Dng nhc xut hin:
New value for DIMALTF <25.4000>:
Cho gi tr tu .
51. DIMALTTD
nh s ch s sau du phy thp phn trong n v chuyn i ca ch dung
sai. Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - alternate units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):2
Dng lnh: Command: dimalttd
Dng nhc xut hin:
New value for DIMALTTD <2>:
Cho gi tr t 0 n 8.
52. DIMALTTZ
M iu khin b cc s 0 v ngha trong ch dung sai ca kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimalttz
Dng nhc xut hin:
New value for DIMALTTZ <2>:
Cho mt trong cc s sau:
0
B s 0 trong feet v inches.
1
s 0 trong feet v inches.
2
s 0 trong feet v b s 0 trong inches.
3
s 0 trong inches v b s 0 trong feet.
i vi cc n v thp phn:
4
B s 0 pha tr-c (leading).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 151

B s 0 pha sau (trailing).

53. DIMALTU
t chuyn i cho tt c cc kiu ghi kch th-c tr kch th-c gc.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):2
Dng lnh: Command: dimaltu
Dng nhc xut hin:
New value for DIMALTU <2>:
Cho mt trong cc s sau:
1
Scientific
2
Decimal
3
Engineering
4
Architectural (stacked)
5
Fractional (stacked)
6
Architectural
7
Fractional
8
Windows Desktop
54. DIMALTZ
M iu khin b cc s 0 v ngha trong ch kch th-c ca cc n v
chuyn i.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimaltz
Dng nhc xut hin:
New value for DIMALTZ <2>:
Cho mt trong cc s sau:
0
B s 0 trong n v feet v inches.
1
nguyn cc s 0 trong n v feet v inches.
2
nguyn cc s 0 trong n v feet v b s 0 trong
inches.
3
nguyn cc s 0 trong n v inches v b s 0 trong
feet.
4
B cc s 0 phn nguyn ng tr-c (leading) cc s thp
phn < 1 (v d 0.5000 s ghi .5000).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

152

Lp trnh ng dng trong AutoCAD - Ph lc 2

8
12

B cc s 0 v ngha pha sau phn thp phn (triling) (v


d, 12.5000 ghi l 12.5).
B cc s 0 c pha tr-c ln pha sau phn thp phn (v d,
0.5000 cn li .5).

55. DIMAPOST
t tip u ng (text prefix) hoc tip v ng (suffix) (hoc c hai th) cho
kch th-c chuyn i ca tt c cc kiu ghi kch th-c tr kch th-c gc.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dimapost
Dng nhc xut hin:
New value for DIMAPOST, or . for none <" ">:
Cho chui cn ghi.
Nu khng cho, g du chm (.).
56. DIMASO
iu khin to cc i t-ng thnh phn ca cm ghi kch th-c nh- -ng
kch th-c, mi tn, -ng dng, ch kch th-c thnh khi.
Gi tr ny khng l-u tr trong Dimension style.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):On
Dng lnh: Command: dimaso
Dng nhc xut hin:
New value for DIMASO <on>:
Cho trng thi:
Off
Khng cho gn thnh khi. Khi ghi kch th-c cc thnh phn s
l cc i t-ng ring r.
On
Cho gn thnh khi. Khi ghi kch th-c, c cm kch th-c l
mt khi.
57. DIMASZ
Cho c u mi tn ca -ng kch th-c.
DIMASZ cng -c s dng nh- l h s t l mi tn nu DIMBLK c ci
t.
DIMASZ khng c tc dng nu DIMTSZ 0.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.1800
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 153

Dng lnh: Command: dimasz


Dng nhc xut hin:
New value for DIMASZ <0.1800>:
Cho s cn thit.
58. DIMAUNIT
t n v o gc khi ghi kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimaunit
Dng nhc xut hin:
New value for DIMAUNIT <0>:
Cho mt trong cc s sau:
0
Decimal degrees
1
Degrees/minutes/seconds
2
Gradians
3
Radians
4
Surveyor's units
59. DIMBLK
Cho tn khi thay th mi tn th-ng dng ca -ng kch th-c.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dimblk
Dng nhc xut hin:
New value for DIMBLK, or . for none <" ">:
Nu khng cho, g du chm (.).
Cho mt trong cc tn sau:
Tn kiu mi tn
cc b
(DDIM Arrow Type Name)

None
Closed
Dot
Closed Filled
Closed Blank
Oblique
Architectural Tick
Open
Origin Indication
Right-Angle
Open 30
Dot Blanked

Tn khi ton cc
(Permanent Block Name)

_NONE
_CLOSED
_DOT DOT
""
_CLOSEDBLANK
_OBLIQUE
_ARCHTICK
_OPEN
_ORIGIN
_OPEN90
_OPEN30
_DOTBLANK

Tn khi s dng
(US Localized Block Name)

NONE
CLOSED
""
CLOSEDBLANK
OBLIQUE
ARCHTICK
OPEN
ORIGIN
OPEN90
OPEN30
DOTBLANK

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

154

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dot Small
_DOTSMALL
DOTSMALL
Box Filled
_BOXFILLED
BOXFILLED
Box
_BOXBLANK
BOXBLANK
Datum Triangle Filled
_DATUMFILLED
DATUMFILLED
Datum Triangle
_DATUMBLANK
DATUMBLANK
Integral
_INTEGRAL
INTEGRAL
L-u : Hnh dng cc khi ny xem trong hp thoi Format - Dimension style - Geometry Arrowheads.

60. DIMBLK1
Nu DIMSAH nhn gi tr ON, cho tn khi thay th mi tn th-ng dng
ca -ng kch th-c ti u th nht.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dimblk1
Dng nhc xut hin:
New value for DIMBLK1, or . for none <"">:
Nu khng cho, g du chm (.).
Cho mt trong cc tn nh- gii thiu ti mc DIMLBK.
61. DIMBLK2
Nu DIMSAH nhn gi tr ON, cho tn khi thay th mi tn th-ng dng
ca -ng kch th-c ti u th hai.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dimblk2
Dng nhc xut hin:
New value for DIMBLK2, or . for none <"">:
Nu khng cho, g du chm (.).
Cho mt trong cc tn nh- gii thiu ti mc DIMLBK trong du " ".
62. DIMCEN
nh kch th-c du tm ca -ng trn, cung trn.
i vi vic ghi kch th-c theo -ng knh (DIMDIAMETER) v theo bn
knh (DIMRADIUS), -ng trc hoc du tm ch -c v khi -ng kch
th-c nm ngoi -ng hoc cung trn.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0900
Dng lnh: Command: dimcen
Dng nhc xut hin:
New value for DIMCEN <0.0900>:
Cho s cn thit, vi iu kin sau:
=0
Khng v du tm.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 155

<0
>0

V cc -ng trc qua tm.


V du tm.

63. DIMCLRD
t mu cho -ng kch th-c.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: dimclrd
Dng nhc xut hin:
New value for DIMCLRD <0>:
Cho s ch th mu ca AutoCAD, vi iu kin sau:
S 0 l BYBLOCK
S 256 l BYLAYER .
64. DIMCLRE
t mu cho -ng dng.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: dimclre
Dng nhc xut hin:
New value for DIMCLRE <0>:
Cho s ch th mu ca AutoCAD, vi iu kin sau:
S 0 l BYBLOCK
S 256 l BYLAYER .
65. DIMCLRT
t mu cho ch kch th-c.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: dimclrt
Dng nhc xut hin:
New value for DIMCLRT <0>:
Cho s ch th mu ca AutoCAD, vi iu kin sau:
S 0 l BYBLOCK
S 256 l BYLAYER .
66. DIMDEC
nh s ch s sau du phy thp phn trong n v chnh ca kch th-c.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

156

Lp trnh ng dng trong AutoCAD - Ph lc 2

Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - Primary units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):4
Dng lnh: Command: dimdec
Dng nhc xut hin:
New value for DIMDEC <4>:
Cho gi tr t 0 n 8.
67. DIMDLE
nh di nh ra ca -ng kch th-c xuyn qua -ng dng khi mi tn
-c thay bng cc hnh khc.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.000
Dng lnh: Command: dimdle
Dng nhc xut hin:
New value for DIMDLE <0.0000>:
Cho s cn thit.
68. DIMDLI
nh khong cch gia cc -ng kch th-c khi ghi theo dng baseline.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.3800
Dng lnh: Command: dimdli
Dng nhc xut hin:
New value for DIMDLI <0.3800>:
Cho s cn thit.
69. DIMEXE
nh di nh ln khi -ng kch th-c ca -ng dng.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.1800
Dng lnh: Command: dimexe
Dng nhc xut hin:
New value for DIMEXE <0.1800>:
Cho s cn thit.
70. DIMEXO
nh khong cch gia chn -ng dng v i t-ng cn o.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0650
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 157

Dng lnh: Command: dimexo


Dng nhc xut hin:
New value for DIMEXO <0.0650>:
Cho s cn thit.
71. DIMFIT
nh v tr ca ch v mi tn bn trong hay bn ngoi -ng dng.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Format - Fit.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):3
Dng lnh: Command: dimfit
Dng nhc xut hin:
New value for DIMFIT <3>:
Cho mt trong cc s sau:
0
Ch v mi tn (Text and Arrows).
1
Ch c ch (Text Only).
2
Ch c mi tn (Arrows Only).
3
Nu ch va th cho vo trong, khng va th cho ra ngoi
(Best Fit)
4
Ghi theo kiu ch thch (Leader)
5
Khng c -ng ch dn (No Leader)
72. DIMGAP
nh khong cch gia -ng kch th-c v ch kch th-c khi ch nm ct
ngang -ng kch th-c.
Khi ch nm pha trn hoc pha d-i -ng kch th-c, -c -a vo bn
trong -ng dng khi khong cch t ch n -ng dng ti thiu phi ln
hn gi tr ca tch 2 * (DIMASZ + DIMGAP).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0900
Dng lnh: Command: dimgap
Dng nhc xut hin:
New value for DIMGAP <0.0900>:
Cho s cn thit.
73. DIMJUST
nh v tr ca ch kch th-c dc theo ph-ng nm ngang.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Format - Horizontal justification.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

158

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimjust
Dng nhc xut hin:
New value for DIMJUST <0>:
Cho mt trong cc s sau:
0
Nm ngang gia hai -ng dng.
1
Nm ngang st -ng dng th nht.
2
Nm ngang st -ng dng th hai.
3
Nm song song vi -ng dng th nht.
4
Nm song song vi -ng dng th hai.
74. DIMLFAC
nh h s t l cho kch th-c di. DIMLFAC khng c tc dng vi kch
th-c gc, v khng -c p dng cho cc gi tr ca DIMTM, DIMTP, hoc
DIMRND.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Linear.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: dimlfac
Dng nhc xut hin:
New value for DIMLFAC <1.0000>: Cho s cn thit .
+ Nu DIMFAC nhn gi tr m, kch th-c -c o khng gian giy
v (Paper space), AutoCAD s nhn di o -c vi gi tr tuyt
i ca DIMLFAC ghi kch th-c, cn khng gian m hnh
(Model space) DIMFAC b b qua v AutoCAD ghi kch th-c o
-c ln bn v.
Trong khng gian giy v (Paper space), khi ra lnh trn dng lnh:
Dim: dimlfac
Dng nhc xut hin:
Current value <1.0000> New value (Viewport): v
Tip theo:
Select viewport to set scale:
Khi chn mt ca s trn mn hnh, AutoCAD tnh t l hnh v nm
gn trong ca s v cho kt qu gi tr ca DIMLFAC vi du m.
75. DIMLIM
t kiu ghi ch kch th-c theo cn trn v cn d-i.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Tolerance - Method.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 159

Khi t DIMLIM on, bt buc DIMTOL phi off.


Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimlim
Dng nhc xut hin:
New value for DIMLIM <off>:
Cho mt trong hai trng thi sau:
Off Khng ghi theo cn trn, cn d-i.
On
Ghi theo cn trn, cn d-i.
76. DIMPOST
t tip u ng v tip v ng cho ch kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Tolerance - Primary Units
Priffix Sufix.

Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):""
Dng lnh: Command: dimpost
Dng nhc xut hin:
New value for DIMPOST, or . for none <"">:
Nu khng t, g du chm (.).
Cho tip u ng t tr-c du <>. V d: cho mm<> khi o -c 32.6,
kch th-c -c ghi l mm32.6.
Cho tip v ng t sau du <>. V d: cho <>mm khi o -c 32.6, kch
th-c -c ghi l 32.6mm.
Nu khng c du <>, ch ghi tip v ng.
Cho c hai th cho hai pha ca du <>.
77. DIMRND
Lm trn s o ca kch th-c. Khng p dng cho s o gc.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Round.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: dimrnd
Dng nhc xut hin:
New value for DIMRND <0.0000>: Cho s cn thit .
Cc s c ngha nh- sau:
0
Ly chnh xc theo lnh Units.
1
Lm trn n phn nguyn.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

160

Lp trnh ng dng trong AutoCAD - Ph lc 2

>1

<1

Nu di o -c nh hn gi tr DIMRND, th ghi bng


DIMRND, nu di o -c ln hn, ghi s o lm trn ln
n phn nguyn.
V tr no ca phn thp phn cho bng s 0 th gi tr o -c
gi nguyn, v tr no cho s 0 th gi tr o -c lm trn
theo nguyn tc ly s lin sau hoc lin tr-c.

78. DIMSAH
Cho php thay mi tn thng th-ng ca -ng kch th-c bng cc khi
hnh khc.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimsah
Dng nhc xut hin:
New value for DIMSAH<off>:
Cho mt trong hai trng thi sau:
Off Khng cho thay th.
On
Cho php thay th.
79. DIMSCALE
nh h s cho cc kch th-c hnh hc ca cc b phn trong cm kch
th-c nh- c mi tn, chiu cao ch, text gap v.v... DIMSCALE khng
p dng cho cc b phn ca nhm dung sai.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Geometry - Overall scale.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: dimscale
Dng nhc xut hin:
New value for DIMSCALE <1.0000>: Cho s cn thit .
Cc s c ngha nh- sau:
1
Cc gi tr ni trn ng nh- ci t.
0.0
AutoCAD coi gi tr ny trong khng gian m hnh (model
space) l 1.00, khi chuyn sang khng gian giy v (paper
space)s t iu chnh ph hp vi kch th-c ca ca nhn
(view port).
>0
Cc gi tr ni trn l tch ca s ci t nhn vi h s ny.
80. DIMSD1
Cho php b phn na bn tri (na th nht) ca -ng kch th-c.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 161

Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimsd1
Dng nhc xut hin:
New value for DIMSD1 <off>:
Cho mt trong hai trng thi sau:
Off Khng cho b.
On
Cho php b.
81. DIMSD2
Cho php b phn na bn phi (na th hai) ca -ng kch th-c.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimsd2
Dng nhc xut hin:
New value for DIMSD2 <off>:
Cho mt trong hai trng thi sau:
Off Khng cho b.
On
Cho php b.
82. DIMSE1
Cho php b -ng dng bn tri (th nht) ca kch th-c.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimse1
Dng nhc xut hin:
New value for DIMSE1 <off>:
Cho mt trong hai trng thi sau:
Off Khng cho b.
On
Cho php b.
83. DIMSe2
Cho php b -ng dng bn phi (th hai) ca kch th-c.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):off
Dng lnh: Command: dimse2
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

162

Lp trnh ng dng trong AutoCAD - Ph lc 2

New value for DIMSE1 <off>:


Cho mt trong hai trng thi sau:
Off Khng cho b.
On
Cho php b.
84. DIMSHO
Cho hin s thay i ca cm kch th-c khi ko.
Gi tr ny khng l-u tr vo dimension style.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):On
Dng lnh: Command: dimsho
Dng nhc xut hin:
New value for DIMSHO <off>:
Cho mt trong hai trng thi sau:
Off Khng hin.
On
Cho php hin.
85. DIMSOXD
Khng v -ng kch th-c pha ngoi -ng dng.
Nu DIMTIX l off, DIMSOXD khng c hiu lc.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimsoxd
Dng nhc xut hin:
New value for DIMSOXD <Off>:
Cho mt trong hai trng thi sau:
Off C v -ng kch th-c pha ngoi -ng dng.
On
Khng v -ng kch th-c pha ngoi -ng dng.
86. DIMSTYLE
t tn kiu ghi kch th-c hin hnh.
Kiu gi tr: Chui k t (String), Ch c (Read-only), l-u tr vo bn
v (saved in: Drawing).
Dng lnh: Command: dimstyle hoc ddim
Dng nhc xut hin:
dimension style: D2
Dimension Style Edit
(Save/Restore/STatus/Variables/Apply/?) <Restore>:
g ENTER cho tn kiu ghi kch th-c thnh hin hnh.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 163

?/Enter dimension style name or press


select dimension: Cho tn kiu ghi kch th-c.

ENTER

to

87. DIMTAD
nh v ch ghi kch th-c theo ph-ng thng ng.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Format - Vertical.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimtad
Dng nhc xut hin:
New value for DIMTAD <0>:
Cho mt trong cc s sau:
0
Ch nm gia ngang -ng kch th-c, bn trong -ng
dng.
1
Ch nm bn trn -ng kch th-c, tr khi -ng kch th-c
khng nm ngang v ch bt buc phi nm ngang (DIMTIH =
1) th ch nm ct ngang -ng kch th-c. Khong cch gia
-ng kch th-c v chn ch l gi tr DIMGAP .
2
Ch nm trn -ng kch th-c, tr khi -ng kch th-c
khng nm ngang v ch bt buc phi nm ngang (DIMTIH =
1) th ch khng nm ct ngang -ng kch th-c m nm cch
-ng kch th-c mt khong = DIMGAP.
3
Ch t ti v tr theo tiu chun cng nghip Nht Bn
Japanese Industrial Standards (JIS), gn ging
nh- DIMTAD = 2.
DIMTDEC
nh s ch s sau du phy thp phn ( chnh xc) ca ch dung sai.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - Units - Tolerance .

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):4
Dng lnh: Command: dimtdec
Dng nhc xut hin:
New value for DIMTDEC <4>:
Cho mt trong cc s sau:
0 8 Ch kch th-c gc c chnh xc theo gi tr DIMADEC.
88. DIMTFAC
nh h s t l cho chiu cao ch dung sai.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

164

Lp trnh ng dng trong AutoCAD - Ph lc 2

Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Tolerance - Height.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: dimtfac
Dng nhc xut hin:
New value for DIMTFAC <1.0000>: Cho s cn thit .
89. DIMTIH
t h-ng ch khi n nm bn trong -ng dng.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):On
Dng lnh: Command: dimtih
Dng nhc xut hin:
New value for DIMTIH <On>:
Cho mt trong hai trng thi sau:
Off Ch nm song song vi -ng kch th-c.
On
Ch nm ngang.
90. DIMTIX
t ch nm bn trong -ng dng. DIMTIX khng c tc dng vi kch
th-c -ng knh hoc bn knh.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimtix
Dng nhc xut hin:
New value for DIMTIX <Off>:
Cho mt trong hai trng thi sau:
Off Nu khong cch gia hai -ng dng va ch th t ch vo
trong, nu thiu th cho ra ngoi.
On
Ch nm trong -ng dng.
91. DIMTM
nh gi tr dung sai d-i.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Format - Annotation - Tolerance.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: dimtm
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 165

New value for DIMTM <0.0000>: Cho s cn thit .


92. DIMTOFL
V -ng kch th-c bn trong hai -ng dng khi ch nm ngoi -ng
dng.
i vi kch th-c -ng knh v bn knh, (nu DIMTIX l off)th -ng
kch th-c v mi tn nm bn trong cung, -ng trn cn ch nm bn
ngoi.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimtofl
Dng nhc xut hin:
New value for DIMTOFL <Off>:
Cho mt trong hai trng thi sau:
Off Khng v.
On
C v.
93. DIMTOH
nh h-ng ch kch th-c khi n nm bn ngoi hai -ng dng.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):On
Dng lnh: Command: dimtoh
Dng nhc xut hin:
New value for DIMTOH <On>:
Cho mt trong hai trng thi sau:
Off Ch nm song song vi -ng kch th-c.
On
Ch nm ngang.
94. DIMTOL
Ghi ch dung sai sau kch th-c. Nu DIMTOL on th bt buc DIMLIM
off.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimtol
Dng nhc xut hin:
New value for DIMTOL <Off>:
Cho mt trong hai trng thi sau:
Off Khng ghi.
On
C ghi.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

166

Lp trnh ng dng trong AutoCAD - Ph lc 2

95. DIMTOLJ
nh v ch dung sai so vi ch kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - Tolerance - Justification.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):1
Dng lnh: Command: dimtolj
Dng nhc xut hin:
New value for DIMTOLJ <1>:
Cho mt trong cc s sau:
0
y ch dung sai ngang vi y ch kch th-c (Bottom).
1
Gia ch dung sai ngang vi y ch kch th-c (Middle).
2
nh ch dung sai ngang vi y ch kch th-c (Top).
96. DIMTP
nh gi tr dung sai trn.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Tolerance.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: dimtm
Dng nhc xut hin:
New value for DIMTM <0.0000>: Cho s cn thit .
97. DIMTSZ
inh kch th-c gch cho thay mi tn ti cc u -ng kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Geometry - Arrowheads - Size.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: dimsz
Dng nhc xut hin:
New value for DIMSZ <0.0000>: Cho s cn thit theo
nguyn tc sau:
0
V mi tn.
>0
V gch cho c kch th-c va cho.
98. DIMTVP
nh v tr ch kch th-c bn trn hoc bn d-i -ng kch th-c.
DIMTVP c hiu lc khi DIMTAD l off.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 167

Gi tr mc nh (Initial value): 0.0000


Dng lnh: Command: dimsz
Dng nhc xut hin:
New value for DIMSZ <0.0000>: Cho s cn thit theo
nguyn tc sau:
<0
Ch nm d-i -ng kch th-c.
=1
DIMTAD l on.
>0
Ch nm bn trn -ng kc th-c.
99. DIMTXSTY
t kiu ch (text style) cho ch kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Text.

Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):"STANDARD"
Dng lnh: Command: dimtxsty
Dng nhc xut hin:
New value for DIMTXSTY <"STANDARD">:
Cho tn kiu ch ci t bng lnh STYLE.
100. DIMTXT
nh chiu cao ch kch th-c.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style - Annotation - Text.

Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).


Gi tr mc nh (Initial value): 0.1800
Dng lnh: Command: dimtxt
Dng nhc xut hin:
New value for DIMTXT <0.1800>: Cho s cn thit .
101. DIMTZIN
M iu khin b cc s 0 v ngha trong ch dung sai.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - Units - Tolerance.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimtzin
Dng nhc xut hin:
New value for DIMTZIN <0>:
Cho mt trong cc s sau:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

168

Lp trnh ng dng trong AutoCAD - Ph lc 2

0
B s 0 trong n v feet v inches.
1
nguyn cc s 0 trong n v feet v inches.
2
nguyn cc s 0 trong n v feet v b s 0 trong
inches.
3
nguyn cc s 0 trong n v inches v b s 0 trong
feet.
4
B cc s 0 phn nguyn ng tr-c (leading) cc s thp
phn < 1 (v d 0.5000 s ghi .5000).
8
B cc s 0 v ngha pha sau phn thp phn (triling) (v
d, 12.5000 ghi l 12.5).
12
B cc s 0 c pha tr-c ln pha sau phn thp phn (v d,
0.5000 cn li .5).
102. DIMUNIT
t kiu n v o khi ghi kch th-c tr kch th-c gc.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimunit
Dng nhc xut hin:
New value for DIMUNIT <0>:
Cho mt trong cc s sau:
1
Scientific
2
Decimal
3
Engineering
4
Architectural (stacked)
5
Fractional (stacked)
6
Architectural
7
Fractional
8
Windows Desktop
103. DIMUPT
Chn ph-ng n nh v tr ch kch th-c.
Kiu gi tr: Cng tc (Switch), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):Off
Dng lnh: Command: dimupt
Dng nhc xut hin:
New value for DIMUPT <Off>:
Cho mt trong hai trng thi sau:
Off Con tr ch nh v -ng kch th-c.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 169

On

Con tr nh v c -ng kch th-c v v tr t ch.

104. DIMZIN
M iu khin b cc s 0 v ngha trong ch kch th-c.
DIMZIN cng c hiu lc trong cc hm chuyn kiu d liu ca AutoLISP
nh- rtos v angtos.
Gi tr ny c th ci t ti dng lnh hoc trong hp thoi Format Dimension style -

Annotation - Units.

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dimzin
Dng nhc xut hin:
New value for DIMZIN <0>:
Cho mt trong cc s sau:
0
B s 0 trong n v feet v inches.
1
nguyn cc s 0 trong n v feet v inches.
2
nguyn cc s 0 trong n v feet v b s 0 trong
inches.
3
nguyn cc s 0 trong n v inches v b s 0 trong
feet.
4
B cc s 0 phn nguyn ng tr-c (leading) cc s thp
phn < 1 (v d 0.5000 s ghi .5000).
8
B cc s 0 v ngha pha sau phn thp phn (triling) (v
d, 12.5000 ghi l 12.5).
12
B cc s 0 c pha tr-c ln pha sau phn thp phn (v d,
0.5000 cn li .5).
105. DISPSILH
Cho hin cc -ng cong bng ca m hnh khi c (solid) trong ch
khung dy.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):0
Dng lnh: Command: dispilh
Dng nhc xut hin:
New value for DISPSILH <0>:
Cho mt trong cc s sau:
0
Off.
1
On.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

170

Lp trnh ng dng trong AutoCAD - Ph lc 2

106.
DISTANCE
L-u tr khong cch tnh -c bng lnh DIST.
Kiu gi tr: S thc (Real), ch c (Read-only) , khng l-u tr (Not
saved)
Dng lnh: Command: Command: distance
Kt qu l:
DISTANCE = 2.1073 (read only).
107. DONUTID
t gi tr mc nh cho -ng knh trong ca hnh vnh khuyn (donut).
Kiu gi tr: S thc (Real), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):0.500
Dng lnh: Command: donutid
Dng nhc xut hin:
New value for DONUTID <0.500>:
Cho gi tr cn thit.
108. DONUTOD
t gi tr mc nh cho -ng knh ngoi ca hnh vnh khuyn (donut).
Kiu gi tr: S thc (Real), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):1.0000
Dng lnh: Command: donutod
Dng nhc xut hin:
New value for DONUTOD <1.0000>:
Cho gi tr cn thit.
109. DRAGMODE
Kim sot vic hin th cc hnh chuyn tip ca i t-ng khi ko, di
chuyn trong bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):2
Dng lnh: Command: dragmode
Dng nhc xut hin:
DRAGMODE ON/OFF/Auto <OFF>:
Cho mt trong cc s hoc ch ci
0
Off (khng hin).
1
On (c hin).
2
Auto (lun lun hin).

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 171

110. DRAGP1
t tc v li hnh khi ko (regen-drag).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):10
Dng lnh: Command: dragp1
Dng nhc xut hin:
New value for DRAGP1 <10>:
Cho s cn thit.
111. DRAGP2
t tc v li nhanh hnh khi ko (regen-drag).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):50
Dng lnh: Command: dragp2
Dng nhc xut hin:
New value for DRAGP2 <50>:
Cho s cn thit.
112. DWGCODEPAGE
Cha trang m bn v.
Kiu gi tr: Chui k t (String), ch c (Read-only) , l-u tr cng
bn v (saved in: Drawing)
Dng lnh: Command: dwgcodepage
Kt qu l:
DWGCODEPAGE = "ANSI_1252" (read only)
113. DWGNAME
Cha tn bn v ang lm vic.
Kiu gi tr: Chui k t (String), ch c (Read-only) , khng l-u tr
(Not saved)
Dng lnh: Command: dwgname
Kt qu l:
DWGNAME = "Drawing.dwg" (read only)
114. DWGPREFIX
Cha tn th- mc cha bn v ang lm vic.
Kiu gi tr: Chui k t (String), ch c (Read-only) , khng l-u tr
(Not saved)
Dng lnh: Command: dwgprefix
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

172

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kt qu l:
DWGPREFIX = "C:\a14\" (read only)
115. DWGTITLED
Cho bit bn v ang lm vic c tn hay ch-a.
Kiu gi tr: S nguyn (Integer), ch c (Read-only) , khng l-u tr
(Not saved)
Dng lnh: Command: dwgtitled
Kt qu l:
DWGTITLED = 1 (read only)
0
Bn v ch-a c tn.
1
Bn v c tn.

E
116. EDGEMODE
Kim sot vic nhn -ng bin cho cc lnh TRIM v EXTEND.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Register)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: edgemode
Dng nhc xut hin:
New value for EDGEMODE <0>:
Cho cc gi tr sau:
0
-ng bin l bn thn i t-ng -c chn.
1
-ng bin l i t-ng -c chn km theo phn ko di v
hnh.
117. ELEVATION
Cao ca i t-ng so vi mt phng XY theo UCS trong khng gian hin
hnh.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: elevation
Dng nhc xut hin:
New value for ELEVATION <0>:
Cho cc gi tr cn thit.
118. EXPERT
C cho xut hin cc cu hi tnh hung pht sinh hay khng.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: expert
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 173

Dng nhc xut hin:


New value for EXPERT <0>:
Cho cc gi tr sau:
0
Cc cu hi tnh hung xut hin bnh th-ng.
1
Khng hin cc cu "About to regen, proceed?" v
"Really want to turn the current layer
off?"
2
B nhng ci t tr-c v khng cho hin cc cu "Block
already defined. Redefine it?" (i vi lnh
BLOCK) v "A drawing with this name already
exists. Overwrite it?" (SAVE or WBLOCK).
3
B cc ci t tr-c v khng cho hin cc cu hi pht sinh
khi dng LINETYPE gi nhng -ng nt -c gi vo
bn v ri.
4
B cc ci t tr-c v khng cho hin cc cu hi pht sinh
khi dng UCS Save v VPORTS Save l-u tr nu t trng
tn vi cc tn c.
5
B cc ci t tr-c v khng cho hin cc cu hi pht sinh
khi dng DIMSTYLE Save option v DIMOVERRIDE nu
t trng tn vi cc tn c.
119. EXPLMODE
Cho php bung (explode) cc khi c h s t l khng ng b
(nonuniformly scaled (NUS) blocks) .
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 1
Dng lnh: Command: explmode
Dng nhc xut hin:
New value for EXPLODE <1>:
Cho cc gi tr sau:
0
Khng bung cc NUS blocks
1
Cho php bung cc NUS blocks
120. EXTMAX
Cha to im gc cao bn phi ca bn v.
Kiu gi tr: Danh sch (List - 3D point), ch c (Read-only), l-u tr
vo bn v (saved in: Drawing)
Dng lnh: Command: extmax
Kt qu: nu ch-a c hnh v:
EXTMAX
=
-1.0000E+20,-1.0000E+20,-1.0000E+20
(read only)
Khi c hnh v, ly ta im nh ca i t-ng nm ti gc cao bn
phi.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

174

Lp trnh ng dng trong AutoCAD - Ph lc 2

EXTMAX = 8.3410,6.5064,0.0000 (read only)


121. EXTMIN
Cha to im gc thp bn tri ca bn v.
Kiu gi tr: Danh sch (List - 3D point), ch c (Read-only), l-u tr
vo bn v (saved in: Drawing)
Dng lnh: Command: extmax
Kt qu: nu ch-a c hnh v:
EXTMIN = 1.0000E+20,1.0000E+20,1.0000E+20 (read
only)
Khi c hnh v, ly ta im nh ca i t-ng nm ti gc thp bn
tri.
EXTMIN = 6.5164,4.4732,-0.0015 (read only)

F
122. FACETRATIO
nh t s mt l-i theo cnh N ca hnh tr v hnh nn.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: facetratio
Dng nhc xut hin:
New value for FACETRATIO <0>:
Cho cc gi tr sau:
0
Ph-ng N ch c mt mt l-i.
1
S mt l-i theo ph-ng N = M mt l-i.
123. FACETRES
Tng thm trn ca cc mt khi t bng.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing)
Gi tr mc nh (Initial value): 0.5
Dng lnh: Command: facetres
Dng nhc xut hin:
New value for FACETRES <0.5>:
Cho cc gi tr t 0.01 n 10.0. S cng ln th mt cng t b gy khc.
124. FILEDIA
Cho hin hp thoi lm vic vi cc tp tin (file dialog boxes).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 1
Dng lnh: Command: filedia
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 175

Dng nhc xut hin:


New value for FILEDIA <1>:
Cho cc gi tr sau:
0
Khng cho hin hp thoi, cc dng nhc hin trn vng
Command. Khi FILEDIA = 0, mun hin hp thoi, thay v tr
li, bn g du ~ ti dng nhc.
1
Cho hin hp thoi.
125. FILLETRAD
Cho bn knh cung trn khi fillet.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing)
Gi tr mc nh (Initial value): 0.5
Dng lnh: Command: filledrad
Dng nhc xut hin:
New value for FILLEDRAD <0.5>:
Cho cc gi tr tu .
126. FILLMODE
t ch t m hay rng cho cc i t-ng c t m (fill).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing)
Gi tr mc nh (Initial value): 1
Dng lnh: Command: fillmode
Dng nhc xut hin:
New value for FILLMODE <1>:
Cho cc gi tr sau:
0
Khng t m (fill off).
1
T m (fill on).
127. FONTALT
Cho tn phng ch (font) chuyn i khi khng tm thy phng ch (font)
dng trong bn v. Nu khng cho phng ch chuyn i, AutoCAD cho
hin hp thoi c cc tn tp tin cha phng ch hin c ng-i dng la
chn.
Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): "simplex.shx"
Dng lnh: Command: fontalt
Dng nhc xut hin:
New
value
for
FONTALT,
or
.
for
none
<"simplex.shx">:
Cho tn tp tin cha phng hoc g du chm (.) nu khng cn.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

176

Lp trnh ng dng trong AutoCAD - Ph lc 2

128. FONTMAP
Cha tn tp tin bn phng ch (font mapping).
Tp tin ny l tp tin dng vn bn, mi dng cha tn tp tin phng ch gc
(original font) v tn tp tin phng ch thay th ngn cch bng du
chm phy (;). V d phng Times TrueType thay cho phng romans,
trong tp tin font mapping ghi nh- sau:
romanc.shx;times.ttf
Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): "acad.fmp"
Dng lnh: Command: fontmap
Dng nhc xut hin:
New
value
for
FONTMAP,
or
.
for
none
<"acad.fmp">:
Cho tn tp tin hoc g du chm (.) nu khng cn.
129. FRONTZ
Cha khong cch gia mt phng ch v mt phng xn hnh ca ca nhn
(viewport) hin hnh.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing)
Dng lnh: Command: frontz
Kt qu:
FRONTZ = 0.0000 (read only)
Gi tr ny c s o nu VIEWMODE l on v front-clip-not-ateye bit cng on.

G
130. GRIDMODE
t ch hin l-i mn hnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: gridmode
Dng nhc xut hin:
New value for GRIDMODE <0>:
Cho cc gi tr sau:
0
Khng hin l-i (off).
1
C hin l-i (on).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 177

131. GRIDUNIT
t khong cch (X v Y) gia cc nt l-i mn hnh.
Kiu gi tr: Danh sch (List - 2D point), l-u tr vo bn v (saved
in: Drawing)
Gi tr mc nh (Initial value): 0.5000,0.5000
Dng lnh: Command: gridunit
Dng nhc xut hin:
New value for GRIDUNIT <0.5000,0.5000>:
Cho cc gi tr ca X v Y, cch nhau du phy (,).
132. GRIPBLOCK
Cho hin cc nt vung (grip) gn vi khi, khi bm chut vo i t-ng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: gripblock
Dng nhc xut hin:
New value for GRIPBLOCK <0>:
Cho cc gi tr sau:
0
Cho hin nt im chn ca khi (block).
1
Cho hin nt ca cc i t-ng c khi (block).
133. GRIPCOLOR
t mu ca nt (grip) khi khng chn vo nt.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 5
Dng lnh: Command: gripcolor
Dng nhc xut hin:
New value for GRIPCOLOR <5>:
Cho cc gi tr ch th mu t 1 n 255.
134. GRIPHOT
t mu ca nt (grip) khi chn vo nt.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 1
Dng lnh: Command: griphot
Dng nhc xut hin:
New value for GRIPHOT <1>:
Cho cc gi tr ch th mu t 1 n 255.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

178

Lp trnh ng dng trong AutoCAD - Ph lc 2

135.
GRIPS
t ch cho hin nt chn (grips).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 1
Dng lnh: Command: grips
Dng nhc xut hin:
New value for GRIPS <1>:
Cho mt trong cc gi tr sau:
0
Cho grips off .
1
Cho grips on.
136. GRIPSIZE
nh kch th-c grips.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Registry)
Gi tr mc nh (Initial value): 3
Dng lnh: Command: gripsize
Dng nhc xut hin:
New value for GRIPSIZE <3>:
Cho cc gi tr t 1 n 255.

H
137. HANDLES
Bo co xem i t-ng c cho php cc ng dng truy cp hay khng.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing)
Gi tr mc nh (Initial value): on
Dng lnh: Command: handles
Kt qu:
ON:
138. HIDEPRECISION
t chnh xc khi dng lnh hid v shad i vi m hnh khng gian
th c.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved)
Gi tr mc nh (Initial value):0
Dng lnh: Command: hideprecision
Dng nhc xut hin;
New value for HIDEPRECISION <0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 179

Cho mt trong cc s sau:


0
chnh xc n, s dng dung l-ng b nh t.
1
chnh xc gp i, s dng dung l-ng b nh nhiu.
139. HIGHLIGHT
nh ph-ng thc nh du i t-ng -c chn.
Khng c tc dng cho la chn bng grips.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved)
Gi tr mc nh (Initial value):1
Dng lnh: Command: highlight
Dng nhc xut hin;
New value for HIGLIGHT <0>:
Cho mt trong cc s sau:
0
i t-ng -c chn khng nh du bng nt dt.
1
i t-ng -c chn nh du bng nt dt.
140. HPANG
nh gc nghing ca mu t mt ct.
Kiu gi tr: S thc (Real), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 0
Dng lnh: Command: hpang
Dng nhc xut hin:
New value for HPANG <0>:
Cho cc gi tr tu .
141. HPBOUND
Cho kiu -ng bin to mt ct ca cc lnh BHATCH v BOUNDARY.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):1
Dng lnh: Command: hpbound
Dng nhc xut hin;
New value for HPBOUND <1>:
Cho mt trong cc s sau:
0
-ng bin l region.
1
-ng bin l a tuyn (polyline).
142. HPDOUBLE
Cho kiu t mt ct l n hay kp.
Kiu gi tr: S nguyn (Integer), khng l-u tr(Not saved).
Gi tr mc nh (Initial value):0
Dng lnh: Command: hpbound
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

180

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dng nhc xut hin;


New value for HPBOUND <0>:
Cho mt trong cc s sau:
0
T n.
1
T kp.
143. HPNAME
Cho tn mt ct l mc nh.
Kiu gi tr: Chui k t (String), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): "ANSI31"
Dng lnh: Command: hpname
Dng nhc xut hin:
New value for HPNAME <"ANSI31">:Cho tn kiu mt ct.
144. HPSCALE
nh t l khong cch gia cc nt ca mt ct.
Kiu gi tr: S thc (Real), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: hpscale
Dng nhc xut hin:
New value for HPSCALE <1.0000>:
Cho cc gi tr tu .
145. HPSPACE
nh khong cch gia cc nt ca mt ct do ng-i dng nh ngha.
Kiu gi tr: S thc (Real), khng l-u tr (Not saved)
Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: hpspace
Dng nhc xut hin:
New value for HPSPACE <1.0000>:
Cho cc gi tr tu .

I
146. INDEXCTL
Kim sot vic to ch s v khng gian cho cc lp khi l-u tr bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing)
Gi tr mc nh (Initial value):0
Dng lnh: Command: indexctl
Dng nhc xut hin:
New value for INDEXCTL <0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 181

Cho mt trong cc s sau:


0 = Khng cho ch s.
1 = To ch s lp.
2 = C to ch s khng gian.
3 = To c ch s khng gian v ch s lp.
Nu bn v khng c Xref, th khng nn to cc ch s khng tng kch
th-c tp tin.
147. INETLOCATION
Cha a ch Internet khi dng trnh duyt BROWSER.
Kiu gi tr: Chui k t (String), l-u tr vo h thng(saved
in:Registry)
Gi
tr
mc
nh
(Initial
value):
"www.autodesk.com/acaduser"
Dng lnh: Command: indexctl
Dng nhc xut hin:
New value for INETLOCATION
<"http://www.autodesk.com/acaduser">:
148. INSBASE
Cha to im gc ca bn v hoc im chn trong lnh BASE.
Kiu gi tr: Danh sch ta im 3D (List 3D point), l-u tr vo bn
v (saved in: Drawing)
Gi tr mc nh (Initial value):0.0000,0.0000,0.0000
Dng lnh: Command: insbase
Dng nhc xut hin:
New value for INSBASE <0.0000,0.0000,0.0000>:
Cho ta im.
149. INSNAME
Cha tn mc nh ca khi (block) dng cho cc lnh DDINSERT hoc
INSERT
Kiu gi tr: Chui k t (String), khng l-u tr (Not saved)
Gi tr mc nh (Initial value):""
Dng lnh: Command: insname
Dng nhc xut hin:
New value for INSNAME, or . for none <"">:
Cho tn khi, nu khng cn, g du chm (.).
150. ISAVEBAK
Cho to tp tin d phng (backup file
bn v.

.BAK) trong qu trnh l-u tr

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

182

Lp trnh ng dng trong AutoCAD - Ph lc 2

Vic to tp tin d phng lm cho qu trnh l-u tr bn v lm cho thi gian


thc hin lnh SAVE tng ln ng k nh-ng an ton.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry)
Gi tr mc nh (Initial value):1
Dng lnh: Command: isavebak
Dng nhc xut hin:
New value for ISAVEBAK <1>:
Cho mt trong cc s sau:
0
Khng to BAK file.
1
C to BAK file.
151. ISAVEPERCENT
nh s l-ng cc khong trng ch-a dng n ca tp tin (file) bn v.
Gi tr ny c th t t 0 n 100. Mc nh l 50, ngha l khong trng
khng v-t qu 50% tng kch th-c tp tin (file). Khong trng b loi b
trong l-u tr ton b (full save). Khi khong trng v-t qu 50%, ln
l-u tr sau l l-u tr ton b. Nu t ISAVEPERCENT = 0, ln l-u tr no
cng l l-u tr ton b.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry)
Gi tr mc nh (Initial value):50
Dng lnh: Command: isavepercent
Dng nhc xut hin:
New value for ISAVEPERCENT <50>:
Cho mt trong cc s nguyn t 0 n 100.
152. ISOLINES
nh s -ng ng h-ng (isolines) cho mi mt khng gian ca i
t-ng.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing)
Gi tr mc nh (Initial value):4
Dng lnh: Command: isolines
Dng nhc xut hin:
New value for ISOLINES <4>:
Cho mt trong cc s nguyn t 0 n 2047.

L
153. LASTANGLE
Cha gc nghing so vi ph-ng ngang ca im cui cung trn v sau cng
trong mt phng XY ca h UCS hin hnh.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 183

Kiu gi tr: S thc (Real), ch c (Read-only), khng l-u tr(Not


saved).
Dng lnh: Command: lastangle
Kt qu:
LASTANGLE = 25 (read only).
154. LASTPOINT
Cha ta im cui ca i t-ng v sau cng, trong h UCS hin hnh s
l ta t-ng i.
Kiu gi tr: Danh sch ta im 3D (List 3D point), l-u tr vo bn
v( saved in: Drawing).
Gi tr mc nh (Initial value):0.000,0.0000,0.0000
Dng lnh: Command: laspoint
Dng nhc xut hin:
New value for LASTPOINT <7.4430,5.9071,0.0000>:
155. LASTPROMPT
Cha dng ch xut hin ln cht trn dng cui ca vng dng lnh.
Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u
tr(Not saved).
Gi tr mc nh (Initial value):""
Dng lnh: Command: lasprompt
Kt qu:
LASTPROMPT = "Command: lastprompt" (read only)
156. LENSLENGTH
Cha chiu di (o bng milimt) ca thu knh hi t trong tr-ng hp nhn
theo phi cnh ca ca nhn hin hnh.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn
v(saved in: Drawing).
Dng lnh: Command: lenslength
Kt qu:
LENSLENGTH = 50.0000 (read only).
157. LIMCHECK
Cho php v ra ngoi limits.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing)
Gi tr mc nh (Initial value):0
Dng lnh: Command: limcheck
Dng nhc xut hin:
New value for LIMCHECK<0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

184

Lp trnh ng dng trong AutoCAD - Ph lc 2

Cho mt trong cc s sau:


0
Cho php v ra ngoi limits (limits off).
1
Khng cho php v ra ngoi limits (limits on).
158. LIMMAX
Cha ta im gc cao bn phi ca limits.
Kiu gi tr: Danh sch ta im 2D (List 2D point), l-u tr vo bn
v( saved in: Drawing).
Gi tr mc nh (Initial value):12.000,9.0000
Dng lnh: Command: limmax
Dng nhc xut hin:
New value for LIMMAX <12.000,9.0000>:
Cho to im.
159. LIMMIN
Cha ta im gc thp bn tri ca limits.
Kiu gi tr: Danh sch ta im 2D (List 2D point), l-u tr vo bn
v( saved in: Drawing).
Gi tr mc nh (Initial value):0.000,0.0000
Dng lnh: Command: limmin
Dng nhc xut hin:
New value for LIMIMN <0.000,0.0000>:
Cho to im.
160. LISPINIT
Cho php duy tr cc bin s ca cc hm AutoLISP khi m bn v khc
(open) hay khng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):1
Dng lnh: Command: lispinit
Dng nhc xut hin:
New value for LISPINIT <1>:
161. LOCALE
Cho hin m ngn ng quc t dng trong AutoCAD (xem bin DCTMAIN).
Kiu gi tr: Chui k t (String), ch c (read only),khng l-u tr
(Not saved).
Gi tr mc nh (Initial value):theo s thch.
Dng lnh: Command: locale
Kt qu:
LOCALE = "enu" (read only)
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 185

162. LOGFILEMODE
Cho php ghi cc dng ch ca mn hnh text vo tp tin nht k (log
file) hay khng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):0
Dng lnh: Command: logfilemode
Dng nhc xut hin:
New value for LOGFILEMODE <0>:
Cho mt trong cc s sau:
0
Khng duy tr log file .
1
C duy tr log file .
163. LOGFILENAME
t -ng dn cho log file. Tp tin nht k (log file) -c m khi
chn ON trong mc Maintain a Log File ca hp thoi
Preferences.
Kiu gi tr: Chui k t (String), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value): "C:\ACADR14\acad.log"
Dng lnh: Command: logfilename
Dng nhc xut hin:
New value for LOGFILENAME, or . for none
<"C:\a14\acad.log">:
164. LOGINNAME
Cho hin tn ci t AutoCAD khi khi ng. Dng di nht cha 30 k t.
Kiu gi tr: Chui k t (String), ch c (read only),khng l-u tr
(Not saved).
Dng lnh: Command: loginname
Kt qu:
LOGINNAME = "Nguyen Van Thiep, CAD/CAM Cent" (read
only)
165. LTSCALE
nh t l khong cch v di cc nt ca cc -ng nt c bit
(global linetype scale factor).
Kiu gi tr: S thc (Real), l-u tr vo bn v (Saved in: Drawing).
Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: ltscale
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

186

Lp trnh ng dng trong AutoCAD - Ph lc 2

New value for LTSCALE <1.0000>:


Cho cc gi tr tu 0.
166. LUNITS
t kiu nhp n v o di.
Kiu gi tr: S nguyn (Integer), l-u tr vobn v(saved in:
Drawing).
Gi tr mc nh (Initial value):2
Dng lnh: Command: luinit
Dng nhc xut hin:
New value for LUNIT <2>:
Cho mt trong cc gi tr sau:
1
Scientific
2
Decimal
3
Engineering
4
Architectural
5
Fractional
167. LUPREC
nh s ch s c ngha sau du phy thp phn cho n v di hin ln mn
hnh trong cc lnh ly gi tr, v xut ra (tr cc lnh ghi kch th-c c ci
t ring).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing).
Gi tr mc nh (Initial value):4
Dng lnh: Command: luprec
Dng nhc xut hin:
New value for LUPREC <4>:
Cho mt s nguyn.
168. lwdefault
t m mc nh cho cc nt v ca AutoCAD 2000.
Kiu gi tr: S (Enum), l-u tr vo h thng(Saved in:
Registry).
Gi tr mc nh (Initial value):25
Dng lnh: Command: lwdefault
Dng nhc xut hin:
New value for LWDEFAULT <25>:
Cho mt trong cc s nguyn sau: 0, 5, 9, 13, 15, 18, 20, 25, 30, 35, 40,
50, 53, 60, 70, 80, 90, 100, 106, 120, 140, 158, 200, v 211. Cc gi tr
ny -c tnh theo h s 0.01 mm.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 187

Nu cho cc gi tr khc b bo li.

M
169. MAXACTVP
Cho s l-ng ti a cc ca nhn (viewports) hot ng ng thi trn
mn hnh v -c in ra giy.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing).
Gi tr mc nh (Initial value):48
Dng lnh: Command: maxactvp
Dng nhc xut hin:
New value for MAXACTVP <48>:
Cho mt s nguyn.
170. MAXOBJMEM
Cho t trang i t-ng (object pager) v dung l-ng b nh o
(virtual memory) m AutoCAD c th s dng trn tp tin trao i
(swap files).
Gi tr mc nh l 0, hoc nu cho s m hay cc gi tr bng 2, 147, 483,
647 th object pager l off.
Nu cho gi tr khc vi cc gi tr trn th object pager l on, y cng
l cn trn ca dung l-ng b nh o m AutoCAD cs th s dng.
Kiu gi tr: S nguyn (Integer), khng l-u tr(Not saved).
Gi tr mc nh (Initial value):0
Dng lnh: Command: maxobjmem
Dng nhc xut hin:
New value for MAXOBJMEM <0>:
Cho mt s nguyn.
Cnh bo: Nu khi ng li my khi AutoCAD cha thot, tp tin
trao i (swap files) khng b xo, chng ta phi t xo khi
AutoCAD khng hot ng.

171. MAXSORT
nh s l-ng ti a cc tn k hiu (symbol) hoc khi (block) cho php
sp xp phn loi theo cc lnh lit k.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):200
Dng lnh: Command: maxsort
Dng nhc xut hin:
New value for MAXSORT <200>:
Cho mt s nguyn.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

188

Lp trnh ng dng trong AutoCAD - Ph lc 2

172. MEASUREINIT
nh n v v mc nh theo h Anh (English) hay h mt (metric).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):theo cc n-c khc nhau.
Dng lnh: Command: measureinit
Dng nhc xut hin:
New value for MEASUREINIT <0>:
Cho mt s nguyn:
0
English.
1
Metric.
173.
MEASUREMENT
nh n v v cho bn v hin hnh theo h Anh (English) hay h mt
(metric).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing).
Gi tr mc nh (Initial value):0.
Dng lnh: Command: measurement
Dng nhc xut hin:
New value for MEASUREMENT <0>:
Cho mt s nguyn:
0
English.
1
Metric.
174. MENUCTL
t trng thi cho Menu dc mn hnh (screen menu).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value):1
Dng lnh: Command: menuctl
Dng nhc xut hin:
New value for MENUCTL <1>:
Cho mt trong cc s:
0
Menu dc mn hnh (Screen menu) khng thay i theo
lnh g t bn phm.
1
Menu dc mn hnh (Screen menu) c thay i theo lnh g
t bn phm.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 189

175. MENUECHO
t cc bit iu khin cho s phn hi ca trnh n (menu) v cc dng
nhc (prompt).
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):0
Dng lnh: Command: menuecho
Dng nhc xut hin:
New value for MENUECHO <0>:
Cho mt s nguyn c th l tng ca cc s sau:
1
B s phn hi ca cc mc trnh n (menu) (^P trn cc mc
menu lt trng thi phn hi).
2
B vic hin th cc dng nhc h thng khi thc hin trn trnh
n.
4
V hiu ho ^P .
8
Hin th cc chui xut nhp (input/output strings).
176. MENUNAME
Cha tn nhm Trnh n (MENUGROUP).
Kiu gi tr: Chui k t (String), ch c (read only),l-u tr vo
ng dng(saved in: Application header).
Dng lnh: Command: menuname
Kt qu:
MENUNAME = "C:\a14\SUPPORT\acad" (read only)
177. MIRRTEXT
iu khin vic ly i xng ch (text) trong lnh MIRROR.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v(saved in:
Drawing).
Gi tr mc nh (Initial value):1
Dng lnh: Command: mirrtext
Dng nhc xut hin:
New value for MIRRTEXT <1>:
Cho mt trong cc s:
0
Gi nguyn h-ng ca ch (ch khng b o ng-c).
1
Ch b o ng-c.
178. MODEMACRO
Cha dng ch s hin trn dng trng thi ca mn hnh.
Kiu gi tr: Chui k t (String), khng l-u tr(Not saved).
Gi tr mc nh (Initial value): " "
Dng lnh: Command: modemacro
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

190

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dng nhc xut hin:


New value for MODEMACRO, or . for none <"">:
Cho chui k t hoc g du chm (.) nu khng cn.
179. MTEXTED
Cho tn ch-ng trnh sa cha ch -c vit bng lnh MTEXT trong bn
v.
Kiu gi tr: Chui k t (String), l-u tr vo h thng(saved
in:Registry).
Gi tr mc nh (Initial value): " Internal "
Dng lnh: Command: mtexted
Dng nhc xut hin:
New value for MTEXTED, or . for none
<"c:\a14\asiodbc.exe">:
Cho chui k t -ng dn v tn tp tin ng dng (ti a 256 k t)
hoc g du chm (.) nu khng cn.

N
180. NOMUTT
Cho hin cc thng bo trong qu trnh thc hin cc lnh ca AutoCAD.
Kiu gi tr: S nguyn ngn (Short), khng l-u tr(Not saved).
Gi tr mc nh (Initial value):0
Dng lnh: Command: nomutt
Dng nhc xut hin:
New value for NOMUTT <0>:
Cho mt trong cc s:
0
Cho hin th cc thng bo hoc dng nhc bnh th-ng.
1
Khng hin th thng bo, ngay c dng Command: trn vng
dng lnh cng b b qua.

O
181. OFFSETDIST
t gi tr mc nh cho khong cch cn offset.
Kiu gi tr: S thc (Real), khng l-u tr (Not saved).
Gi tr mc nh (Initial value): 1.0000
Dng lnh: Command: offsetdist
Dng nhc xut hin:
New value for OFFSETDIST <1.0000>:
Cho cc gi tr tu .
Nu gi tr < 0, i t-ng -c offset qua mt im nh.
Nu gi tr > 0, l gi tr mc nh cho khong cch cn offset.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 191

182. OLEHIDE
Cho hin cc i t-ng ca cc phn mm nhng (OLE) vo AutoCAD.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: olenhide
Dng nhc xut hin:
New value for OLEHIDE <0>:
Cho mt trong cc gi tr:
0
Cho hin tt c cc i t-ng nhng kt.
1
Cc i t-ng nhng kt (OLE objects) ch hin trong khng
gian giy v (paper space).
183.
ORTHOMODE
Kim sot ch ORTHO.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: orthomode
Dng nhc xut hin:
New value for ORTHOMODE <0>:
Cho mt trong cc gi tr:
0
Ortho OFF.
1
Ortho ON.
184.
OSMODE
Kim sot ch OSNAP.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: osmode
Dng nhc xut hin:
New value for OSMODE <0>:
Cho mt trong cc gi tr:
0
NONe
1
ENDpoint
2
MIDpoint
4
CENter
8
NODe
16
QUAdrant
32
INTersection
64
INSertion
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

192

Lp trnh ng dng trong AutoCAD - Ph lc 2

128
PERpendicular
256
TANgent
512
NEArest
1024 QUIck
2048 APParent Intersection
+ Mun t ch OSMODE cho ng thi nhiu i t-ng, cho gi tr
bng tng cc gi tr ca tng i t-ng.
+ Gi tr OSMODE = 4095 l chn tt c cc la chn trn.
+ Khi ch object snaps lt trng thi OFF, ng-i dng s
dng cc nt trn thanh cng c th OSMODE = 16384 (0x4000).
185. OSNAPCOORD
Cho nhp to t bn phm thay cho vic bt im bng OSNAP.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 2
Dng lnh: Command: osnapcoord
Dng nhc xut hin:
New value for OSNAPCOORD <2>:
Cho mt trong cc gi tr:
0
Ch OSNAP thay cho nhp ta t bn phm.
1
Ch nhp ta t bn phm thay cho OSNAP.
2
Ch nhp ta t bn phm thay cho OSNAP tr khi chy
p bn (scripts).

P
186. PDMODE
Xc nh hnh dng ca im (point).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: pdmode
Dng nhc xut hin:
New value for PDMODE <0>:
Cho mt trong cc gi tr trong bng. Hnh dng ca im -c minh
ha t-ng ng.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 193

187. PDSIZE
nh kch th-c im (point).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: pdsize
Dng nhc xut hin:
New value for PDSIZE <0.0000>:
Cho gi tr c l-u sau:
=0
Kch th-c im (point) l 5% chiu cao vng hnh v.
>0
Gi tr tht ca kch th-c im.
<0
Gi tr phn trm so vi kch th-c ca nhn (view port).
188. PELLIPSE
nh kiu i t-ng cho hnh Elp.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: pellipse
Dng nhc xut hin:
New value for PELLIPSE <0>:
Cho mt trong cc gi tr sau:
0
Hnh Elp thc s.
1
-ng Polyline c hnh Elp.
Mch nh: Nu khi v Elp l hnh Elp thc s theo phng trnh
ton hc th khng v c ng trn tip xc vi Elp
(trong R12 v bnh thng). Khi Elp c chuyn thnh
Polyline th cng vic trn thc hin tt.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

194

Lp trnh ng dng trong AutoCAD - Ph lc 2

189. PERIMETER
Cha gi tr chu vi hoc di ca cc i t-ng cui cng trong cc lnh
AREA, LIST, or DBLIST.
Kiu gi tr: S thc (Real), ch c (Read-only), khng l-u tr (Not
saved).
Dng lnh: Command: perimeter
Kt qu:
PERIMETER = 5.9946 (read only).
190. PFACEVMAX
Cha s l-ng -ng thng ng trong mi mt khng gian.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: pfacevmax
Kt qu:
PFACEVMAX = 4 (read only).
191. PICKADD
t ch chn i t-ng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: pickadd
Dng nhc xut hin:
New value for PICKADD <1>:
Cho mt trong cc gi tr sau:
0
PICKADD l OFF, mi ln chn ch -c mt i t-ng, mun
chn nhiu phi nhn phm Shift.
1
PICKADD l ON, vic chn i t-ng din ra bnh th-ng.
192. PICKAUTO
Cho t ng dng con tr to ca s khi chn i t-ng, khng cn phi g
w.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: pickauto
Dng nhc xut hin:
New value for PICKAUTO <1>:
Cho mt trong cc gi tr sau:
0
PICKAUTO l OFF, mun chn i t-ng theo ca s phi g
w trn dng nhc.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 195

PICKAUTO l ON, t ng dng con tr to ca s khi chn


i t-ng, khng cn phi g w.

193. PICKBOX
t kch th-c vung gn vi con tr ca AutoCAD, tnh theo pixels.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 3
Dng lnh: Command: pickbox
Dng nhc xut hin:
New value for PICKBOX <3>:
Cho s nguyn.
194. PICKDRAG
nh ph-ng thc v ca s khi chn i t-ng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: pickdrag
Dng nhc xut hin:
New value for PICKDRAG <0>:
Cho mt trong cc s sau:
0
V bng cch chn 2 im gc i nhau. Nu dng chut, nhn
chut chn im th nht, di chut v nhn chut ln na xc
nh im th hai.
1
V bng cch chn mt im ca mt gc bng nhn gi chut
v ko, khi nh chut l ca s -c to.
195. PICKFIRST
Cho php chn i t-ng tr-c Dng lnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: pickfirst
Dng nhc xut hin:
New value for PICKFIRST <1>:
Cho mt trong cc s sau:
0
PICKFIRST nhn gi tr OFF - khng cho chn i t-ng tr-c.
1
PICKFIRST nhn gi tr ON - cho chn i t-ng tr-c.
196. PICKSTYLE
t cch chn i t-ng cho mt ct.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

196

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: pickstyle
Dng nhc xut hin:
New value for PICKSTYLE <1>:
Cho mt trong cc s sau:
0
Chn mt ct nh- i t-ng khc.
(No group selection or associative hatch
selection)

1
2

Chn nhm (Group selection), ch cn nhn chut vo


mt thnh vin th tt c cc thnh vin khc thuc nhm cng
-c chn.
Chn lin kt (Associative hatch selection), khi
mt ct -c chn th c -ng bin (boundary) nu c to
cng -c chn theo.
Chn c nhm v lin kt (Group selection and
associative hatch selection), cc i t-ng c chung
-ng bin vi mt ct cng -c chn.

197. PLATFORM
Cha mi tr-ng lm vic ca AutoCAD.
Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: platform
Kt qu:

PLATFORM = "Microsoft Windows Version 4.0 (x86)" (read


only)

198. PLINEGEN
t kiu nt cho nh ca a tuyn 2D (pline).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: plinegen
Dng nhc xut hin:
New value for PLINEGEN <0>:
Cho mt trong cc s sau:
0
D pline c kiu -ng nt c bit, th cc nh vn l nt lin
nh ra.
1
nh c th b t on theo khong cch ca nt v.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 197

199. PLINETYPE
nh ti -u ha a tuyn 2D (pline). PLINETYPE iu khin cc -ng
mi to v c cc -ng chuyn i t cc phin bn tr-c.
+ PLINRTYPE cng c tc dng cho cc lnh: BOUNDARY (nu i t-ng
l Polyline), DONUT, ELLIPSE (khi PELLIPSE = 1), PEDIT (khi chn
line hoc arc), POLYGON, v SKETCH (khi SKPOLY = 1).
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 2
Dng lnh: Command: plinetype
Dng nhc xut hin:
New value for PLINETYPE <2>:
0
Polyline ca phin bn c khng -c chuyn i; PLINE
to mi cng vn theo dng c.
1
Polyline ca phin bn c khng -c chuyn i; PLINE
to mi -\c ti -u ho.
2
Polyline ca phin bn c -c chuyn i sang phin bn
mi; PLINE to mi -c ti -u ho.
Specifies whether AutoCAD uses optimized 2d polylines
200. PLINEWID
Cha b rng mc nh ca a tuyn (polyline).
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: plinewid
Dng nhc xut hin:
New value for PLINEWID <0.0000>:
Cho gi tr tu .
201. PLOTID
Cho tn my v hoc my in (plotter) da trn dng m t (description).
Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: plotid
Dng nhc xut hin:
New value for PLOTID <"System Printer ADI 4.3">:
Cho tn my in.
202. PLOTROTMODE
t chiu in bn v so vi giy.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

198

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:


Registry).
Gi tr mc nh (Initial value):1
Dng lnh: Command: plotrotmode
Dng nhc xut hin:
New value for PLOTROTMODE <1>:
Cho mt trong cc gi tr sau:
0
Bn v c th xoay 0, 90, 180, hoc 270 .
1
Gc thp ca bn v lun trng vi gc thp ca t giy.
203.
PLOTTER
t my in, my v mc nh.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):0
Dng lnh: Command: plotter
Dng nhc xut hin:
New value for PLOTTER <0>:
Cho mt trong cc gi tr theo th t trong bng danh sch my v ca
AutoCAD.
204. POLYSIDES
t s cnh mc nh cho a gic u (POLYGON).
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value):4
Dng lnh: Command: plysides
Dng nhc xut hin:
New value for PLYSIDES <4>:
Cho s nguyn t 3 n 1024.
205.
POPUPS
Cha trng thi thit b hin th ci t.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: popups
Kt qu:
POPUPS = 1 (read only).
Cc gi tr c ngha sau:
0
Khng h tr hp thoi (dialog boxes), thanh trnh n
(the menu bar), trnh n xung (pull-down
menus), v trnh n hnh nh (icon menus).
1
C h tr cc phn trn.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 199

206.
PROJECTNAME
Cha tn d n (project).
D n -c dng khi c chn nh (images), xref, trao i gia nhng
ng-i s dng hoc c dng thit b khc ging vi nh cung cp.
Kiu gi tr: Chui k t (String), l-u tr vo banr vex (saved in:
Drawing).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: projectname
Dng nhc xut hin:
New value for PROJECTNAME, or . for none <"">:
Cho tn d n hoc g du chm (.) nu khng cn
207. PROJMODE
t ch d n cho trim v extend.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: projmode
Dng nhc xut hin:
New value for PROJMODE <1>:
Cho mt trong cc s sau:
0
Ch 3D (no projection)
1
D n (Project) trn mt phng XY ca UCS hin hnh.
2
D n (Project) trn mt phng ca ca nhn (view
plane) hin
hnh.
208. PROXYGRAPHICS
Cho php l-u tr nh qut (image) cng bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: proxygraphics
Dng nhc xut hin:
New value for PROXYGRAPHICS <1>:
Cho mt trong cc s sau:
0
Khng l-u tr nh vo bn v; trong bn v ch hin khung nh.
1
nh -c l-u cng bn v.
209. PROXYNOTICE
Cho php hin th thng bo khi to i din (proxy).
Gii thch thm: i din (proxy) c th hiu nh sau: cc i
tng do cc phn mm khc hoc do cc chng trnh ng
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

200

Lp trnh ng dng trong AutoCAD - Ph lc 2


dng ARX to ra (nh, bng biu, vn bn ...) c th
hin (nhng kt) trong AutoCAD, khi m AutoCAD, cc i
tng khng c hin th y m ch hin th bng
k hiu i din nh nhng hnh ch nht hoc cc k hiu
khc. C hai trng hp phi dng n i din (proxy):
1 - Khi m bn v c cha cc i tng ni trn nhng
phn mm to ra n khng c ci t trong my.
2 - Khi loi (unload) ng dng to i tng ra khi
AutoCAD.
Khi AutoCAD s hin th hp thoi thng bo v s
lng, tn ca cc ng dng vng mt v tng s cc i
din ( ho cng nh khng phi ha).

Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:


Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: proxynotice
Dng nhc xut hin:
New value for PROXYNOTICE <1>:
Cho mt trong cc s sau:
0
Khng c li thng bo khi hin th i din.
1
C li thng bo khi hin th i din.
210. PROXYSHOW
Cho hin i din tron bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: proxyshow
Dng nhc xut hin:
New value for PROXYSHOW <1>:
Cho mt trong cc s sau:
0
Khng hin i din.
1
Hin nh ha cho tt c cc loi i din.
2
Ch hin khung cho tt c cc i din.
211. PSLTSCALE
nh t l -ng nt cho khng gian giy v (paper space).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved
in:Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: psltscale
Dng nhc xut hin:
New value for PSLTSCALE <1>:
Cho mt trong cc s sau:

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 201

0
1

Khng nh t l. di v khong cch gia cc on t ly


theo gi tr LTSCALE
T l ca ca nhn (Viewport scaling) khng ch t l
-ng nt (linetype scaling).

212. PSPROLOG
Cho tn ca phn m u (prolog section) c t tp tin
acad.psf khi dng lnh PSOUT.
Kiu gi tr: Chui k t (String), l-u tr vo h thng (saved
in:Registry).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: psprolog
Dng nhc xut hin:
New value for PSPROLOG, or . for none <"">:
Cho chui k t hoc g du chm (.) nu khng cn.
213. PSQUALITY
nh cht l-ng t bng (render) ca nh PostScript.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved
in:Regitry).
Gi tr mc nh (Initial value): 75
Dng lnh: Command: psquality
Dng nhc xut hin:
New value for PSQUALITY <75>:
Cho mt s nguyn vi nguyn tc:
=0
t gi tr off cho vic khi to nh PostScript.
<0
S im nh (pixels) cho mi n v v (ly gi tr tuyt i).
>0
S im nh (pixels) cho mi n v v.

Q
214. QTEXTMODE
t ch hin th ch (text) trong bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved
in:Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: qtextmode
Dng nhc xut hin:
New value for QTEXTMODE <0>:
Cho mt trong cc s sau:
0
Cho Quick Text mode l off; ch hin y .

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

202

Lp trnh ng dng trong AutoCAD - Ph lc 2

1
nht.

Cho Quick Text mode l on; dng ch thay bng hnh ch

R
215. RASTERPREVIEW
Cho xem nh tr-c khi chn vo bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: rasterpreview
Dng nhc xut hin:
New value for RASTERPREVIEW <1>:
Cho mt trong cc gi tr sau:
0
Khng cho xem tr-c.
1
Cho xem tr-c.
216. REGENMODE
t ch t ng khi to li (regen) bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: regenmode
Dng nhc xut hin:
New value for REGENMODE <1>:
Cho mt trong cc gi tr sau:
0
Cho REGENAUTO l off; khng t ng khi to li bn v
mi khi thc hin cc lnh c lin quan.
1
Cho REGENAUTO l on; t ng khi to li bn v.
217. RE-INIT
Khi ng bn iu khin s (digitizer), cng ni v tp tin
acad.pgp.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: re-init
Dng nhc xut hin:
New value for RE-INIT <0>:
Cho mt trong cc gi tr sau:
1
Khi ng Digitizer v cng I/O.
4
Khi ng Digitizer.
16
Khi ng li tp tin PGP.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 203

218. RTDISPLAY
Cho hin li nh qut khi thc hin ZOOM hoc PAN.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: rtdisplay
Dng nhc xut hin:
New value for RTDISPLAY <1>:
Cho mt trong cc gi tr sau:
0
Cho hin th ni dung nh.
1
Ch hin khung nh.

S
219. SAVEFILE
Cha tn tp tin l-u tr t ng (auto-save).
Kiu gi tr: Chui k t (String), ch c (Read-only), l-u tr vo h
thng (saved in: Registry).
Gi tr mc nh (Initial value): "auto.sv$"
Dng lnh: Command: savefile
Kt qu:
SAVEFILE = "auto.sv$" (read only)
220. SAVENAME
Cha tn v -ng dn tp tin bn v hin hnh.
Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u tr
(Not saved).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: savename
Kt qu:
SAVENAME = "" (read only)
221. SAVETIME
nh sau bao nhiu thi gian (pht) AutoCAD s t ng l-u tr bn v.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 120
Dng lnh: Command: savetime
Dng nhc xut hin:
New value for SAVETIME <120>:
Cho mt trong cc gi tr sau:
=0
Khng l-u tr t ng.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

204

Lp trnh ng dng trong AutoCAD - Ph lc 2

>0

C l-u tr t ng sau thi gian cho.

222. SCREENBOXES
Cha s dng trn Menu dc mn hnh (screen menu). Nu khng hin
th Screen Menu th SCREENBOXES = 0.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), l-u tr vo h
thng (saved in: Registry).
Dng lnh: Command: screenboxes
Kt qu:
SCREENBOXES = 0 (read only)
223. SCREENMODE
Cha m thng tin v trng thi ca mn hnh ho (graphics) v mn
hnh ch (text).
Kiu gi tr: S nguyn (Integer), ch c (Read-only), l-u tr vo h
thng (saved in: Registry).
Dng lnh: Command: savefile
Kt qu:
SAVEFILE = 1 (read only).
Cc gi tr c ngha sau:
0
Mn hnh ch (Text) ang hin hnh.
1
Mn hnh ho (Graphics) ang hin hnh.
2
C hai mn hnh cng hin th.
224. SCREENSIZE
Cha kch th-c ca nhn (tnh bng im nh - pixels).
Kiu gi tr: Danh sch im 2D (List 2D point), ch c (Readonly), khng l-u tr (Not saved).
Dng lnh: Command: screensize
Kt qu:
SCREENSIZE = 780.0000,341.0000 (read only).
225. SHADEDGE
nh kiu hin th (shading) cnh ca i t-ng khi t bng
(rendering).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 3
Dng lnh: Command: shadedge
Dng nhc xut hin:
New value for SHADEDGE <3>:
Cho mt trong cc gi tr sau:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 205

0
1
2
3

Mt -c t bng, cnh khng bt sng.


Mt -c t bng, cnh -c t theo mu nn ca AutoCAD.
Mt khng t, cnh t theo mu i t-ng.
Mt t theo mu i t-ng, cnh t theo mu nn.

226. SHADEDIF
t tn x phn chiu nh sng ln vt th khi t bng.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 70
Dng lnh: Command: shadedif
Dng nhc xut hin:
New value for SHADEDIF <70>:
Cho gi tr tu .
227. SHPNAME
Cho tn mc nh ca kiu t bng (Shape).
Kiu gi tr: Chui k t (String), khng l-u tr (Not saved).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: shpname
Dng nhc xut hin:
New value for SHPNAME, or . for none <"">:
Cho tn hoc g du chm (.) nu khng cn.
228. SKETCHINC
t di ca mi on trong lnh SKETCH.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.1000
Dng lnh: Command: sketchinc
Dng nhc xut hin:
New value for SKETCHINC <0.1000>:
Cho gi tr tu .
229. SKPOLY
nh dng i t-ng sinh ra do lnh SKETCH l cc on thng ri rc
(lines) hay l mt a tuyn lin (polylines).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: skpoly
Dng nhc xut hin:
New value for SKPOLY <0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

206

Lp trnh ng dng trong AutoCAD - Ph lc 2

Cho gi tr nh- sau:


0
L cc on thng ri rc.
1
L mt a tuyn.
230. SNAPANG
t ch snap v gc nghing ca l-i mn hnh (grid) cho ca nhn
(viewport) hin hnh.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: snapang
Dng nhc xut hin:
New value for SNAPANG <0.000>:
Cho gi tr tu .
231. SNAPBASE
t im gc (origin point) cho l-i mn hnh (grid) v ch
snap ca ca nhn (viewport) hin hnh.
Kiu gi tr: Danh sch im (List 2D point), l-u tr vo bn v
(saved in: Drawing).
Gi tr mc nh (Initial value): 0.000,0.0000
Dng lnh: Command: snapbase
Dng nhc xut hin:
New value for SNAPBASE <0.000,0.000>:
Cho danh sch im.
232. SNAPISOPAIR
t ch mt phng hnh chiu trc o (isometric plane) cho ca
nhn (viewport) hin hnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: snapisopair
Dng nhc xut hin:
New value for SNAPISOPAIR <0>:
Cho mt trong cc gi tr sau:
0
Tri qua phi (Left).
1
Trn xung (Top).
2
Phi qua tri (Right).
233. SNAPMODE
Bt ch snap.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 207

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: snapmode
Dng nhc xut hin:
New value for SNAPMODE <0>:
Cho mt trong cc gi tr sau:
0
Snap l OFF.
1
Snap l ON.
234. SNAPSTYL
t kiu bt l-i (snap).
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: snapstyl
Dng nhc xut hin:
New value for SNAPSTYL <0>:
Cho mt trong cc gi tr sau:
0
Kiu chun (Standard)
1
Kiu hnh chiu trc o (Isometric)
235. SNAPUNIT
t khong cch gia cc nt bt l-i.
Kiu gi tr: Danh sch im (List 2D point), l-u tr vo bn v
(saved in: Drawing).
Gi tr mc nh (Initial value): 0.5000,0.50000
Dng lnh: Command: snapunit
Dng nhc xut hin:
New value for SNAPUNIT <0.5000,0.5000>:
Cho to cn thit.
236. SORTENTS
t m kim sot thao tc phn loi (sort) trong lnh DDSELECT.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 96
Dng lnh: Command: sortents
Dng nhc xut hin:
New value for SORTENTS <96>:
Cho mt trong cc gi tr sau:
0
Khng phn loi.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

208

Lp trnh ng dng trong AutoCAD - Ph lc 2

1
Phn loi theo vic chn i t-ng (object selection).
2
Phn loi theo vic bt im (object snap).
4
Phn loi theo redraws
8
Phn loi theo REGEN.
32
Phn loi theo vic in (plotting)
64
Phn loi theo vic xut ra PostScript.
Nu cho cc s ngoi cc s trn, tu chn s l tng cc m to thnh
s cho.
237. SPLFRAME
Cho hin c -ng trn v a tuyn gc sau khi lm trn hoc v bng
SPLINE.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: splframe
Dng nhc xut hin:
New value for SPLFRAME <0>:
Cho mt trong cc gi tr sau:
0
Khng hin a tuyn gc.
1
C hin a tuyn gc.
238. SPLINESEGS
nh s on thng (line segments) to ra mt on cong (line
segments) ca a tuyn khi chuyn thnh -ng cong trn bng Pedit
- Spline.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 8
Dng lnh: Command: splinesegs
Dng nhc xut hin:
New value for SPLINESEGS <8>:
Cho s nguyn tu .
239. SPLINETYPE
nh dng -ng cong ca a tuyn khi chuyn thnh -ng cong trn bng
Pedit - Spline.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: splinetype
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 209

New value for SPLINETYPE <6>:


Cho mt trong cc s:
5
-ng cong bc hai (Quadratic B-spline).
6
-ng cong bc ba (Cubic B-spline).
240. SURFTAB1
t gi tr s cc nt l-i trn cnh th nht (M) ca khung dy to thnh
mt l-i bng RULESURF v TABSURF.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: surftab1
Dng nhc xut hin:
New value for SURFTAB1 <6>:
Cho gi tr tu :
241. SURFTAB2
t gi tr s cc nt l-i trn cnh th hai (N) ca khung dy to thnh
mt l-i RULESURF and TABSURF.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: surftab2
Dng nhc xut hin:
New value for SURFTAB2 <6>:
Cho gi tr tu .
242. SURFTYPE
nh dng mt khi to thnh cc mt cong trn bng PEDIT - Smooth.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: surftype
Dng nhc xut hin:
New value for SURFTYPE <6>:
5
Mt cong bc hai.
6
Mt cong bc ba.
8
Mt Bezier.
243. SURFU
t mt nt l-i trn h-ng M mt khi dng PEDIT - Smooth.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

210

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: surfu
Dng nhc xut hin:
New value for SURFU <6>:
Cho gi tr tu .
244. SURFV
t mt nt l-i trn h-ng N mt khi dng PEDIT - Smooth.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 6
Dng lnh: Command: surfv
Dng nhc xut hin:
New value for SURFV <6>:
Cho gi tr tu .
245. SYSCODEPAGE
Trang m h thng -c xc nh ti tp tin acad.xmx.
Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: savename
Kt qu:
SYSCODEPAGE = "ANSI_1252" (read only)
Trang m h thng c th l:
ascii
dos860
dos932
iso8859-7
big5
dos861
gb2312
iso8859-8
dos437
dos863
iso8859-1 iso8859-9
dos850
dos864
iso8859-2 johab
dos852
dos865
iso8859-3 ksc5601
dos855
dos866
iso8859-4 mac-roman
dos857
dos869
iso8859-6
Cc m chu :
Tn (Name)
CharSet Name
M ANSI
Chinese (Simplified)
GB2312-80
CP936
Chinese (Traditional)
Big-5
CP950
Japanese
Shift-JIS
CP932
Korean (Wansung)
KS C-5601-1987
CP949
Korean (Johab)
KS C-5601-1992
CP1361

T
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 211

246. TABMODE
t ch s dng bn iu khin s (Tablet - Digitizer).
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: tabmode
Dng nhc xut hin:
New value for TABMODE <0>:
0
Cho Tablet mode off; khng dng bn iu khin s
(Tablet - Digitizer).
1
Cho Tablet mode on; c dng bn iu khin s (Tablet Digitizer).
247.
TARGET
Cha ta tiu im ca ca nhn (viewport) hin hnh.
Kiu gi tr: Danh sch im (List 3D point), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: target
Kt qu:
TARGET = 0.0000,0.0000,0.0000 (read only)
248. TDCREATE
Cha ngy thng v thi gian to bn v.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Dng lnh: Command: tdcreate
Kt qu:
TDCREATE = 2451286.54687095 (read only)
249. TDINDWG
Cha tng thi gian sa cha bn v.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Dng lnh: Command: tdindwg
Kt qu:
TDINDWG = 0.03257326 (read only)
250. TDUPDATE
Cha thi gian v ngy thng cp nht bn v ln cui cng.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Dng lnh: Command: tdupdate
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

212

Lp trnh ng dng trong AutoCAD - Ph lc 2

Kt qu:
TDUPDATE = 2451286.54687095 (read only)
251. TDUSRTIMER
Cha thi gian s dng.
Kiu gi tr: S thc (Real), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Dng lnh: Command: tdupdate
Kt qu:
TDUSRTIMER = 0.03741806 (read only)
252. TEMPPREFIX
Cha tn th- mc cha cc tp tin l-u tr tm (temporary files) .
Kiu gi tr: Chui k t (String), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: tempprefix
Kt qu:
TEMPPREFIX = "C:\WINDOWS\TEMP\" (read only)
253. TEXTEVAL
nh ph-ng thc xc nh dng ch.
Kiu gi tr: S nguyn (Integer), khng l-u tr (Not saved).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: texteval
Dng nhc xut hin:
New value for TEXTEVAL <0>:
Cho mt trong cc s sau:
0
p li y dng ch v cc c tnh (attribute) khi bt
u g.
1
Dng ch bt u vi cc du ngoc ton hc [(] hoc du
chm thanan (!) -c coi l cc biu thc ca AutoLISP, khng
phi l dng ch.
Ch : lnh DTEXT b qua gi tr TEXTEVAL.

254.
TEXTFILL
nh ch t c hay rng cc kiu ch Bitstream, TrueType,
v Adobe Type 1.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: textfill
Dng nhc xut hin:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 213

New value for TEXTFILL <1>:


Cho mt trong cc s sau:
0
Ch rng.
1
Ch c.
255. TEXTQLTY
nh cht l-ng khi kt xut hoc t bng (render) ca cc kiu ch
Bitstream, TrueType, v Adobe Type 1.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):50
Dng lnh: Command: textqlty
Dng nhc xut hin:
New value for TEXTQLTY <50>:
Cho mt trong cc s t 0 n 100; s cng ln, cht l-ng cng cao.
256. TEXTSIZE
Cho chiu cao mc nh ca dng ch sp v theo kiu (style) ci t.
Gi tr ny khng c tc dng khi chiu cao ch -c t sn trong lnh
STYLE.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.2000
Dng lnh: Command: textsize
Dng nhc xut hin:
New value for TEXTSIZE <0.2000>:
Cho gi tr tu .
257. TEXTSTYLE
t tn kiu ch.
Kiu gi tr: Chui k t (String), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): "STANDARD"
Dng lnh: Command: textstyle
Dng nhc xut hin:
New value for TEXTSTYLE <"STANDARD">:
Cho tn kiu ch.
258. THICKNESS
t chiu cao ko dn theo trc Z.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.0000
Dng lnh: Command: thickness
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

214

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dng nhc xut hin:


New value for THICKNESS <0.0000>:
Cho gi tr tu .
259. TILEMODE
Chuyn khng gian v.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value):1
Dng lnh: Command: tilemode
Dng nhc xut hin:
New value for TILEMODE <1>:
Cho mt trong cc gi tr sau:
0
Chuyn sang khng gian giy v (paper space).
1
Khng gian m hnh (model space).
260. TOOLTIPS
Cho hin li nhc nh (tooltips) trn mn hnh trong khi thc hin cc
lnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value):1
Dng lnh: Command: tooltips
Dng nhc xut hin:
New value for TOOLTIPS <1>:
Cho mt trong cc gi tr sau:
0
Cho hin li nhc nh (tooltips).
1
Khng hin li nhc nh (tooltips).
261. TRACEWID
t gi tr mc nh cho b rng ca trace.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value):0.0500
Dng lnh: Command: tracewid
Dng nhc xut hin:
New value for TRACEWID <0.0500>:
Cho gi tr tu .
262. TREEDEPTH
nh chiu su khng gian. Bin ny gm 4 ch s, hai s u dng cho
khng gian m hnh (model space), hai s sau dng cho khng gian giy
v (paper space).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 215

Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:


Drawing).
Gi tr mc nh (Initial value):3020
Dng lnh: Command: treedepth
Dng nhc xut hin:
New value for TREEDEPTH <3020>:
Cho mt gi tr.
263. TREEMAX
t gii hn cho dung l-ng b nh cn dng khi to bn v vi cc nt
khng gian c gii hn.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 10000000
Dng lnh: Command: treemax
Dng nhc xut hin:
New value for TREEMAX <10000000>:Cho mt gi tr.
264. TRIMMODE
nhh ch ct b phn tha ca cc i t-ng khi dng fillet v
chamfers.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: trimde
Dng nhc xut hin:
New value for TRIMMODE <1>:
Cho mt trong cc gi tr:
0
Khng ct b.
1
C ct b.

U
265. UCSFOLLOW
Chuyn sang ca nhn phng (plan view) bt c lc no khi ng-i dng
chuyn t h ta ny sang h khc.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: ucsfollow
Dng nhc xut hin:
New value for UCSFOLLOW <0>:
Cho mt trong cc gi tr:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

216

Lp trnh ng dng trong AutoCAD - Ph lc 2

0
1

H ta khng nh h-ng n ca nhn.


Mi khi thay i h ta , ko theo ca nhn l phng.

266. UCSICON
Cho hin th k hiu h ta .
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: ucsicon
Dng nhc xut hin:
New value for UCSICON <1>:
Cho mt trong cc gi tr:
0
Khng hin k hiu gc ta .
1
UCSICON l On; c hin k hiu gc ta lun gc tri
pha d-i mn hnh.
2
UCSICON l Origin; c hin k hiu gc ta lun gc
ta hin hnh.
267. UCSNAME
Cha tn ca h UCS. Tr ra kt qu Nil nu h ta khng dt tn.
Kiu gi tr: Chui k t (String), ch c (Read-only), l-u tr vo bn
v (saved in: Drawing).
Dng lnh: Command: uscname
Kt qu:
UCSNAME = "" (read only).
268. UCSORG
Cha ta im gc ca h ta cho khng gian hin hnh.
Kiu gi tr: Danh sch im (List 3Dpoint), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: ucsorg
Kt qu:
UCSORG = 0.0000,0.0000,0.0000 (read only).
269. UCSXDIR
Cha ta im ngn ca vect n v trn trc X ca UCS hin hnh.
Kiu gi tr: Danh sch im (List 3Dpoint), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: ucsxdir
Kt qu:
UCSXDIR = 1.0000,0.0000,0.0000 (read only)
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 217

270. UCSYDIR
Cha ta im ngn ca vect n v trn trc Y ca UCS hin hnh.
Kiu gi tr: Danh sch im (List 3Dpoint), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: ucsydir
Kt qu:
UCSXDIR = 0.0000,1.0000,0.0000 (read only)
271. UNDOCTL
Cha m ch trng thi ca lnh UNDO.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: undoctl
Kt qu:
UNDOCTL = 5 (read only)
Kt qu c th l tng cc gi tr sau:
0
UNDO l off.
1
UNDO l on.
2
Ch thc hin mt ln cho mt lnh.
4
Cho ch Auto l on.
8
Ch group l hot ng (active).
272. UNDOMARKS
Cha m ch trng thi ca tu chn marks trong lnh UNDO.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: undomarks
Kt qu:
UNDOMARKS = 0 (read only)
273. UNITMODE
nh dng cc n v khi hin th ln mn hnh.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: unitmode
Dng nhc xut hin:
New value for UNITMODE <1>:
Cho mt trong cc gi tr:
0
Hin th dng fractional, feet-and-inches, v gc
trc c (surveyor's angles) nh- ci t.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

218

Lp trnh ng dng trong AutoCAD - Ph lc 2

1
Hin th dng fractional, feet-and-inches, v gc
trc c (surveyor's angles) nh- khi nhp vo.
274. uSERI1-5
Cc bin USERI1, USERI2, USERI3, USERI4, v USERI5 -c dng
cha s nguyn v ly gi tr ca chng.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: useri1
Dng nhc xut hin:
New value for USERI1 <0>:
Cho mt gi tr.
275. USERR1-5
Cc bin USERR1, USERR2, USERR3, USERR4, v USERR5 -c dng
cha s thc v ly gi tr ca chng.
Kiu gi tr: S thc (Real), l-u tr vo bn v (saved in: Drawing).
Gi tr mc nh (Initial value): 0.0000
Dng lnh: Command: userr1
Dng nhc xut hin:
New value for USERR1 <0.0000>:
Cho mt gi tr.
276. USERS1-5
Cc bin USERS1, USERS2, USERS3, USERS4, v USERS5 -c dng
cha s thc v ly gi tr ca chng.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: users1
Dng nhc xut hin:
New value for USERS1 <"">:
Cho mt chui k t.

V
277. VIEWCTR
Cha tm im ca ca nhn (viewport).
Kiu gi tr: Danh sch im (List 3Dpoint), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: viewctr
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 219

Kt qu:
VIEWCTR = 10.3103,4.5000,0.0000 (read only)
278. VIEWDIR
Cha h-ng nhn ca ca nhn (viewport) hin hnh trong UCS. y
chnh l im t ca camera cch im ch (target point).
Kiu gi tr: Danh sch im (List 3D vector), ch c (Readonly), l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: viewdir
Kt qu:
VIEWDIR = 0.0000,0.0000,1.0000 (read only)
279. VIEWMODE
M kim sot ch nhn (View).
Kiu gi tr: S nguyn (Integer), ch c (Read-only), l-u tr vo bn
v (saved in: Drawing).
Dng lnh: Command: viewmode
Kt qu:
VIEWMODE = 0 (read only)
Kt qu cs th l tng cc s sau:
0
View l off.
1
Nhn vin cnh (Perspective view).
2
Nhn thng chnh din (Front clipping).
4
Nhn t pha sau (Back clipping).
8
Theo UCS (Follow mode).
16
Nhn chnh din khng phi t mt, m gi tr FRONTZ thc
hin chnh din phng. Nu off (khng bng 16) , FRONTZ s
b b qua, v mt chnh din -c t thng qua im t
camera.
280.
VIEWSIZE
Cha chiu cao ca nhn (viewport) hin hnh.
Kiu gi tr: S thc (Integer), ch c (Read-only),
l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: viewsize
Kt qu:
VIEWSIZE = 9.0000 (read only)
281.
VIEWTWIST
Cha gc xoay ca ca nhn (viewport) hin hnh.
Kiu gi tr: S thc (Integer), ch c (Read-only), l-u tr vo bn v
(saved in: Drawing).
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

220

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dng lnh: Command: viewtwist


Kt qu:
VIEWTWIST = 0 (read only)
282. VISRETAIN
Cho hin th cc lp (layers) trong cc tp tin xref.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: visretain
Dng nhc xut hin:
New value for VISRETAIN <1>:
Cho mt trong cc gi tr:
0
Cc lp (layer) ca bn v tham chiu (xref) cng -c ci
t li cc chc nng: On/Off, Freeze/Thaw, Color,
v Linetype. Nh-ng cc ci t ny khng -c l-u tr cng
bn v, ngha l khi m bn v ra mi ci t tr li nh- trng
thi nguyn thu.
1
Cc lp (layer) ca bn v tham chiu (xref) cng -c ci
t li cc chc nng: On/Off, Freeze/Thaw, Color,
v Linetype. Cc ci t ny -c l-u tr cng bn v, ngha
l khi m bn v ra mi ci t -c th hin y .
283. VSMAX
Cha im gc cao bn phi mn hnh o ca ca nhn hin hnh -c biu
din nh- h UCS.
Kiu gi tr: Danh sch im (List 3D vector), ch c (Readonly), l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: vsmax
Kt qu:
VSMAX = 61.8618,27.0000,0.0000 (read only)
284. VSMIN
Cha im gc thp bn tri mn hnh o ca ca nhn hin hnh -c biu
din nh- h UCS.
Kiu gi tr: Danh sch im (List 3D vector), ch c (Readonly), l-u tr vo bn v (saved in: Drawing).
Dng lnh: Command: vsmin
Kt qu:
VSMIN = -41.2412,-18.0000,0.0000 (read only)

W
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 221

285. WORLDUCS
Ch ra UCS c ging h ta World hay khng.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), khng l-u tr
(Not saved).
Dng lnh: Command: worlducs
Kt qu:
WORLDUCS = 1 (read only)
Cc gi tr c th l:
0
UCS khc vi World Coordinate System.
1
UCS ging nh- World Coordinate System.
286.
WORLDVIEW
Cho php thay UCS bng WCS khi thc hin DVIEW hoc VPOINT.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: worldview
Dng nhc xut hin:
New value for worldview <1>:
Cho mt trong cc gi tr:
0
H UCS khng b thay th
1
H UCS b thay bng WCS.
287. WRITESTAT
M iu khin c tnh ca tp tin bn v tr thnh ch c (read-only)
dng ngn khng cho ghi t AutoLISP.
Kiu gi tr: S nguyn (Integer), ch c (Read-only), l-u tr vo bn
v (saved in: Drawing).
Dng lnh: Command: writestat
Kt qu:
WRITESTAT = 1 (read only)
Cc gi tr c th l:
0
Khng cho php ghi tip (save) vo bn v.
1
Cho php ghi vo bn v.

X
288. XCLIPFRAME
Cho hin khung ca bn v xref.
Kiu gi tr: S nguyn (Integer), l-u tr vo bn v (saved in:
Drawing).
Gi tr mc nh (Initial value): 0
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

222

Lp trnh ng dng trong AutoCAD - Ph lc 2

Dng lnh: Command: xclipframe


Dng nhc xut hin:
New value for XCLIPFRAME <0>:
Cho mt trong cc gi tr:
0
Khng hin khung.
1
C hin khung.
289. XLOADCTL
i triu gi (demand loading) bn xref khi m bn v c cha xref.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 1
Dng lnh: Command: xloadctl
Dng nhc xut hin:
New value for XLOADCTL <1>:
Cho mt trong cc gi tr:
0
Cho off demand loading; bn v -c gi vo y .
1
Cho on demand loading; bn v tham chiu cng -c
m.
2
Cho on demand loading; ch c bn sao ca tham chiu
-c m.
290. XLOADPATH
Cho -ng dn cha tp tin l-u tr tm bn sao (copy) ca tp tin xref.
Kiu gi tr: Chui k t (Srtring), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): ""
Dng lnh: Command: xloadpath
Dng nhc xut hin:
New value for XLOADPATH, or . for none
<"C:\WINDOWS\TEMP\">:
Cho -ng dn hoc g du chm (.) nu khng cn.
291. XREFCTL
Cho php ghi vo tp tin nht k .XLG (Xref log) ca bn tham chiu
(external reference) hay khng.
Kiu gi tr: S nguyn (Integer), l-u tr vo h thng (saved in:
Registry).
Gi tr mc nh (Initial value): 0
Dng lnh: Command: xrefctkl
Dng nhc xut hin:
New value for XREFCTL <0>:
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 2 223

Cho mt trong cc gi tr sau:


0
Khng ghi vo tp tin .XLG (Xref log).
1
C ghi vo tp tin .XLG (Xref log).
Ht ph lc II

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

222

Lp trnh ng dng trong AutoCAD - Ph lc 3

Ph lc III
Cc m li v thng bo li trong lp trnh AutoLISP
P31. Cc m li
Bng sau y trnh by cc gi tr m gy li trong AutoLISP. Bin h
thng ERRNO s nhn mt trong cc gi tr ny khi AutoCAD gi cc hm
ca AutoLISP b li. AutoLISP cng c th kim sot li ca mnh bng hm
(getvar "errno") hi gi tr ca bin ERRNO hin thi.
Bin ERRNO lun b xo khi khi ng hoc m mt bn v mi.
Cc m v cc ngha ca n c th b thay i trong cc phin bn
AutoCAD sau ny.
Gi tr
ngha
0
Khng c li
1
Sai tn bng k hiu. Invalid symbol table name
2
Sai tn thc th hoc tn nhm trong tp hp chn (selection
set).
3
V-t qu s ti a trong tp tp chn(selection set).
4
Tp hp chn (selection set) khng ng.
5
Dng nh ngha khi (block definition) khng ph hp
6
Dng xref sai.
7
Object selection: Chn khng ng i t-ng.
8
Kt thc tp tin cha i t-ng.
9
Kt thc tp tin nh ngha khi.
10
Tm i t-ng cui cng trong bn v (last entity) khng thnh
cng.
11
Xa bt hp php i t-ng ca ca nhn (viewport object)
12
Thao tc khng -c php trong lnh PLINE.
13
iu khin sai (Invalid handle).
14
iu khin khng -c php (Handles not enabled).
15
Sai i s trong chuyn i h ta .
16
Sai v tr trong chuyn i h ta .
17
S dng sai cc i t-ng b xo.
18
Tn bng cc i t-ng (table name) sai.
19
Sai bng i s ca hm.
20
C tnh gn gi tr cho bin ch c (read-only variable).
21
Khng cho php nhn gi tr Zero.
22
Gi tr ngoi hng ngch (Value out of range).
23
Dng REGEN khng ng lc.
24
C tnh thay i kiu ca i t-ng (entity type).
25
Tn lp (layere) khng ng.
26
Tn -ng nt (linetype) khng ng.
27
Tn mu (color) khng ng.
28
Tn kiu ch (text style) khng ng.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 3 223

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70

Tn shape khng ng.


Tr-ng (field) l-u tr kiu ca thc th (entity type) khng ng.
C tnh modify i t-ng b xa (deleted entity).
C tnh modify i t-ng con trong dy (seqend subentity).
C tnh thay i iu khin (handle).
C tnh modify ca nhn (viewport) ang hin th (visibility)
i t-ng ca lp b kha.
Kiu thc th (entity type) sai.
i t-ng dng (polyline entity) khng ng.
Gom thiu cc i t-ng trong khi.
Tr-ng (field) tn khi sai.
t trng m lnh (flag) ca khi.
t trng tn khi.
Vct php tuyn (normal vector) sai.
Thiu tn khi.
Thiu m lnh (flag) ca khi.
Khi khng tn (anonymous block) sai.
nh ngha khi khng ng.
Thiu lnh.
Kiu d liu m rng (XDATA) khng t-ng thch
Cc nhnh danh sch d liu m rng (XDATA) sai.
V tr ca tr-ng APPID khng ng.
V-t qu kch th-c ln nht ca XDATA.
Entity selection: khng chn -c i t-ng.
Dng APPID trng.
C tnh to hoc tu sa ca nhn (viewport).
C tnh to hoc tu sa xref, xdef, hoc xdep
ssget filter: kt thc danh sch mt cch t ngt.
ssget filter: thiu theo tc th (test)
ssget filter: m opcode (-4) ca chui k t sai.
ssget filter: mnh iu kin hoc mnh iu kin lng
nhau (nesting) sai.
ssget filter: mnh iu kin thiu m u hoc kt thc.
ssget filter: s i s trong mnh khng ng (dng cho NOT
hoc XOR)
ssget filter: v-t qu gii hn lng nhau ti a.
ssget filter: m nhm (group code) sai.
ssget filter: th chui (string test) sai.
ssget filter: th vc t (vector test) sai.
ssget filter: th s thc (real test) sai.
ssget filter: th s nguyn (integer test) sai.
Digitizer khng phi l bng (tablet).
Tablet khng -c nh kch th-c.
i s ca tablet sai.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np ti

224

Lp trnh ng dng trong AutoCAD - Ph lc 3

71
72
73
74
75
76
77
78
79
80
81
82
83
84

85

Li ADS : khng cp pht b nh cho kt qu mi.


Li ADS : pht hin thy im Null.
Khng m -c tp tin chy ch-ng trnh (executable file).
ng dng -c triu gi ri.
S l-ng ti a trnh ng dng -c triu gi.
Khng cho chy cc trnh ng dng.
S phin bn (version) khng t-ng thch.
Khng cho g b (unload) ng dng lng nhau.
ng dng t chi g b (unload).
ng dng khng -c triu gi kp thi.
Khng b nh triu gi ng dng.
Li ADS: li ma trn chuyn i (transformation matrix).
Li ADS: li tn symbol.
Li ADS: li gi tr symbol.
Cc hot ng ca AutoLISP/ADS b cm khi hp thai ang
hin th.

P32. Cc thng bo li
Trong lp trnh chng ta th-ng gp nhng li v c php nh- thiu
du ngoc, thiu nh ngha bin, hm, cc li v x l d liu v.v....
Khi chy ch-ng trnh, nu gp li, AutoLIST -a ra thng bo li.
Mt li c th do nhiu nguyn nhn. D-i y l cc thng bo li ca
AutoCAD khi thc hin cc lnh trong AutoLISP.
Arguments of a defun can't have the same name
Cc i s trong hm c s trng tn.
AutoCAD rejected function
Cc nguyn nhn:- Truyn tham s cho cc hm AutoCAD b sai (nhl truyn gi tr cho cc bin h thng ch c (read-only) hoc tblnext
vi tn bng khng ng).
- Bn thn hm khng ng trong ng cnh hin hnh.
V d:Khng -c dng getxxx nhp s liu bn trong cc hm ra
lnh ca AutoCAD.
AutoLISP stack overflow
Ngn xp b trn.
Cc nguyn nhn:
- Chy cc hm hi qui (t gi) v tn.
- C qu nhiu bin s hoc gi tr bin qu ln.
bad argument type
Truyn d liu khng ng kiu ca i s.
V d: khng -c dng hm strlen (ly di chui k t) i vi
kiu integer (s nguyn)
bad association list
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 3 225

Danh sch kt hp trong hm khng ph hp vi cc gi tr ca danh sch.


bad conversion code
M chuyn i sai.
Sai v ch truyn s liu cho hm chuyn i.
bad ENTMOD list
Tham s truyn cho entmod khng ng vi d liu ca thc th.
bad ENTMOD list value
Gi tr danh sch ENTMOD sai.
Mt trong danh sch con trong danh sch ln truyn cho entmod c
cha gi tr sai.
bad formal argument list
Danh sch bin hnh thc sai.
Khi ly gi tr ca hm s, AutoLISP gp phi danh sch bin hnh thc
khng ng, c l hm khng phi l hm m l danh sch d liu.
bad function
Hm khng ng.
Cc nguyn nhn:
- y ch l tn bin hoc ch s, khng phi l tn hm nh-ng li gi
ra nh- mt hm.
- Hm ch-a -c nh ngha.
Khng loi tr tr-ng hp i hi phi c bin hnh thc.
bad function code
Sai m hm.
Hm truyn d liu cho lnh thao tc vi bng thc th b li.
bad grvecs list value
Gi tr danh sch vect ha (grvecs) sai.
Ci g truyn cho danh sch vect ha (grvecs) khng phi l 2D
hoc 3D.
Something that was passed in a grvecs list isn't a 2D or 3D point.
bad grvecs matrix value
Gi tr ma trn vect ha (grvecs) sai.
Ma trn truyn cho vect ha (grvecs) c li hoc cha d liu sai
kiu (v d kiu STR, SYM, v mt s kiu khc khng ph hp).
bad list
Danh sch sai.
Danh sch truyn cho hm khng hp. C th pht hin ra nh- s thc
thiu du chm thp phn.
bad list of points
Danh sch im sai.
Danh sch nhn gi tr Null hoc danh sch cha thnh phn khc vi
im.
bad node
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np ti

226

Lp trnh ng dng trong AutoCAD - Ph lc 3

Nt sai.
Kiu ca biu thc sai vi kiu hm.
bad node type in list
Kiu nt trong danh sch sai.
Kiu ca biu thc sai vi hm foreach.
bad point argument
bad point value
Gi tr im sai.
nh ngha im sai (danh sch gm 2 s thc). C th do du chm
thp phn ca ta im nh hn 1 gy ra, nn thm s 0 ng tr-c
cho r rng. V d: '(.123 2.45) hoc '(1.23 .34) d gy bo li, nn
thm '(0.123 2.45) hoc '(1.23 0.34) s r rng hn.
bad real number detected
S thc b pht hin l s sai.
Truyn s thc khng ng t AutoLISP sang AutoCAD.
bad ssget list
Danh sch ssget sai.
i s truyn cho (ssget "X") l khng ph hp vi d liu danh
sch ca thc th.
bad ssget list value
Mt gi tr ca danh sch ssget sai.
Mt trong danh sch con trong danh sch ln truyn cho (ssget "X")
l khng ph hp vi d liu danh sch ca thc th.
bad ssget mode string
Chui ghi m ca lnh ssget sai.
bad xdata list
Danh sch d liu m rng sai.
base point is required
Thiu im c s.
Trong lnh getcorner thiu im c s.
Boole arg1 0 or 15
i s th nht ca cc hm Boole l s nguyn t 0 n 15.
can't evaluate expression
Khng ly -c gi tr ca biu thc.
t sai du chm thp phn hoc mt s biu thc vit sai qui tc.
can't open (file) for input -- LOAD failed
Khng m -c tp tin nhp d liu - lnh LOAD khng thc hin -c.
Tn tp tin cn gi khng ng hoc tp tin khng c ni dung.
can't reenter AutoLISP
Khng th gi tip ch-ng trnh AutoLISP.
B m chung ca AutoCAD/AutoLISP ang b mt hm s dng. Hm
mi gi vo phi i khi hm ang hot ng kt thc.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 3 227

console break
Ngt cng.
Ng-i dng nhn CTRL+C trong qu trnh x l.
divide by zero
Chia cho 0.
Khng cho php trong php tnh chia cho 0.
divide overflow
Php chia y .
Chia cho mt gi tr qu nh dn n kt qu qu ln.
exceeded maximum string length
V-t qu chiu di ti a ca chui k t.
Chui ti a 132 k t.
extra right paren
Tha u ngoc bn phi.
Tha mt hay nhiu du ngoc bn phi.
file not open
Khng m -c tp tin.
file read--insufficient string space
Thiu b nh cha tp tin cn c.
file size limit exceeded
Tp tin di qu gii hn.
floating-point exception
S thp phn du phy ng b loi.
(Ch trong UNIX). Khi h thng truy cp n cc s thp phn du phy
ng trong s hc b li.
function canceled
Hm b ngng v thot.
Ng-i dng nhn CTRL+C hoc ESC.
function undefined for argument
i s khng xc nh (m h).
i s truyn cho hm Log hoc Sqrt ngoi phm vi.
function undefined for real
Hm c s thc m h.
S thc truyn cho i s nguyn ca hm.
A real number was passed as an argument to a function requiring an
integer--for instance, (lsh val 1.2).
grvecs missing endpoint
Vc t ho thiu im cui.
Danh sch truyn cho vect ha thiu ta im cui.
illegal type in left
Kiu bn tri bt hp php.

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np ti

228

Lp trnh ng dng trong AutoCAD - Ph lc 3

Tp tin *.LSP khng phi l tp tin ASCII thun khit, khi l-u tr phi
km theo m nh dng.
improper argument
i s khng ph hp.
i s ca hm gcd l m hoc s 0.
inappropriate object in function
i t-ng trong hm khng ph hp.
Hm -c xy dng sai.
incorrect number of arguments
S l-ng i s khng ng.
Hm cn chnh xc l mt i s nh-ng li -c cung cp s l-ng
khc.
incorrect number of arguments to a function
S l-ng i s cho hm khng ng.
S i s cho khi triu gi hm do ng-i dng nh ngha khng cn
xng vi i s hnh thc trong nh ngha hm.
incorrect request for command list data
D liu thc hin lnh khng ng.
Hm thc hin lnh b chn bi mt hm ang hot ng hoc hm ch-a
-c khi ng hon ton. Th-ng gp trong cc hm thc hin lnh
ca acad.lsp, acadr13.lsp hoc tp tin .mnl.
input aborted
Vic nhp d liu b hu b.
Tp tin d liu b li hoc kt thc t ngt, dn n kt thc vic nhp
liu.
insufficient node space
Thiu khong trng ca HEAP.
insufficient string space
Thiu khong trng ca HEAP cha dng ch.
invalid argument
i s sai.
Kiu i s khng ng, hoc i s ngoi phm vi.
invalid argument list
i s kiu danh sch sai.
i s kiu danh sch truyn cho hm khng ng.
invalid character
K t khng ng.
Trong biu thc c k t khng ph hp.
invalid dotted pair
Danh sch i c du chm b sai.
Danh sch i c du chm cha hai thnh vin cch nhau bng du
chm. D gp thng bo ny nu s thc bt u bng du chm thp
phn, bn c th thm s 0 ng tr-c trnh nhm ln.
Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np tin

Lp trnh ng dng trong AutoCAD - Ph lc 3 229

invalid integer value


Gi tr s nguyn sai.
Mt s nh hn s nguyn nh nht hoc ln hn s nguyn ln nht
u coi l sai.
LISPSTACK overflow
Trn STACK.
Cc nguyn nhn:
- Chy cc hm hi qui (t gi) v tn.
- C qu nhiu bin s hoc gi tr bin qu ln.
malformed list
Danh sch sai
S cc du ngoc m v ng trong ch-ng trnh khng bng nhau.
malformed string
Chui k t sai.
Chui c t tp tin kt thc t ngt.
misplaced dot
Du chm t sai.
Do s thc bt u bng du chm thp phn. Nn thm s 0 ng tr-c
cho r rng.
null function
Khng c hm.
C tnh triu gi hm ch-a c nh ngha.
quit/exit abort
Hm quit hoc exit -c triu gi.
string too long
Chui qu di.
Chui k t truyn cho hm setvar qu di.
too few arguments
Thiu i s.
i s truyn khi gi hm b thiu.
too few arguments to grvecs
Thiu i s cho grvecs
too many arguments
Tha i s.
i s khi gi hm b tha.
Ht ph lc III

Nguyn Vn Thip - Ti liu min ph, nu c ai li dng thu ph, cc bn ng np ti