Chủ Nhật, 7 tháng 2, 2010

Các tiện ích đo.

Tác dụng và hướng dẩn:
-Đo diện tích pline bằng cách chọn pline: gọi lệnh: DTICH
-Đo chu vi pline bằng cách chọn pline: gọi bằng lệnh: CHUVI
-Đo chu diện tích chữ nhật bằng cách pick 2 điểm góc hình chử nhật: gọi bằng lệnh: 2D Kết quả viết ra tại tâm hình chữ nhật.
-Đo diện tích 1 vùng kín bằng cách pick vào 1 điểm trong vùng: gọi bằng lệnh: DTICHP
*Lưu ý lệnh cho phép xác định gí trị 1 mét là bao nhiêu để tính toán ra diện tích theo tỏ lệ đang vẽ. Mặc định 1 mét vẽ là 1000, bạn muốn thay đổi giá trị này thì để ý khi nào lisp hỏi:
Mot met hien hanh la (1000) :
Hoặc:
Mot met hien hanh la (1000) :
Thì gỏ M enter lisp sẽ hỏi bạn: Mot met ban ve la <1000> : Bạn nhập vào enter rồi tiếp tục lệnh. Giá trị này sẽ lưu cho các lần gọi lệnh sau trong 1 phiên làm việc.

Bạn copy nội dung và tạo file lisp hay tải file về cũng được!

