You are on page 1of 12

(defun c:vetuong () (initvetuong) (command "trim" "" "e" "e" "p" "n" "") (command "undo" "be") (setvar

"cmdecho" 0) (setq old_layer (getvar "clayer")) (setq snap (getvar "osmode")) (setq hl (getvar "highlight")) (setq tbl (tblsearch "layer" "tuong")) (if (= tbl nil) (command "-layer" "n" "tuong" "c" "4" "tuong" "") ) (setq tbl (tblsearch "layer" "_tim")) (if (= tbl nil) (command "-layer" "n" "_tim" "c" "8" "_tim" "l" "center" "_tim" "") ) (setq tbl (tblsearch "layer" "template")) (if (= tbl nil) (command "-layer" "n" "template" "") ) (setvar "clayer" "template") (setvar "osmode" 0) (setq ss (ssget '((0 . "line")))) (setq day (cond (day) (220) )

) (setq oldday day) (setq day (getint (strcat "\nnhap chieu day tuong <" (rtos oldday 2 1) "> : ") ) ) (if (null day) (setq day oldday) ) (setq day1 (/ (* day 7) 15)) (command "change" ss "" "p" "la" "_tim" "") (setq i 0) (setq lp nil) (setq ssml nil) (setq ssml (ssadd)) (while (< i (sslength ss)) (setq name (ssname ss i) ent (entget name) p1 (cdr (assoc 10 ent)) p2 (cdr (assoc 11 ent)) lp (append (list (append (list p1) (list p2))) lp) ) (command "mline" "j" "z" "s" day p1 p2 "") (command "explode" "l") (setq ssline (ssget "p"))

(setq line1 (ssname ssline 0)) (setq line2 (ssname ssline 1)) (setq ssml (ssadd line1 (ssadd line2 ssml))) (setq i (1+ i)) ) (command "-layer" "off" "_tim" "") (setq j 0) (setvar "highlight" 0) (while (< j (length lp)) (setq nhom (nth j lp) pt1 (car nhom) pt2 (last nhom) angf (+ (angle pt1 pt2) (/ pi 2)) t1 (polar pt1 angf day1) t2 (polar pt1 (+ angf pi) day1) t3 (polar pt2 (+ angf pi) day1) t4 (polar pt2 angf day1) ) (command "trim" ssml "" "f" t1 t2 t3 t4 t1 "" "") (setq j (1+ j)) ) (setq q 0) (setq ssml (ssget "x" '((0 . "line") (8 . "template")))) (while (< q (sslength ssml)) (setq l1 (ssname ssml q) pf1 (cdr (assoc 10 (entget l1)))

pf2 (cdr (assoc 11 (entget l1))) ) (setq k 0) (while (< k (sslength ssml)) (setq l2 (ssname ssml k)

pf3 (cdr (assoc 10 (entget l2))) pf4 (cdr (assoc 11 (entget l2))) d1 d2 d3 d4 ) (if (or (and (< d1 (* day1 2)) (> d1 0)) (and (< d2 (* day1 2)) (> d2 0)) (and (< d3 (* day1 2)) (> d3 0)) (and (< d4 (* day1 2)) (> d4 0)) ) (command "fillet" l1 l2) ) (setq k (1+ k)) ) (setq q (1+ q)) ) (command "change" ssml "" "p" "la" "tuong" "") (dimtuong) (setvar "clayer" old_layer) (distance pf1 pf3) (distance pf1 pf4) (distance pf2 pf3) (distance pf2 pf4)

(command "-layer" "on" "_tim" "") (setvar "osmode" snap) (setvar "highlight" hl) (setvar "cmdecho" 1) (command "undo" "e") (command "trim" "" "e" "n" "") ) ;****************************************** (defun c:vt () (command "trim" "" "e" "e" "p" "n" "") (command "undo" "be") (setvar "cmdecho" 0) (setq old_layer (getvar "clayer")) (setq snap (getvar "osmode")) (setvar "clayer" "tuong") (setq dt (cond (dt) (220) ) ) (setq olddt dt) (setq dt (getint (strcat "\nrong tuong <" (rtos olddt 2 1) "> : "))) (if (null dt) (setq dt olddt) ) (setq pt1 (getpoint "\ndiem thu nhat:") pt2 (getpoint "\ndiem thu hai:" pt1)

) (setvar "osmode" 0) (command "-layer" "off" "_tim" "") (command "mline" "j" "z" "s" dt pt1 pt2 "") (setq mll (entlast)) (command "trim" mll "" "f" pt1 pt2 "" "") (command "explode" mll) (setvar "osmode" snap) (setvar "clayer" old_layer) (command "-layer" "on" "_tim" "") (setvar "cmdecho" 1) (command "trim" "" "e" "n" "") ) ;***************************************** (defun c:vc () (setvar "cmdecho" 0) (setq old_layer (getvar "clayer")) (setq snap (getvar "osmode")) (setvar "clayer" "tuong") (setq cua (cond (cua) (900) ) ) (setq oldcua cua) (setq cua (getint (strcat "\nrong cua <" (rtos oldcua 2 1) "> : "))) (if (null cua)

(setq cua oldcua) ) (setq pc1 (getpoint "\ndiem thu nhat:") pc2 (getpoint "\ndiem thu hai:" pc1) ang (+ (angle pc1 pc2) (/ (* 90 pi) 180)) pc3 (polar pc1 ang (+ 110 (/ cua 2))) pc4 (polar pc2 ang (+ 110 (/ cua 2))) ) (setvar "osmode" 0) (command "-layer" "off" "_tim" "") (command "mline" "j" "z" "s" cua pc3 pc4 "") (setq mll (entlast)) (command "trim" mll "" "f" pc3 pc4 "" "") (command "explode" mll) (setvar "osmode" snap) (setvar "clayer" old_layer) (command "-layer" "on" "_tim" "") (setvar "cmdecho" 1) ) ;***************************************** (defun dimtuong (setq e nil c nil ) (setq tbl (tblsearch "layer" "_dim")) (if (= tbl nil) ()

(command "-layer" "n" "_dim" "c" "8" "_dim" "") ) (setvar "clayer" "_dim") (setq tldim (getvar "dimscale")) (setq th (getvar "dimtxt")) (setq a 0) (setq lpx nil) (setq lpy nil) (while (< a (length lp)) (setq px1 (car (car (nth a lp))) py1 (cadr (car (nth a lp))) px2 (car (cadr (nth a lp))) py2 (cadr (cadr (nth a lp))) ) (if (/= py1 py2)

(setq lpx (append (list px1) lpx)) ) (if (= py1 py2)

(setq lpy (append (list py1) lpy)) ) (setq a (1+ a)) ) (setq lpx (vl-sort lpx '<)) (setq lpy (vl-sort lpy '<)) (setq dc (- (last lpx) (car lpx))) (setq pdi (list (car lpx) (- (car lpy) (/ dc 40)) 0))

(setq pdi2 (list (- (car lpx) (/ dc 40)) (car lpy) 0)) (setq pdim (polar pdi pi (/ day 2))) (setq pdim2 (polar pdi2 (/ (* pi 3) 2) (/ day 2))) (setq pdim1 (polar pdi (/ (* pi 3) 2) (/ dc 25))) (setq pdim12 (polar pdi2 pi (/ dc 25))) (command "_dimlinear" pdi pdim pdim1) (command "_dimlinear" pdi2 pdim2 pdim12) (setq c 0) (while (< (1+ c) (length lpx)) (setq y (cadr pdim) x1 (nth c lpx) x2 (nth (1+ c) lpx) dd1 (list x1 y 0) dd2 (list x2 y 0) tam (list x1 (- (cadr pdim1) (* (* tldim th) 6)) 0) ) (command "_dimlinear" dd1 dd2 pdim1) (vetruc) (setq c (1+ c)) ) (setq tam (list x2 (- (cadr pdim1) (* (* tldim th) 6)) 0)) (vetruc) (setq c nil) (setq e 0) (while (< (1+ e) (length lpy)) (setq x (car pdim2)

y1 (nth e lpy) y2 (nth (1+ e) lpy) ddy1 (list x y1 0) ddy2 (list x y2 0) tam (list (- (car pdim12) (* (* tldim th) 7)) y1 0) ) (command "_dimlinear" ddy1 ddy2 pdim12) (vetruc) (setq e (1+ e)) ) (setq tam (list (- (car pdim12) (* (* tldim th) 7)) y2 0)) (vetruc) (setq e nil) (setq pcc (polar dd2 0 (/ day 2))) (setq pcc2 (polar ddy2 (/ pi 2) (/ day 2))) (command "_dimlinear" dd2 pcc pdim1) (command "_dimlinear" ddy2 pcc2 pdim12) (command "_dimlinear" pdim pcc (polar pdim1 (/ (* pi 3) 2) (* (* tldim th) 3)) ) (command "_dimlinear" pdim2 pcc2 (polar pdim12 pi (* (* tldim th) 3))

) )

;************************* (defun vetruc () (if (= (tblsearch "style" "chutruc") nil) (command "style" "chutruc" ".VnAvantH" "" "0.8" "" "" "") ) (setq r r2 dline1 dline2 (* (* th tldim) 2) (/ r 1.2) (polar tam 0 r2) (polar dline1 0 (/ (* r2 2) 3))

listtrucx '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20) listtrucy '("A" "I" "R" ) ) (command "circle" tam r) (command "change" "l" "" "p" "la" "tuong" "") (command "circle" tam r2) (command "change" "l" "" "p" "la" "_dim" "") (command "line" dline1 dline2 "") (command "change" "l" "" "p" "la" "tuong" "") (command "-array" "p" "" "p" tam "4" "360" "y") (if (= e nil) "B" "K" "S" "C" "D" "E" "L" "N" "M" "T" "U" "V" "F" "O" "X" "G" "H" "P" "Q" "Y" "Z"

(command "-text" "j" "m" tam r "0" (rtos (nth c listtrucx))) ) (if (= c nil) (command "-text" "j" "m" tam r "0" (nth e listtrucy)) ) ) ;******************************** (defun initvetuong () (setq vetuong_old_er *error* *error* vetuongerror ) ) ;************************** (defun vetuongerror (errmsg) (loivetuong))

;************************** (defun loivetuong () (setq *error* vetuong_old_er) (command "undo" "end") (command "undo" "") (princ "xay ra loi trong qua trinh ve") ) ;**************************

You might also like