;Viet boi: KTS_DUY BINH SON - QUANG NGAI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:2d ( )
(dodientichbanghaidiem))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:dtich ( )
(dodientich))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:chuvi ( )
(dochuvi))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN C:dtichp ( )
(dodientichpicdiem))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(DEFUN dodientichbanghaidiem ( )
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(princ "\nPHAM QUOC DUY Binh Son - Quang ngai")
(if (null motmetdo2d)(setq motmetdo2d "1000"))
(Setq temp T)
(While temp
(setq a (strcat "\nMot met hien hanh la ("motmetdo2d") : "))
(Initget "m M")
(setq str (getpoint a))
(Cond
((= str "m") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
((= str "M") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(setq b (getcorner a"\nDiem thu hai: "))
(setq luubatdiem (getvar "osmode")) (setq luulop (getvar "clayer"))
(setvar "osmode" 0)

(command ".RECTANGLE" a b)
(command "area" "object" "last")
(setq dientichdo2d (getvar "area"))

(setq motmetdo2dt (atof motmetdo2d))
(setq dolonchu2d (/ motmetdo2dt 4))
(setq dientichdo2dtinh (/ dientichdo2d (* motmetdo2dt motmetdo2dt)))

(setq daitong2d (distance a b))
(setq dainua2d (/ daitong2d 2))
(setq goc2d(angle a b))
(setq diemviet2d (polar a goc2d dainua2d))

(command "erase" "last" "")
(command "TEXT" "m" diemviet2d dolonchu2d 0 (rtos dientichdo2dtinh 2 2))
(setvar "osmode" luubatdiem) (setvar "clayer" luulop)

(setvar "MODEMACRO" "**TAILIEUKYTHUAT.COM**")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(DEFUN dodientich ( )
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(princ "\nPHAM QUOC DUY Binh Son - Quang ngai")

(Prompt "\nChon doi tuong")
(Setq doituongdo (Ssget))
(setq luubatdiem (getvar "osmode")) (setq luulop (getvar "clayer"))
(setvar "osmode" 0)

(if (null motmetdo2d)(setq motmetdo2d "1000"))
(Setq temp T)
(While temp
(setq a (strcat "\nMot met hien hanh la ("motmetdo2d") : "))
(Initget "m M")
(setq str (getpoint a))
(Cond
((= str "m") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
((= str "M") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(command "area" "object" doituongdo)
(setq dientichdo2d (getvar "area"))

(setq motmetdo2dt (atof motmetdo2d))
(setq dolonchu2d (/ motmetdo2dt 4))
(setq dientichdo2dtinh (/ dientichdo2d (* motmetdo2dt motmetdo2dt)))

(setq dientichdo2dtinh (rtos dientichdo2dtinh 2 2))
; (setq dientichdo2dtinh (strcat "S=" dientichdo2dtinh))

(command "TEXT" a dolonchu2d 0 dientichdo2dtinh)
(setvar "osmode" luubatdiem) (setvar "clayer" luulop)
(setvar "MODEMACRO" "**TAILIEUKYTHUAT.COM**")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(DEFUN dochuvi ( )
(command "-style" "thep" "VNI-HELVE" "0" "1" "0" "n" "n")
(princ "\nPHAM QUOC DUY Binh Son - Quang ngai")

(Prompt "\nChon doi tuong")
(Setq doituongdo (Ssget))
(setq luubatdiem (getvar "osmode")) (setq luulop (getvar "clayer"))
(setvar "osmode" 0)

(if (null motmetdo2d)(setq motmetdo2d "1000"))
(Setq temp T)
(While temp
(setq a (strcat "\nMot met hien hanh la ("motmetdo2d") : "))
(Initget "m M")
(setq str (getpoint a))
(Cond
((= str "m") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
((= str "M") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(command "area" "object" doituongdo)
(setq dientichdo2d (getvar "Perimeter"))

(setq motmetdo2dt (atof motmetdo2d))
(setq dolonchu2d (/ motmetdo2dt 4))
(setq dientichdo2dtinh (/ dientichdo2d motmetdo2dt))

(setq dientichdo2dtinh (rtos dientichdo2dtinh 2 2))
; (setq dientichdo2dtinh (strcat "L=" dientichdo2dtinh))

(command "TEXT" a dolonchu2d 0 dientichdo2dtinh)
(setvar "osmode" luubatdiem) (setvar "clayer" luulop)
(setvar "MODEMACRO" "**TAILIEUKYTHUAT.COM**")
(princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(DEFUN dodientichpicdiem ( )

(setq luubatdiem (getvar "osmode")) (setq luulop (getvar "clayer"))
(setvar "osmode" 0)
(picpic)
(command "-boundary" diemchona "")


(setq doituongdo (entlast))

(if (null motmetdo2d)(setq motmetdo2d "1000"))
(Setq temp T)
(While temp
(setq a (strcat "\nMot met hien hanh la ("motmetdo2d") : "))
(Initget "m M")
(setq str (getpoint a))
(Cond
((= str "m") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
((= str "M") (setq motmetdo2d (getstring (strcat"\nMot met ban ve la <" motmetdo2d "> :"))))
(Progn
(Setq a str)
(setq temp nil)
)
)
)
(command "area" "object" doituongdo)
(setq dientichdo2d (getvar "area"))

(setq motmetdo2dt (atof motmetdo2d))
(setq dolonchu2d (/ motmetdo2dt 4))
(setq dientichdo2dtinh (/ dientichdo2d (* motmetdo2dt motmetdo2dt)))

(setq dientichdo2dtinh (rtos dientichdo2dtinh 2 2))

(command "TEXT" a dolonchu2d 0 dientichdo2dtinh)
(setvar "osmode" luubatdiem) (setvar "clayer" luulop)
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:dod ()
(dodegoi))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun dodegoi (/ COM)
(setq DCL_ID (load_dialog (strcat "c:" "\\tailieukythuat\\dcl\\do.DCL")))
(new_dialog "do" DCL_ID)
(action_tile "btn_2d" "(done_dialog 1)")
(action_tile "btn_dtich" "(done_dialog 2)")
(action_tile "btn_chuvi" "(done_dialog 3)")
(action_tile "btn_dtcv" "(done_dialog 4)")
(action_tile "btn_dtichp" "(done_dialog 5)")

(action_tile "btn_thoi" "(done_dialog 14)")


(action_tile "btn_zoom" "(done_dialog 50)")


(start_image "img_1")
(slide_image 0 0 (dimx_tile "img_1")(dimy_tile "img_1") (strcat "c:" "\\tailieukythuat\\dcl\\lgoduy01.sld"))
(end_image)
(setq phepchon (start_dialog))
(cond
((= phepchon 1) (dodientichbanghaidiem))
((= phepchon 2) (dodientich))
((= phepchon 3) (dochuvi))
((= phepchon 4) (dtcv))
((= phepchon 5) (dodientichpicdiem))



((= phepchon 14) (thoi))


((= phepchon 50) (zoomduy))

)
(princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;---------------------------------------
(defun nstr (stri def)
(princ stri)
(princ "<")
(princ " ")
(princ def)
(princ ">")
(princ ":")
(princ " ")
);defun nstr
;--------------------
(defun nstr1 (stri)
(princ stri)
(princ "<")
(princ "Nhap vao")
(princ ">")
(princ ":")
(princ " ")
);defun nstr1
;---------------------
(defun nint (prompt def / temp)
(if def
(setq temp (getint (nstr prompt def)))
(setq def (getint (nstr1 prompt)))
);if def
(if temp
(setq def temp)
def
);if temp
);defun nint
;---------------------
(defun dnint (prompt def / temp)
(if def
(setq temp (getreal (nstr prompt def)))
(setq def (getreal (nstr1 prompt)))
);if def
(if temp
(setq def temp)
def
);if temp
);defun nint
;--------------------
(defun ndist (po prompt def / temp) ;nhan kh/cach va luu gia tri mac dinh
(if def
(setq temp (getdist po (nstr prompt def)))
(setq def (getdist po (nstr1 prompt)))
)if def
(if temp
(setq def temp)
def
);if temp
);defun ndist
;-----------------------------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(Defun zoomduy ( )
(command ".zoom" "")
(Princ))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(Defun thoi ()
(princ "\nPHAM QUOC DUY Binh Son - Quang ngai")
(setvar "MODEMACRO" "**TAILIEUKYTHUAT.COM**")
(Princ)
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;